diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index a4b2e18ec10..4a14223eb88 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -53,13 +53,13 @@ pub enum Def { Existential(DefId), /// `type Foo = Bar;` TyAlias(DefId), - Foreign(DefId), + TyForeign(DefId), TraitAlias(DefId), AssociatedTy(DefId), /// `existential type Foo: Bar;` AssociatedExistential(DefId), PrimTy(hir::PrimTy), - Param(DefId), + TyParam(DefId), SelfTy(Option /* trait */, Option /* impl */), ToolMod, // e.g. `rustfmt` in `#[rustfmt::skip]` @@ -269,10 +269,10 @@ impl Def { Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) | Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | Def::TyAlias(id) | Def::TraitAlias(id) | - Def::AssociatedTy(id) | Def::Param(id) | Def::Struct(id) | Def::StructCtor(id, ..) | + Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) | Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) | Def::Macro(id, ..) | - Def::Existential(id) | Def::AssociatedExistential(id) | Def::Foreign(id) => { + Def::Existential(id) | Def::AssociatedExistential(id) | Def::TyForeign(id) => { id } @@ -311,11 +311,11 @@ impl Def { Def::StructCtor(.., CtorKind::Fictive) => bug!("impossible struct constructor"), Def::Union(..) => "union", Def::Trait(..) => "trait", - Def::Foreign(..) => "foreign type", + Def::TyForeign(..) => "foreign type", Def::Method(..) => "method", Def::Const(..) => "constant", Def::AssociatedConst(..) => "associated constant", - Def::Param(..) => "type parameter", + Def::TyParam(..) => "type parameter", Def::PrimTy(..) => "builtin type", Def::Local(..) => "local variable", Def::Upvar(..) => "closure capture", diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 4251e4e9eaa..a43afa9e34a 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1213,7 +1213,7 @@ impl<'a> LoweringContext<'a> { None, P(hir::Path { span, - def: Def::Param(DefId::local(def_index)), + def: Def::TyParam(DefId::local(def_index)), segments: hir_vec![hir::PathSegment::from_ident(ident)], }), )) @@ -2352,7 +2352,7 @@ impl<'a> LoweringContext<'a> { if path.segments.len() == 1 && bound_pred.bound_generic_params.is_empty() => { - if let Some(Def::Param(def_id)) = self.resolver + if let Some(Def::TyParam(def_id)) = self.resolver .get_resolution(bound_pred.bounded_ty.id) .map(|d| d.base_def()) { diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index b48e9a1f45c..ebda91cb7b0 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -453,7 +453,7 @@ impl<'hir> Map<'hir> { match item.node { ForeignItemKind::Fn(..) => Some(Def::Fn(def_id)), ForeignItemKind::Static(_, m) => Some(Def::Static(def_id, m)), - ForeignItemKind::Type => Some(Def::Foreign(def_id)), + ForeignItemKind::Type => Some(Def::TyForeign(def_id)), } } NodeTraitItem(item) => { @@ -499,7 +499,7 @@ impl<'hir> Map<'hir> { NodeGenericParam(param) => { Some(match param.kind { GenericParamKind::Lifetime { .. } => Def::Local(param.id), - GenericParamKind::Type { .. } => Def::Param(self.local_def_id(param.id)), + GenericParamKind::Type { .. } => Def::TyParam(self.local_def_id(param.id)), }) } } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 4e75905595e..e1d673a5115 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -1010,9 +1010,9 @@ impl_stable_hash_for!(enum hir::def::Def { AssociatedTy(def_id), AssociatedExistential(def_id), PrimTy(prim_ty), - Param(def_id), + TyParam(def_id), SelfTy(trait_def_id, impl_def_id), - Foreign(def_id), + TyForeign(def_id), Fn(def_id), Const(def_id), Static(def_id, is_mutbl), diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 84890abc85d..379f4df11fa 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -1326,7 +1326,7 @@ fn object_lifetime_defaults_for_item( _ => continue, }; - if def == Def::Param(param_def_id) { + if def == Def::TyParam(param_def_id) { add_bounds(&mut set, &data.bounds); } } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d4bb5769c75..c26d8555214 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1510,7 +1510,7 @@ impl TypeAliasBounds { match ty.node { hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { match path.def { - Def::Param(_) => true, + Def::TyParam(_) => true, _ => false } } diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 292355b6656..f4dd8861e2a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -429,7 +429,7 @@ impl<'tcx> EntryKind<'tcx> { EntryKind::Trait(_) => Def::Trait(did), EntryKind::Enum(..) => Def::Enum(did), EntryKind::MacroDef(_) => Def::Macro(did, MacroKind::Bang), - EntryKind::ForeignType => Def::Foreign(did), + EntryKind::ForeignType => Def::TyForeign(did), EntryKind::ForeignMod | EntryKind::GlobalAsm | diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 0c55ae65ec7..19dc35f854e 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -656,7 +656,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { (Def::Static(self.definitions.local_def_id(item.id), m), ValueNS) } ForeignItemKind::Ty => { - (Def::Foreign(self.definitions.local_def_id(item.id)), TypeNS) + (Def::TyForeign(self.definitions.local_def_id(item.id)), TypeNS) } ForeignItemKind::Macro(_) => unreachable!(), }; @@ -692,7 +692,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { span); self.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion)); } - Def::Variant(..) | Def::TyAlias(..) | Def::Foreign(..) => { + Def::Variant(..) | Def::TyAlias(..) | Def::TyForeign(..) => { self.define(parent, ident, TypeNS, (def, vis, DUMMY_SP, expansion)); } Def::Fn(..) | Def::Static(..) | Def::Const(..) | Def::VariantCtor(..) => { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 3760a64b168..36b87823c7e 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -204,14 +204,14 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, "`Self` type implicitly declared here, on the `impl`"); } }, - Def::Param(typaram_defid) => { + Def::TyParam(typaram_defid) => { if let Some(typaram_span) = resolver.definitions.opt_span(typaram_defid) { err.span_label(typaram_span, "type variable from outer function"); } }, _ => { bug!("TypeParametersFromOuterFunction should only be used with Def::SelfTy or \ - Def::Param") + Def::TyParam") } } @@ -537,9 +537,9 @@ impl<'a> PathSource<'a> { PathSource::Type => match def { Def::Struct(..) | Def::Union(..) | Def::Enum(..) | Def::Trait(..) | Def::TyAlias(..) | Def::AssociatedTy(..) | - Def::PrimTy(..) | Def::Param(..) | Def::SelfTy(..) | + Def::PrimTy(..) | Def::TyParam(..) | Def::SelfTy(..) | Def::Existential(..) | - Def::Foreign(..) => true, + Def::TyForeign(..) => true, _ => false, }, PathSource::Trait(AliasPossibility::No) => match def { @@ -2359,7 +2359,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { seen_bindings.entry(ident).or_insert(param.ident.span); // Plain insert (no renaming). - let def = Def::Param(self.definitions.local_def_id(param.id)); + let def = Def::TyParam(self.definitions.local_def_id(param.id)); function_type_rib.bindings.insert(ident, def); self.record_def(param.id, PathResolution::new(def)); } @@ -3765,7 +3765,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { } } } - Def::Param(..) | Def::SelfTy(..) => { + Def::TyParam(..) | Def::SelfTy(..) => { for rib in ribs { match rib.kind { NormalRibKind | TraitOrImplItemRibKind | ClosureRibKind(..) | diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 2d9768db113..298f9549666 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -747,13 +747,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { HirDef::Union(def_id) | HirDef::Enum(def_id) | HirDef::TyAlias(def_id) | - HirDef::Foreign(def_id) | + HirDef::TyForeign(def_id) | HirDef::TraitAlias(def_id) | HirDef::AssociatedExistential(def_id) | HirDef::AssociatedTy(def_id) | HirDef::Trait(def_id) | HirDef::Existential(def_id) | - HirDef::Param(def_id) => { + HirDef::TyParam(def_id) => { let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Type, diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index b38002d0f62..e2f3451ce8f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1240,7 +1240,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { } } (&ty::Param(_), Def::SelfTy(Some(param_did), None)) | - (&ty::Param(_), Def::Param(param_did)) => { + (&ty::Param(_), Def::TyParam(param_did)) => { match self.find_bound_for_assoc_item(param_did, assoc_name, span) { Ok(bound) => bound, Err(ErrorReported) => return (tcx.types.err, Def::Err), @@ -1387,7 +1387,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { ) } Def::Enum(did) | Def::TyAlias(did) | Def::Struct(did) | - Def::Union(did) | Def::Foreign(did) => { + Def::Union(did) | Def::TyForeign(did) => { assert_eq!(opt_self_ty, None); self.prohibit_generics(path.segments.split_last().unwrap().1); self.ast_path_to_ty(span, did, path.segments.last().unwrap()) @@ -1401,7 +1401,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { tcx.parent_def_id(did).unwrap(), path.segments.last().unwrap()) } - Def::Param(did) => { + Def::TyParam(did) => { assert_eq!(opt_self_ty, None); self.prohibit_generics(&path.segments); diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 3f32e26c1b4..9aa2ba363ed 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -830,7 +830,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir::intravisit::walk_ty(self, ty); match ty.node { hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { - if let hir::def::Def::Param(def_id) = path.def { + if let hir::def::Def::TyParam(def_id) = path.def { if def_id == self.1 { self.0 = Some(ty.span); } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 14328578229..956d542ab7d 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -350,7 +350,7 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = ast_ty.node { match path.def { Def::SelfTy(Some(def_id), None) | - Def::Param(def_id) => { + Def::TyParam(def_id) => { def_id == tcx.hir.local_def_id(param_id) } _ => false diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ec5db1e7f9a..1c66c39b660 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -83,7 +83,7 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa ret.extend(build_impls(cx, did, true)); clean::EnumItem(build_enum(cx, did)) } - Def::Foreign(did) => { + Def::TyForeign(did) => { record_extern_fqn(cx, did, clean::TypeKind::Foreign); ret.extend(build_impls(cx, did, false)); clean::ForeignTypeItem diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 96d8cfff5d4..62f5c9795e4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2411,7 +2411,7 @@ impl Clean for hir::Ty { return new_ty; } - if let Def::Param(did) = path.def { + if let Def::TyParam(did) = path.def { if let Some(bounds) = cx.impl_trait_bounds.borrow_mut().remove(&did) { return ImplTrait(bounds); } @@ -2460,7 +2460,7 @@ impl Clean for hir::Ty { } hir::GenericParamKind::Type { ref default, .. } => { let ty_param_def = - Def::Param(cx.tcx.hir.local_def_id(param.id)); + Def::TyParam(cx.tcx.hir.local_def_id(param.id)); let mut j = 0; let type_ = generic_args.args.iter().find_map(|arg| { match arg { @@ -3710,10 +3710,10 @@ fn resolve_type(cx: &DocContext, Def::SelfTy(..) if path.segments.len() == 1 => { return Generic(keywords::SelfType.name().to_string()); } - Def::Param(..) if path.segments.len() == 1 => { + Def::TyParam(..) if path.segments.len() == 1 => { return Generic(format!("{:#}", path)); } - Def::SelfTy(..) | Def::Param(..) | Def::AssociatedTy(..) => true, + Def::SelfTy(..) | Def::TyParam(..) | Def::AssociatedTy(..) => true, _ => false, }; let did = register_def(&*cx, path.def); @@ -3731,7 +3731,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId { Def::Struct(i) => (i, TypeKind::Struct), Def::Union(i) => (i, TypeKind::Union), Def::Mod(i) => (i, TypeKind::Module), - Def::Foreign(i) => (i, TypeKind::Foreign), + Def::TyForeign(i) => (i, TypeKind::Foreign), Def::Const(i) => (i, TypeKind::Const), Def::Static(i, _) => (i, TypeKind::Static), Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"), diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index d08031cd219..a312913a69c 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -234,7 +234,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> DocContext<'a, 'tcx, 'rcx, 'cstore> { None, P(hir::Path { span: DUMMY_SP, - def: Def::Param(param.def_id), + def: Def::TyParam(param.def_id), segments: HirVec::from_vec(vec![ hir::PathSegment::from_ident(Ident::from_interned_str(param.name)) ]), diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index db32a324521..68ddf72da06 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -267,7 +267,7 @@ impl<'a, 'tcx, 'rcx, 'cstore> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { Def::Struct(did) | Def::Union(did) | Def::Enum(did) | - Def::Foreign(did) | + Def::TyForeign(did) | Def::TyAlias(did) if !self_is_hidden => { self.cx.access_levels.borrow_mut().map.insert(did, AccessLevel::Public); },