Skip to content

Commit c50cbd6

Browse files
committed
Rename *.node to *.kind in c2rust-refactor
1 parent 6e99017 commit c50cbd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+454
-461
lines changed

c2rust-refactor/gen/ast.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct Mod { inner, #[mac_table_seq] items, #[rewrite_ignore] inline }
3232

3333
#[rewrite_print_recover] #[rewrite_seq_item] #[rewrite_extra_strategies=item_header]
3434
#[nonterminal] #[extend_span]
35-
struct Item { ident, #[match=ignore] attrs, id, node, vis, span,
35+
struct Item { ident, #[match=ignore] attrs, id, kind, vis, span,
3636
#[match=ignore] #[rewrite_ignore] tokens }
3737
enum ItemKind {
3838
ExternCrate(name),
@@ -64,7 +64,7 @@ enum UseTreeKind {
6464
struct UseTree { kind, prefix, span }
6565

6666
#[nonterminal] #[extend_span]
67-
struct TraitItem { id, ident, #[match=ignore] attrs, generics, node, span,
67+
struct TraitItem { id, ident, #[match=ignore] attrs, generics, kind, span,
6868
#[match=ignore] #[rewrite_ignore] tokens }
6969
enum TraitItemKind {
7070
Const(ty, init),
@@ -74,7 +74,7 @@ enum TraitItemKind {
7474
}
7575

7676
#[nonterminal] #[extend_span]
77-
struct ImplItem { id, ident, vis, defaultness, #[match=ignore] attrs, generics, node, span,
77+
struct ImplItem { id, ident, vis, defaultness, #[match=ignore] attrs, generics, kind, span,
7878
#[match=ignore] #[rewrite_ignore] tokens }
7979
enum ImplItemKind {
8080
Const(ty, init),
@@ -102,7 +102,7 @@ struct MethodSig { header, decl }
102102

103103
struct ForeignMod { abi, #[mac_table_seq] items }
104104
#[rewrite_print_recover] #[rewrite_seq_item] #[nonterminal] #[extend_span]
105-
struct ForeignItem { ident, #[match=ignore] attrs, node, id, span, vis }
105+
struct ForeignItem { ident, #[match=ignore] attrs, kind, id, span, vis }
106106
enum ForeignItemKind {
107107
Fn(decl, generics),
108108
Static(ty, mutbl),
@@ -145,7 +145,7 @@ enum CrateSugar {
145145
}
146146

147147
#[match=custom] #[rewrite_print_recover] #[mac_table_record] #[nonterminal]
148-
struct Ty { id, node, span }
148+
struct Ty { id, kind, span }
149149
struct MutTy {ty, mutbl}
150150
enum TyKind {
151151
Slice(ty),
@@ -182,7 +182,7 @@ enum GenericBound {
182182

183183
struct PolyTraitRef { trait_ref, span, bound_generic_params }
184184

185-
struct FnDecl { inputs, output, c_variadic }
185+
struct FnDecl { inputs, output }
186186
struct FnHeader { unsafety, asyncness, constness, abi }
187187
#[rewrite_print]
188188
struct Param { attrs, ty, pat, id, span, is_placeholder }
@@ -193,7 +193,7 @@ enum FunctionRetTy {
193193

194194

195195
#[match=custom] #[rewrite_print_recover] #[rewrite_seq_item] #[nonterminal]
196-
struct Stmt { id, node, span }
196+
struct Stmt { id, kind, span }
197197
#[no_debug]
198198
enum StmtKind {
199199
Local(local),
@@ -208,7 +208,7 @@ struct Local { pat, ty, init, id, span, #[match=ignore] attrs }
208208

209209

210210
#[match=custom] #[rewrite_print_recover] #[extend_span] #[mac_table_record] #[nonterminal]
211-
struct Expr { id, node, span, #[match=ignore] attrs }
211+
struct Expr { id, kind, span, #[match=ignore] attrs }
212212
#[prec_contains_expr]
213213
enum ExprKind {
214214
Box(#[prec=PREFIX] expr),
@@ -281,7 +281,7 @@ struct Block { #[mac_table_seq] stmts, id, rules, span }
281281

282282

283283
#[match=custom] #[mac_table_record] #[nonterminal]
284-
struct Pat { id, node, span }
284+
struct Pat { id, kind, span }
285285
enum PatKind {
286286
Wild,
287287
Ident(mode, id, pat),
@@ -304,7 +304,7 @@ enum PatKind {
304304
struct FieldPat { id, ident, pat, is_shorthand, attrs, span, is_placeholder }
305305

306306
#[match=custom]
307-
struct Lit { token, node, span }
307+
struct Lit { token, kind, span }
308308

309309
enum LitKind {
310310
Str(sym, style),
@@ -455,7 +455,7 @@ struct DelimSpan { open, close }
455455
flag DelimToken;
456456
flag Token;
457457

458-
struct MetaItem { path, node, span }
458+
struct MetaItem { path, kind, span }
459459
enum MetaItemKind {
460460
Word,
461461
List(l),

c2rust-refactor/src/analysis/labeled_ty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'lty, 'tcx: 'lty, L: Clone> LabeledTyCtxt<'lty, L> {
9696
) -> LabeledTy<'lty, 'tcx, L> {
9797
use rustc::ty::TyKind::*;
9898
let label = f(ty);
99-
match ty.sty {
99+
match ty.kind {
100100
// Types with no arguments
101101
Bool | Char | Int(_) | Uint(_) | Float(_) | Str | Foreign(_) | Never => {
102102
self.mk(ty, &[], label)
@@ -181,7 +181,7 @@ impl<'lty, 'tcx: 'lty, L: Clone> LabeledTyCtxt<'lty, L> {
181181
lty: LabeledTy<'lty, 'tcx, L>,
182182
substs: &[LabeledTy<'lty, 'tcx, L>],
183183
) -> LabeledTy<'lty, 'tcx, L> {
184-
match lty.ty.sty {
184+
match lty.ty.kind {
185185
TyKind::Param(ref tp) => substs[tp.index as usize],
186186
_ => self.mk(
187187
lty.ty,
@@ -238,7 +238,7 @@ impl<'lty, 'tcx: 'lty, L: Clone> LabeledTyCtxt<'lty, L> {
238238

239239
impl<'lty, 'tcx, L: fmt::Debug> type_map::Type for LabeledTy<'lty, 'tcx, L> {
240240
fn sty(&self) -> &TyKind {
241-
&self.ty.sty
241+
&self.ty.kind
242242
}
243243

244244
fn num_args(&self) -> usize {

c2rust-refactor/src/analysis/ownership/annot.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct AttrVisitor<'ast> {
123123

124124
impl<'ast> Visitor<'ast> for AttrVisitor<'ast> {
125125
fn visit_item(&mut self, i: &'ast ast::Item) {
126-
match i.node {
126+
match i.kind {
127127
ast::ItemKind::Fn(..) | ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
128128
if i.attrs.len() > 0 {
129129
self.def_attrs.push((i.id, &i.attrs));
@@ -136,7 +136,7 @@ impl<'ast> Visitor<'ast> for AttrVisitor<'ast> {
136136
}
137137

138138
fn visit_impl_item(&mut self, i: &'ast ast::ImplItem) {
139-
match i.node {
139+
match i.kind {
140140
ast::ImplItemKind::Method(..) | ast::ImplItemKind::Const(..) => {
141141
if i.attrs.len() > 0 {
142142
self.def_attrs.push((i.id, &i.attrs));
@@ -274,14 +274,14 @@ pub fn handle_attrs<'a, 'hir, 'tcx, 'lty>(
274274
}
275275

276276
fn meta_item_list(meta: &ast::MetaItem) -> Result<&[ast::NestedMetaItem], &'static str> {
277-
match meta.node {
277+
match meta.kind {
278278
ast::MetaItemKind::List(ref xs) => Ok(xs),
279279
_ => Err("expected MetaItemKind::List"),
280280
}
281281
}
282282

283283
fn meta_item_word(meta: &ast::MetaItem) -> Result<(), &'static str> {
284-
match meta.node {
284+
match meta.kind {
285285
ast::MetaItemKind::Word => Ok(()),
286286
_ => Err("expected MetaItemKind::List"),
287287
}
@@ -296,7 +296,7 @@ fn nested_meta_item(nmeta: &ast::NestedMetaItem) -> Result<&ast::MetaItem, &'sta
296296

297297
fn nested_str(nmeta: &ast::NestedMetaItem) -> Result<Symbol, &'static str> {
298298
match nmeta {
299-
ast::NestedMetaItem::Literal(ref lit) => match lit.node {
299+
ast::NestedMetaItem::Literal(ref lit) => match lit.kind {
300300
ast::LitKind::Str(s, _) => Ok(s),
301301
_ => Err("expected str"),
302302
},

c2rust-refactor/src/analysis/ownership/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'lty, 'a: 'lty, 'tcx: 'a> Ctxt<'lty, 'tcx> {
141141
Entry::Vacant(e) => {
142142
*e.insert(
143143
self.lcx
144-
.label(self.tcx.type_of(did), &mut |ty| match ty.sty {
144+
.label(self.tcx.type_of(did), &mut |ty| match ty.kind {
145145
TyKind::Ref(_, _, _) | TyKind::RawPtr(_) => {
146146
let v = assign.push(ConcretePerm::Read);
147147
Some(PermVar::Static(v))
@@ -172,7 +172,7 @@ impl<'lty, 'a: 'lty, 'tcx: 'a> Ctxt<'lty, 'tcx> {
172172
let mut counter = 0;
173173

174174
let l_sig = {
175-
let mut f = |ty: Ty<'tcx>| match ty.sty {
175+
let mut f = |ty: Ty<'tcx>| match ty.kind {
176176
TyKind::Ref(_, _, _) | TyKind::RawPtr(_) => {
177177
let v = Var(counter);
178178
counter += 1;

c2rust-refactor/src/analysis/ownership/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
PrettyLabel<L>: fmt::Debug,
103103
{
104104
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
105-
match self.0.ty.sty {
105+
match self.0.ty.kind {
106106
TyKind::Ref(_, _, m) => write!(
107107
fmt,
108108
"&{}{:?} {:?}",

c2rust-refactor/src/analysis/ownership/intra.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> {
189189
ref mut insts,
190190
..
191191
} = *self;
192-
ilcx.label(ty, &mut |ty| match ty.sty {
192+
ilcx.label(ty, &mut |ty| match ty.kind {
193193
TyKind::Ref(_, _, _) | TyKind::RawPtr(_) => {
194194
let v = Var(*next_local_var);
195195
*next_local_var += 1;
@@ -290,7 +290,7 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> {
290290
}
291291

292292
fn field_lty(&mut self, base_ty: ITy<'lty, 'tcx>, v: VariantIdx, f: Field) -> ITy<'lty, 'tcx> {
293-
match base_ty.ty.sty {
293+
match base_ty.ty.kind {
294294
TyKind::Adt(adt, _substs) => {
295295
let field_def = &adt.variants[v].fields[f.index()];
296296
let poly_ty = self.static_ty(field_def.did);
@@ -493,7 +493,7 @@ impl<'c, 'lty, 'a: 'lty, 'tcx: 'a> IntraCtxt<'c, 'lty, 'a, 'tcx> {
493493
}
494494

495495
fn ty_fn_sig(&mut self, ty: ITy<'lty, 'tcx>) -> IFnSig<'lty, 'tcx> {
496-
match ty.ty.sty {
496+
match ty.ty.kind {
497497
TyKind::FnDef(did, _substs) => {
498498
let idx = expect!([ty.label] Label::FnDef(idx) => idx);
499499
let var_base = self.insts[idx].first_inst_var;

c2rust-refactor/src/analysis/ownership/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,19 @@ fn is_fn(hir_map: &hir::map::Map, def_id: DefId) -> bool {
143143
};
144144

145145
match n {
146-
Node::Item(i) => match i.node {
146+
Node::Item(i) => match i.kind {
147147
hir::ItemKind::Fn(..) => true,
148148
_ => false,
149149
},
150-
Node::ForeignItem(i) => match i.node {
150+
Node::ForeignItem(i) => match i.kind {
151151
hir::ForeignItemKind::Fn(..) => true,
152152
_ => false,
153153
},
154-
Node::TraitItem(i) => match i.node {
154+
Node::TraitItem(i) => match i.kind {
155155
hir::TraitItemKind::Method(..) => true,
156156
_ => false,
157157
},
158-
Node::ImplItem(i) => match i.node {
158+
Node::ImplItem(i) => match i.kind {
159159
hir::ImplItemKind::Method(..) => true,
160160
_ => false,
161161
},
@@ -198,9 +198,9 @@ fn analyze_inter<'lty, 'tcx>(cx: &mut Ctxt<'lty, 'tcx>) {
198198
}
199199

200200
fn is_mut_t(ty: &TyS) -> bool {
201-
if let TyKind::RawPtr(mut_ty) = ty.sty {
201+
if let TyKind::RawPtr(mut_ty) = ty.kind {
202202
if mut_ty.mutbl == Mutability::MutMutable {
203-
if let TyKind::Param(param_ty) = mut_ty.ty.sty {
203+
if let TyKind::Param(param_ty) = mut_ty.ty.kind {
204204
return param_ty.name.as_str() == "T";
205205
}
206206
}
@@ -224,7 +224,7 @@ fn register_std_constraints<'a, 'tcx, 'lty>(
224224
// fn offset<T>(self: *mut T, _: isize) -> *mut T;
225225
if func_summ.sig.inputs.len() == 2 && fn_name_path == "::ptr[0]::{{impl}}[1]::offset[0]" {
226226
let param0_is_mut_t = is_mut_t(func_summ.sig.inputs[0].ty);
227-
let param1_is_isize = if let TyKind::Int(int_ty) = func_summ.sig.inputs[1].ty.sty {
227+
let param1_is_isize = if let TyKind::Int(int_ty) = func_summ.sig.inputs[1].ty.kind {
228228
int_ty == IntTy::Isize
229229
} else {
230230
false

c2rust-refactor/src/analysis/type_eq.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'lty, 'a, 'hir> ItemLikeVisitor<'hir> for ExprPatVisitor<'lty, 'hir> {
223223
// Visit every itemlike with a BodyId, and call `handle_body` on each.
224224

225225
fn visit_item(&mut self, item: &'hir Item) {
226-
let body_id = match item.node {
226+
let body_id = match item.kind {
227227
ItemKind::Static(_, _, body_id) => body_id,
228228
ItemKind::Const(_, body_id) => body_id,
229229
ItemKind::Fn(_, _, _, body_id) => body_id,
@@ -233,7 +233,7 @@ impl<'lty, 'a, 'hir> ItemLikeVisitor<'hir> for ExprPatVisitor<'lty, 'hir> {
233233
}
234234

235235
fn visit_trait_item(&mut self, item: &'hir TraitItem) {
236-
let body_id = match item.node {
236+
let body_id = match item.kind {
237237
TraitItemKind::Const(_, Some(body_id)) => body_id,
238238
TraitItemKind::Method(_, TraitMethod::Provided(body_id)) => body_id,
239239
_ => return,
@@ -242,7 +242,7 @@ impl<'lty, 'a, 'hir> ItemLikeVisitor<'hir> for ExprPatVisitor<'lty, 'hir> {
242242
}
243243

244244
fn visit_impl_item(&mut self, item: &'hir ImplItem) {
245-
let body_id = match item.node {
245+
let body_id = match item.kind {
246246
ImplItemKind::Const(_, body_id) => body_id,
247247
ImplItemKind::Method(_, body_id) => body_id,
248248
_ => return,
@@ -486,7 +486,7 @@ impl<'lty, 'tcx> UnifyVisitor<'lty, 'tcx> {
486486

487487
fn fn_num_inputs(&self, lty: LTy<'lty, 'tcx>) -> usize {
488488
use rustc::ty::TyKind::*;
489-
match lty.ty.sty {
489+
match lty.ty.kind {
490490
FnDef(id, _) => self.def_sig(id).inputs.len(),
491491
FnPtr(_) => lty.args.len() - 1,
492492
// TODO: Handle Closure. This should be similar to FnDef, but the substs are a bit
@@ -498,7 +498,7 @@ impl<'lty, 'tcx> UnifyVisitor<'lty, 'tcx> {
498498
/// Get the input types out of a `FnPtr` or `FnDef` `LTy`.
499499
fn fn_input(&self, lty: LTy<'lty, 'tcx>, idx: usize) -> LTy<'lty, 'tcx> {
500500
use rustc::ty::TyKind::*;
501-
match lty.ty.sty {
501+
match lty.ty.kind {
502502
FnDef(id, _) => {
503503
// For a `FnDef`, retrieve the `LFnSig` for the given `DefId` and apply the
504504
// labeled substs recorded in `LTy.args`.
@@ -517,7 +517,7 @@ impl<'lty, 'tcx> UnifyVisitor<'lty, 'tcx> {
517517
/// Get the output type out of a `FnPtr` or `FnDef` `LTy`.
518518
fn fn_output(&self, lty: LTy<'lty, 'tcx>) -> LTy<'lty, 'tcx> {
519519
use rustc::ty::TyKind::*;
520-
match lty.ty.sty {
520+
match lty.ty.kind {
521521
FnDef(id, _) => {
522522
let sig = self.def_sig(id);
523523
self.ltt.subst(sig.output, &lty.args)
@@ -530,7 +530,7 @@ impl<'lty, 'tcx> UnifyVisitor<'lty, 'tcx> {
530530

531531
fn fn_is_variadic(&self, lty: LTy<'lty, 'tcx>) -> bool {
532532
use rustc::ty::TyKind::*;
533-
match lty.ty.sty {
533+
match lty.ty.kind {
534534
FnDef(id, _) => self.def_sig(id).c_variadic,
535535
FnPtr(ty_sig) => ty_sig.skip_binder().c_variadic,
536536
// TODO: Closure
@@ -559,7 +559,7 @@ impl<'lty, 'tcx> UnifyVisitor<'lty, 'tcx> {
559559
/// Get the labeled type of a field. For generic structs, this returns the type after
560560
/// substitution, using the type arguments from `struct_ty`.
561561
fn field_lty(&self, struct_ty: LTy<'lty, 'tcx>, name: Symbol) -> LTy<'lty, 'tcx> {
562-
let adt = match struct_ty.ty.sty {
562+
let adt = match struct_ty.ty.kind {
563563
ty::TyKind::Adt(ref adt, _) => adt,
564564
_ => panic!("field_lty: not a struct ty: {:?}", struct_ty),
565565
};
@@ -601,7 +601,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'hir> {
601601
// whole analysis to run over MIR. At that level, operator-overload method calls are fully
602602
// explicit.)
603603

604-
match e.node {
604+
match e.kind {
605605
ExprKind::Box(ref e) => {
606606
self.ltt.unify(rty.args[0], self.expr_lty(e));
607607
}
@@ -616,7 +616,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'hir> {
616616
let func_lty = self.expr_lty(func);
617617

618618
fn is_closure(ty: ty::Ty) -> bool {
619-
if let ty::TyKind::Closure(..) = ty.sty {
619+
if let ty::TyKind::Closure(..) = ty.kind {
620620
true
621621
} else {
622622
false
@@ -831,7 +831,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'hir> {
831831
fn visit_pat(&mut self, p: &'hir Pat) {
832832
let rty = self.pat_lty(p);
833833

834-
match p.node {
834+
match p.kind {
835835
PatKind::Wild => {}
836836

837837
PatKind::Binding(_, node_id, _, ref opt_pat) => {
@@ -936,7 +936,7 @@ impl<'lty, 'a, 'hir> Visitor<'hir> for UnifyVisitor<'lty, 'hir> {
936936

937937
fn visit_foreign_item(&mut self, i: &'hir ForeignItem) {
938938
let def_id = self.tcx.hir().local_def_id(i.hir_id);
939-
match i.node {
939+
match i.kind {
940940
ForeignItemKind::Fn(ref decl, _, _) => {
941941
let sig = self.def_sig(def_id);
942942

c2rust-refactor/src/ast_manip/ast_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct MapAstInto<'a, 's: 'a> {
9696

9797
impl<'a, 's> Visitor<'s> for MapAstInto<'a, 's> {
9898
fn visit_expr(&mut self, x: &'s Expr) {
99-
if let ExprKind::Paren(_) = x.node {
99+
if let ExprKind::Paren(_) = x.kind {
100100
// Ignore. `Paren` nodes cause problems because they have the same NodeId as the inner
101101
// expression.
102102
} else {
@@ -175,7 +175,7 @@ struct MapAstIntoUnified<'a, 's: 'a> {
175175

176176
impl<'a, 's> Visitor<'s> for MapAstIntoUnified<'a, 's> {
177177
fn visit_expr(&mut self, x: &'s Expr) {
178-
if let ExprKind::Paren(_) = x.node {
178+
if let ExprKind::Paren(_) = x.kind {
179179
// Ignore. `Paren` nodes cause problems because they have the same NodeId as the inner
180180
// expression.
181181
} else {

0 commit comments

Comments
 (0)