Skip to content

Commit b31cc64

Browse files
committed
Auto merge of #29766 - oli-obk:impl_item, r=nikomatsakis
[breaking change] I'm not sure if those renames are ok. [TokenType::Tt* to TokenType::*](#29582) was obvious, but for all those Item-enums it's less obvious to me what the right way forward is due to the underscore.
2 parents 8809a33 + d09220d commit b31cc64

File tree

41 files changed

+150
-154
lines changed

Some content is hidden

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

41 files changed

+150
-154
lines changed

src/librustc/front/map/blocks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'a> FnLikeNode<'a> {
236236
},
237237
map::NodeImplItem(ii) => {
238238
match ii.node {
239-
ast::MethodImplItem(ref sig, ref body) => {
239+
ast::ImplItemKind::Method(ref sig, ref body) => {
240240
method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span)
241241
}
242242
_ => {

src/librustc/front/map/collector.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
224224

225225
fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
226226
let def_data = match ii.node {
227-
MethodImplItem(..) | ConstImplItem(..) => DefPathData::Value(ii.name),
228-
TypeImplItem(..) => DefPathData::Type(ii.name),
227+
ImplItemKind::Method(..) | ImplItemKind::Const(..) => DefPathData::Value(ii.name),
228+
ImplItemKind::Type(..) => DefPathData::Type(ii.name),
229229
};
230230

231231
self.insert_def(ii.id, NodeImplItem(ii), def_data);
@@ -234,7 +234,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
234234
self.parent_node = ii.id;
235235

236236
match ii.node {
237-
ConstImplItem(_, ref expr) => {
237+
ImplItemKind::Const(_, ref expr) => {
238238
self.create_def(expr.id, DefPathData::Initializer);
239239
}
240240
_ => { }
@@ -313,4 +313,3 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
313313
self.create_def(macro_def.id, DefPathData::MacroDef(macro_def.name));
314314
}
315315
}
316-

src/librustc/front/map/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -937,18 +937,18 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
937937
}
938938
Some(NodeImplItem(ii)) => {
939939
match ii.node {
940-
ConstImplItem(..) => {
940+
ImplItemKind::Const(..) => {
941941
format!("assoc const {} in {}{}",
942942
ii.name,
943943
map.path_to_string(id),
944944
id_str)
945945
}
946-
MethodImplItem(..) => {
946+
ImplItemKind::Method(..) => {
947947
format!("method {} in {}{}",
948948
ii.name,
949949
map.path_to_string(id), id_str)
950950
}
951-
TypeImplItem(_) => {
951+
ImplItemKind::Type(_) => {
952952
format!("assoc type {} in {}{}",
953953
ii.name,
954954
map.path_to_string(id),

src/librustc/metadata/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
739739
let elem = ast_map::PathName(m.name);
740740
encode_path(rbml_w, impl_path.chain(Some(elem)));
741741
if let Some(impl_item) = impl_item_opt {
742-
if let hir::MethodImplItem(ref sig, _) = impl_item.node {
742+
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
743743
encode_attributes(rbml_w, &impl_item.attrs);
744744
let scheme = ecx.tcx.lookup_item_type(m.def_id);
745745
let any_types = !scheme.generics.types.is_empty();

src/librustc/middle/check_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
348348

349349
fn visit_impl_item(&mut self, i: &'v hir::ImplItem) {
350350
match i.node {
351-
hir::ConstImplItem(_, ref expr) => {
351+
hir::ImplItemKind::Const(_, ref expr) => {
352352
self.global_expr(Mode::Const, &*expr);
353353
}
354354
_ => self.with_mode(Mode::Var, |v| visit::walk_impl_item(v, i)),

src/librustc/middle/check_static_recursion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
7979

8080
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
8181
match ii.node {
82-
hir::ConstImplItem(..) => {
82+
hir::ImplItemKind::Const(..) => {
8383
let mut recursion_visitor =
8484
CheckItemRecursionVisitor::new(self, &ii.span);
8585
recursion_visitor.visit_impl_item(ii);

src/librustc/middle/const_eval.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
129129
_ => None
130130
},
131131
Some(ast_map::NodeImplItem(ii)) => match ii.node {
132-
hir::ConstImplItem(_, ref expr) => {
132+
hir::ImplItemKind::Const(_, ref expr) => {
133133
Some(&*expr)
134134
}
135135
_ => None
@@ -171,7 +171,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
171171
_ => None
172172
},
173173
csearch::FoundAst::Found(&InlinedItem::ImplItem(_, ref ii)) => match ii.node {
174-
hir::ConstImplItem(_, ref expr) => Some(expr.id),
174+
hir::ImplItemKind::Const(_, ref expr) => Some(expr.id),
175175
_ => None
176176
},
177177
_ => None
@@ -996,7 +996,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
996996
},
997997
ty::ImplContainer(_) => match tcx.map.find(node_id) {
998998
Some(ast_map::NodeImplItem(ii)) => match ii.node {
999-
hir::ConstImplItem(ref ty, ref expr) => {
999+
hir::ImplItemKind::Const(ref ty, ref expr) => {
10001000
(Some(&**expr), Some(&**ty))
10011001
}
10021002
_ => (None, None)

src/librustc/middle/dead.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ impl<'v> Visitor<'v> for LifeSeeder {
358358
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
359359
for impl_item in impl_items {
360360
match impl_item.node {
361-
hir::ConstImplItem(..) |
362-
hir::MethodImplItem(..) => {
361+
hir::ImplItemKind::Const(..) |
362+
hir::ImplItemKind::Method(..) => {
363363
if opt_trait.is_some() ||
364364
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
365365
self.worklist.push(impl_item.id);
366366
}
367367
}
368-
hir::TypeImplItem(_) => {}
368+
hir::ImplItemKind::Type(_) => {}
369369
}
370370
}
371371
}
@@ -571,21 +571,21 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
571571

572572
fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
573573
match impl_item.node {
574-
hir::ConstImplItem(_, ref expr) => {
574+
hir::ImplItemKind::Const(_, ref expr) => {
575575
if !self.symbol_is_live(impl_item.id, None) {
576576
self.warn_dead_code(impl_item.id, impl_item.span,
577577
impl_item.name, "associated const");
578578
}
579579
visit::walk_expr(self, expr)
580580
}
581-
hir::MethodImplItem(_, ref body) => {
581+
hir::ImplItemKind::Method(_, ref body) => {
582582
if !self.symbol_is_live(impl_item.id, None) {
583583
self.warn_dead_code(impl_item.id, impl_item.span,
584584
impl_item.name, "method");
585585
}
586586
visit::walk_block(self, body)
587587
}
588-
hir::TypeImplItem(..) => {}
588+
hir::ImplItemKind::Type(..) => {}
589589
}
590590
}
591591

src/librustc/middle/infer/error_reporting.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
948948
}
949949
ast_map::NodeImplItem(item) => {
950950
match item.node {
951-
hir::MethodImplItem(ref sig, _) => {
951+
hir::ImplItemKind::Method(ref sig, _) => {
952952
Some((&sig.decl,
953953
&sig.generics,
954954
sig.unsafety,
@@ -1838,7 +1838,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
18381838
},
18391839
ast_map::NodeImplItem(ii) => {
18401840
match ii.node {
1841-
hir::MethodImplItem(ref sig, _) => {
1841+
hir::ImplItemKind::Method(ref sig, _) => {
18421842
taken.push_all(&sig.generics.lifetimes);
18431843
Some(ii.id)
18441844
}

src/librustc/middle/reachable.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
185185
}
186186
Some(ast_map::NodeImplItem(impl_item)) => {
187187
match impl_item.node {
188-
hir::ConstImplItem(..) => true,
189-
hir::MethodImplItem(ref sig, _) => {
188+
hir::ImplItemKind::Const(..) => true,
189+
hir::ImplItemKind::Method(ref sig, _) => {
190190
if generics_require_inlining(&sig.generics) ||
191191
attr::requests_inline(&impl_item.attrs) {
192192
true
@@ -206,7 +206,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
206206
}
207207
}
208208
}
209-
hir::TypeImplItem(_) => false,
209+
hir::ImplItemKind::Type(_) => false,
210210
}
211211
}
212212
Some(_) => false,
@@ -299,16 +299,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
299299
}
300300
ast_map::NodeImplItem(impl_item) => {
301301
match impl_item.node {
302-
hir::ConstImplItem(_, ref expr) => {
302+
hir::ImplItemKind::Const(_, ref expr) => {
303303
self.visit_expr(&*expr);
304304
}
305-
hir::MethodImplItem(ref sig, ref body) => {
305+
hir::ImplItemKind::Method(ref sig, ref body) => {
306306
let did = self.tcx.map.get_parent_did(search_item);
307307
if method_might_be_inlined(self.tcx, sig, impl_item, did) {
308308
visit::walk_block(self, body)
309309
}
310310
}
311-
hir::TypeImplItem(_) => {}
311+
hir::ImplItemKind::Type(_) => {}
312312
}
313313
}
314314
// Nothing to recurse on for these

src/librustc/middle/ty/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
11241124
match cx.map.find(id) {
11251125
Some(ast_map::NodeImplItem(ref impl_item)) => {
11261126
match impl_item.node {
1127-
hir::TypeImplItem(_) => {
1127+
hir::ImplItemKind::Type(_) => {
11281128
// associated types don't have their own entry (for some reason),
11291129
// so for now just grab environment for the impl
11301130
let impl_id = cx.map.get_parent(id);
@@ -1136,7 +1136,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
11361136
&predicates,
11371137
id)
11381138
}
1139-
hir::ConstImplItem(_, _) => {
1139+
hir::ImplItemKind::Const(_, _) => {
11401140
let def_id = cx.map.local_def_id(id);
11411141
let scheme = cx.lookup_item_type(def_id);
11421142
let predicates = cx.lookup_predicates(def_id);
@@ -1145,7 +1145,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
11451145
&predicates,
11461146
id)
11471147
}
1148-
hir::MethodImplItem(_, ref body) => {
1148+
hir::ImplItemKind::Method(_, ref body) => {
11491149
let method_def_id = cx.map.local_def_id(id);
11501150
match cx.impl_or_trait_item(method_def_id) {
11511151
MethodTraitItem(ref method_ty) => {
@@ -2158,7 +2158,7 @@ impl<'tcx> ctxt<'tcx> {
21582158
}
21592159
ItemImpl(_, _, _, _, _, ref iis) => {
21602160
iis.iter().filter_map(|ii| {
2161-
if let hir::ConstImplItem(_, _) = ii.node {
2161+
if let hir::ImplItemKind::Const(_, _) = ii.node {
21622162
match self.impl_or_trait_item(self.map.local_def_id(ii.id)) {
21632163
ConstTraitItem(ac) => Some(ac),
21642164
_ => {

src/librustc_borrowck/borrowck/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
8989
}
9090

9191
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
92-
if let hir::ConstImplItem(_, ref expr) = ii.node {
92+
if let hir::ImplItemKind::Const(_, ref expr) = ii.node {
9393
gather_loans::gather_loans_in_static_initializer(self, &*expr);
9494
}
9595
visit::walk_impl_item(self, ii);

src/librustc_driver/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ impl fold::Folder for ReplaceBodyWithLoop {
623623

624624
fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> {
625625
match i.node {
626-
ast::ConstImplItem(..) => {
626+
ast::ImplItemKind::Const(..) => {
627627
self.within_static_or_const = true;
628628
let ret = fold::noop_fold_impl_item(i, self);
629629
self.within_static_or_const = false;

src/librustc_front/fold.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,13 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T) -> P<ImplI
866866
attrs: fold_attrs(attrs, folder),
867867
vis: vis,
868868
node: match node {
869-
ConstImplItem(ty, expr) => {
870-
ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr))
869+
ImplItemKind::Const(ty, expr) => {
870+
ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr))
871871
}
872-
MethodImplItem(sig, body) => {
873-
MethodImplItem(noop_fold_method_sig(sig, folder), folder.fold_block(body))
872+
ImplItemKind::Method(sig, body) => {
873+
ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body))
874874
}
875-
TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)),
875+
ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)),
876876
},
877877
span: folder.new_span(span),
878878
}

src/librustc_front/hir.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub use self::ExplicitSelf_::*;
1919
pub use self::Expr_::*;
2020
pub use self::FunctionRetTy::*;
2121
pub use self::ForeignItem_::*;
22-
pub use self::ImplItem_::*;
2322
pub use self::Item_::*;
2423
pub use self::Mutability::*;
2524
pub use self::Pat_::*;
@@ -771,15 +770,15 @@ pub struct ImplItem {
771770
pub name: Name,
772771
pub vis: Visibility,
773772
pub attrs: Vec<Attribute>,
774-
pub node: ImplItem_,
773+
pub node: ImplItemKind,
775774
pub span: Span,
776775
}
777776

778777
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
779-
pub enum ImplItem_ {
780-
ConstImplItem(P<Ty>, P<Expr>),
781-
MethodImplItem(MethodSig, P<Block>),
782-
TypeImplItem(P<Ty>),
778+
pub enum ImplItemKind {
779+
Const(P<Ty>, P<Expr>),
780+
Method(MethodSig, P<Block>),
781+
Type(P<Ty>),
783782
}
784783

785784
// Bind a type to an associated type: `A=Foo`.

src/librustc_front/lowering.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,14 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem
677677
attrs: i.attrs.clone(),
678678
vis: lower_visibility(_lctx, i.vis),
679679
node: match i.node {
680-
ConstImplItem(ref ty, ref expr) => {
681-
hir::ConstImplItem(lower_ty(_lctx, ty), lower_expr(_lctx, expr))
680+
ImplItemKind::Const(ref ty, ref expr) => {
681+
hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr))
682682
}
683-
MethodImplItem(ref sig, ref body) => {
684-
hir::MethodImplItem(lower_method_sig(_lctx, sig), lower_block(_lctx, body))
683+
ImplItemKind::Method(ref sig, ref body) => {
684+
hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body))
685685
}
686-
TypeImplItem(ref ty) => hir::TypeImplItem(lower_ty(_lctx, ty)),
687-
MacImplItem(..) => panic!("Shouldn't exist any more"),
686+
ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)),
687+
ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),
688688
},
689689
span: i.span,
690690
})

src/librustc_front/print/pprust.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1006,16 +1006,16 @@ impl<'a> State<'a> {
10061006
try!(self.maybe_print_comment(ii.span.lo));
10071007
try!(self.print_outer_attributes(&ii.attrs));
10081008
match ii.node {
1009-
hir::ConstImplItem(ref ty, ref expr) => {
1009+
hir::ImplItemKind::Const(ref ty, ref expr) => {
10101010
try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis));
10111011
}
1012-
hir::MethodImplItem(ref sig, ref body) => {
1012+
hir::ImplItemKind::Method(ref sig, ref body) => {
10131013
try!(self.head(""));
10141014
try!(self.print_method_sig(ii.name, sig, ii.vis));
10151015
try!(self.nbsp());
10161016
try!(self.print_block_with_attrs(body, &ii.attrs));
10171017
}
1018-
hir::TypeImplItem(ref ty) => {
1018+
hir::ImplItemKind::Type(ref ty) => {
10191019
try!(self.print_associated_type(ii.name, None, Some(ty)));
10201020
}
10211021
}

src/librustc_front/visit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -614,18 +614,18 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
614614
visitor.visit_name(impl_item.span, impl_item.name);
615615
walk_list!(visitor, visit_attribute, &impl_item.attrs);
616616
match impl_item.node {
617-
ConstImplItem(ref ty, ref expr) => {
617+
ImplItemKind::Const(ref ty, ref expr) => {
618618
visitor.visit_ty(ty);
619619
visitor.visit_expr(expr);
620620
}
621-
MethodImplItem(ref sig, ref body) => {
621+
ImplItemKind::Method(ref sig, ref body) => {
622622
visitor.visit_fn(FnKind::Method(impl_item.name, sig, Some(impl_item.vis)),
623623
&sig.decl,
624624
body,
625625
impl_item.span,
626626
impl_item.id);
627627
}
628-
TypeImplItem(ref ty) => {
628+
ImplItemKind::Type(ref ty) => {
629629
visitor.visit_ty(ty);
630630
}
631631
}

src/librustc_lint/bad_style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl LateLintPass for NonUpperCaseGlobals {
351351

352352
fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
353353
match ii.node {
354-
hir::ConstImplItem(..) => {
354+
hir::ImplItemKind::Const(..) => {
355355
NonUpperCaseGlobals::check_upper_case(cx, "associated constant",
356356
ii.name, ii.span);
357357
}

src/librustc_lint/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ impl LateLintPass for MissingDoc {
505505
}
506506

507507
let desc = match impl_item.node {
508-
hir::ConstImplItem(..) => "an associated constant",
509-
hir::MethodImplItem(..) => "a method",
510-
hir::TypeImplItem(_) => "an associated type",
508+
hir::ImplItemKind::Const(..) => "an associated constant",
509+
hir::ImplItemKind::Method(..) => "a method",
510+
hir::ImplItemKind::Type(_) => "an associated type",
511511
};
512512
self.check_missing_docs_attrs(cx, Some(impl_item.id),
513513
&impl_item.attrs,

0 commit comments

Comments
 (0)