diff options
Diffstat (limited to 'src')
25 files changed, 429 insertions, 386 deletions
diff --git a/src/librustc/arena.rs b/src/librustc/arena.rs index f604a66aebc..1381772d5e8 100644 --- a/src/librustc/arena.rs +++ b/src/librustc/arena.rs @@ -132,21 +132,21 @@ macro_rules! arena_types { [] expr: rustc::hir::Expr<$tcx>, [] field: rustc::hir::Field<$tcx>, [] field_pat: rustc::hir::FieldPat<$tcx>, - [] fn_decl: rustc::hir::FnDecl, + [] fn_decl: rustc::hir::FnDecl<$tcx>, [] foreign_item: rustc::hir::ForeignItem<$tcx>, - [] impl_item_ref: rustc::hir::ImplItemRef, + [] impl_item_ref: rustc::hir::ImplItemRef<$tcx>, [] inline_asm: rustc::hir::InlineAsm<$tcx>, [] local: rustc::hir::Local<$tcx>, [few] macro_def: rustc::hir::MacroDef<$tcx>, [] param: rustc::hir::Param<$tcx>, [] pat: rustc::hir::Pat<$tcx>, - [] path: rustc::hir::Path, - [] path_segment: rustc::hir::PathSegment, - [] qpath: rustc::hir::QPath, + [] path: rustc::hir::Path<$tcx>, + [] path_segment: rustc::hir::PathSegment<$tcx>, + [] qpath: rustc::hir::QPath<$tcx>, [] stmt: rustc::hir::Stmt<$tcx>, [] struct_field: rustc::hir::StructField<$tcx>, [] trait_item_ref: rustc::hir::TraitItemRef, - [] ty: rustc::hir::Ty, + [] ty: rustc::hir::Ty<$tcx>, [] variant: rustc::hir::Variant<$tcx>, ], $tcx); ) diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 7011a572fb1..33e636a03bd 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -42,10 +42,10 @@ use syntax_pos::Span; #[derive(Copy, Clone)] pub enum FnKind<'a> { /// `#[xxx] pub async/const/extern "Abi" fn foo()` - ItemFn(Ident, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]), + ItemFn(Ident, &'a Generics<'a>, FnHeader, &'a Visibility<'a>, &'a [Attribute]), /// `fn foo(&self)` - Method(Ident, &'a FnSig<'a>, Option<&'a Visibility>, &'a [Attribute]), + Method(Ident, &'a FnSig<'a>, Option<&'a Visibility<'a>>, &'a [Attribute]), /// `|x, y| {}` Closure(&'a [Attribute]), @@ -274,25 +274,25 @@ pub trait Visitor<'v>: Sized { fn visit_expr(&mut self, ex: &'v Expr<'v>) { walk_expr(self, ex) } - fn visit_ty(&mut self, t: &'v Ty) { + fn visit_ty(&mut self, t: &'v Ty<'v>) { walk_ty(self, t) } - fn visit_generic_param(&mut self, p: &'v GenericParam) { + fn visit_generic_param(&mut self, p: &'v GenericParam<'v>) { walk_generic_param(self, p) } - fn visit_generics(&mut self, g: &'v Generics) { + fn visit_generics(&mut self, g: &'v Generics<'v>) { walk_generics(self, g) } - fn visit_where_predicate(&mut self, predicate: &'v WherePredicate) { + fn visit_where_predicate(&mut self, predicate: &'v WherePredicate<'v>) { walk_where_predicate(self, predicate) } - fn visit_fn_decl(&mut self, fd: &'v FnDecl) { + fn visit_fn_decl(&mut self, fd: &'v FnDecl<'v>) { walk_fn_decl(self, fd) } - fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: BodyId, s: Span, id: HirId) { + fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl<'v>, b: BodyId, s: Span, id: HirId) { walk_fn(self, fk, fd, b, s, id) } - fn visit_use(&mut self, path: &'v Path, hir_id: HirId) { + fn visit_use(&mut self, path: &'v Path<'v>, hir_id: HirId) { walk_use(self, path, hir_id) } fn visit_trait_item(&mut self, ti: &'v TraitItem<'v>) { @@ -304,23 +304,23 @@ pub trait Visitor<'v>: Sized { fn visit_impl_item(&mut self, ii: &'v ImplItem<'v>) { walk_impl_item(self, ii) } - fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef) { + fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef<'v>) { walk_impl_item_ref(self, ii) } - fn visit_trait_ref(&mut self, t: &'v TraitRef) { + fn visit_trait_ref(&mut self, t: &'v TraitRef<'v>) { walk_trait_ref(self, t) } - fn visit_param_bound(&mut self, bounds: &'v GenericBound) { + fn visit_param_bound(&mut self, bounds: &'v GenericBound<'v>) { walk_param_bound(self, bounds) } - fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: TraitBoundModifier) { + fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef<'v>, m: TraitBoundModifier) { walk_poly_trait_ref(self, t, m) } fn visit_variant_data( &mut self, s: &'v VariantData<'v>, _: Name, - _: &'v Generics, + _: &'v Generics<'v>, _parent_id: HirId, _: Span, ) { @@ -332,19 +332,19 @@ pub trait Visitor<'v>: Sized { fn visit_enum_def( &mut self, enum_definition: &'v EnumDef<'v>, - generics: &'v Generics, + generics: &'v Generics<'v>, item_id: HirId, _: Span, ) { walk_enum_def(self, enum_definition, generics, item_id) } - fn visit_variant(&mut self, v: &'v Variant<'v>, g: &'v Generics, item_id: HirId) { + fn visit_variant(&mut self, v: &'v Variant<'v>, g: &'v Generics<'v>, item_id: HirId) { walk_variant(self, v, g, item_id) } fn visit_label(&mut self, label: &'v Label) { walk_label(self, label) } - fn visit_generic_arg(&mut self, generic_arg: &'v GenericArg) { + fn visit_generic_arg(&mut self, generic_arg: &'v GenericArg<'v>) { match generic_arg { GenericArg::Lifetime(lt) => self.visit_lifetime(lt), GenericArg::Type(ty) => self.visit_ty(ty), @@ -354,26 +354,26 @@ pub trait Visitor<'v>: Sized { fn visit_lifetime(&mut self, lifetime: &'v Lifetime) { walk_lifetime(self, lifetime) } - fn visit_qpath(&mut self, qpath: &'v QPath, id: HirId, span: Span) { + fn visit_qpath(&mut self, qpath: &'v QPath<'v>, id: HirId, span: Span) { walk_qpath(self, qpath, id, span) } - fn visit_path(&mut self, path: &'v Path, _id: HirId) { + fn visit_path(&mut self, path: &'v Path<'v>, _id: HirId) { walk_path(self, path) } - fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment) { + fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment<'v>) { walk_path_segment(self, path_span, path_segment) } - fn visit_generic_args(&mut self, path_span: Span, generic_args: &'v GenericArgs) { + fn visit_generic_args(&mut self, path_span: Span, generic_args: &'v GenericArgs<'v>) { walk_generic_args(self, path_span, generic_args) } - fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding) { + fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding<'v>) { walk_assoc_type_binding(self, type_binding) } fn visit_attribute(&mut self, _attr: &'v Attribute) {} fn visit_macro_def(&mut self, macro_def: &'v MacroDef<'v>) { walk_macro_def(self, macro_def) } - fn visit_vis(&mut self, vis: &'v Visibility) { + fn visit_vis(&mut self, vis: &'v Visibility<'v>) { walk_vis(self, vis) } fn visit_associated_item_kind(&mut self, kind: &'v AssocItemKind) { @@ -445,7 +445,7 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime pub fn walk_poly_trait_ref<'v, V>( visitor: &mut V, - trait_ref: &'v PolyTraitRef, + trait_ref: &'v PolyTraitRef<'v>, _modifier: TraitBoundModifier, ) where V: Visitor<'v>, @@ -454,7 +454,7 @@ pub fn walk_poly_trait_ref<'v, V>( visitor.visit_trait_ref(&trait_ref.trait_ref); } -pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef) +pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef<'v>) where V: Visitor<'v>, { @@ -553,7 +553,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) { walk_list!(visitor, visit_attribute, item.attrs); } -pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path, hir_id: HirId) { +pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: HirId) { visitor.visit_id(hir_id); visitor.visit_path(path, hir_id); } @@ -561,7 +561,7 @@ pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path, hir_id: Hir pub fn walk_enum_def<'v, V: Visitor<'v>>( visitor: &mut V, enum_definition: &'v EnumDef<'v>, - generics: &'v Generics, + generics: &'v Generics<'v>, item_id: HirId, ) { visitor.visit_id(item_id); @@ -571,7 +571,7 @@ pub fn walk_enum_def<'v, V: Visitor<'v>>( pub fn walk_variant<'v, V: Visitor<'v>>( visitor: &mut V, variant: &'v Variant<'v>, - generics: &'v Generics, + generics: &'v Generics<'v>, parent_item_id: HirId, ) { visitor.visit_ident(variant.ident); @@ -587,7 +587,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>( walk_list!(visitor, visit_attribute, variant.attrs); } -pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { +pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty<'v>) { visitor.visit_id(typ.hir_id); match typ.kind { @@ -627,7 +627,12 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { } } -pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: HirId, span: Span) { +pub fn walk_qpath<'v, V: Visitor<'v>>( + visitor: &mut V, + qpath: &'v QPath<'v>, + id: HirId, + span: Span, +) { match *qpath { QPath::Resolved(ref maybe_qself, ref path) => { if let Some(ref qself) = *maybe_qself { @@ -642,7 +647,7 @@ pub fn walk_qpath<'v, V: Visitor<'v>>(visitor: &mut V, qpath: &'v QPath, id: Hir } } -pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) { +pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>) { for segment in &path.segments { visitor.visit_path_segment(path.span, segment); } @@ -651,7 +656,7 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) { pub fn walk_path_segment<'v, V: Visitor<'v>>( visitor: &mut V, path_span: Span, - segment: &'v PathSegment, + segment: &'v PathSegment<'v>, ) { visitor.visit_ident(segment.ident); if let Some(id) = segment.hir_id { @@ -665,13 +670,16 @@ pub fn walk_path_segment<'v, V: Visitor<'v>>( pub fn walk_generic_args<'v, V: Visitor<'v>>( visitor: &mut V, _path_span: Span, - generic_args: &'v GenericArgs, + generic_args: &'v GenericArgs<'v>, ) { walk_list!(visitor, visit_generic_arg, &generic_args.args); walk_list!(visitor, visit_assoc_type_binding, &generic_args.bindings); } -pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding: &'v TypeBinding) { +pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>( + visitor: &mut V, + type_binding: &'v TypeBinding<'v>, +) { visitor.visit_id(type_binding.hir_id); visitor.visit_ident(type_binding.ident); match type_binding.kind { @@ -747,7 +755,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v walk_list!(visitor, visit_attribute, foreign_item.attrs); } -pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound) { +pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericBound<'v>) { match *bound { GenericBound::Trait(ref typ, modifier) => { visitor.visit_poly_trait_ref(typ, modifier); @@ -756,7 +764,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v GenericB } } -pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam) { +pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v GenericParam<'v>) { visitor.visit_id(param.hir_id); walk_list!(visitor, visit_attribute, ¶m.attrs); match param.name { @@ -771,12 +779,15 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi walk_list!(visitor, visit_param_bound, ¶m.bounds); } -pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) { +pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics<'v>) { walk_list!(visitor, visit_generic_param, &generics.params); walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates); } -pub fn walk_where_predicate<'v, V: Visitor<'v>>(visitor: &mut V, predicate: &'v WherePredicate) { +pub fn walk_where_predicate<'v, V: Visitor<'v>>( + visitor: &mut V, + predicate: &'v WherePredicate<'v>, +) { match predicate { &WherePredicate::BoundPredicate(WhereBoundPredicate { ref bounded_ty, @@ -804,13 +815,13 @@ pub fn walk_where_predicate<'v, V: Visitor<'v>>(visitor: &mut V, predicate: &'v } } -pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy) { +pub fn walk_fn_ret_ty<'v, V: Visitor<'v>>(visitor: &mut V, ret_ty: &'v FunctionRetTy<'v>) { if let Return(ref output_ty) = *ret_ty { visitor.visit_ty(output_ty) } } -pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl) { +pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl<'v>) { for ty in &function_declaration.inputs { visitor.visit_ty(ty) } @@ -829,7 +840,7 @@ pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V, function_kind: FnKind<' pub fn walk_fn<'v, V: Visitor<'v>>( visitor: &mut V, function_kind: FnKind<'v>, - function_declaration: &'v FnDecl, + function_declaration: &'v FnDecl<'v>, body_id: BodyId, _span: Span, id: HirId, @@ -927,7 +938,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt } } -pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) { +pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef<'v>) { // N.B., deliberately force a compilation error if/when new fields are added. let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref; visitor.visit_nested_impl_item(id); @@ -1099,7 +1110,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm<'v>) { walk_list!(visitor, visit_attribute, arm.attrs); } -pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) { +pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility<'v>) { if let VisibilityKind::Restricted { ref path, hir_id } = vis.node { visitor.visit_id(hir_id); visitor.visit_path(path, hir_id) diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index ed84bd118f7..e58485fe318 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -212,7 +212,7 @@ enum ImplTraitContext<'a> { /// equivalent to a fresh universal parameter like `fn foo<T: Debug>(x: T)`. /// /// Newly generated parameters should be inserted into the given `Vec`. - Universal(&'a mut Vec<hir::GenericParam>), + Universal(&'a mut Vec<hir::GenericParam<'a>>), /// Treat `impl Trait` as shorthand for a new opaque type. /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually @@ -739,9 +739,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { parent_id: DefId, anonymous_lifetime_mode: AnonymousLifetimeMode, f: F, - ) -> (Vec<hir::GenericParam>, T) + ) -> (Vec<hir::GenericParam<'hir>>, T) where - F: FnOnce(&mut LoweringContext<'_, '_>) -> (Vec<hir::GenericParam>, T), + F: FnOnce(&mut LoweringContext<'_, '_>) -> (Vec<hir::GenericParam<'hir>>, T), { assert!(!self.is_collecting_in_band_lifetimes); assert!(self.lifetimes_to_define.is_empty()); @@ -772,7 +772,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { span: Span, hir_name: ParamName, parent_index: DefIndex, - ) -> hir::GenericParam { + ) -> hir::GenericParam<'hir> { let node_id = self.resolver.next_node_id(); // Get the name we'll use to make the def-path. Note @@ -874,9 +874,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { parent_id: DefId, anonymous_lifetime_mode: AnonymousLifetimeMode, f: F, - ) -> (hir::Generics, T) + ) -> (hir::Generics<'hir>, T) where - F: FnOnce(&mut LoweringContext<'_, '_>, &mut Vec<hir::GenericParam>) -> T, + F: FnOnce(&mut LoweringContext<'_, '_>, &mut Vec<hir::GenericParam<'hir>>) -> T, { let (in_band_defs, (mut lowered_generics, res)) = self.with_in_scope_lifetime_defs(&generics.params, |this| { @@ -1026,7 +1026,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, constraint: &AssocTyConstraint, itctx: ImplTraitContext<'_>, - ) -> hir::TypeBinding { + ) -> hir::TypeBinding<'hir> { debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx); let kind = match constraint.kind { @@ -1123,7 +1123,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, arg: &ast::GenericArg, itctx: ImplTraitContext<'_>, - ) -> hir::GenericArg { + ) -> hir::GenericArg<'hir> { match arg { ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)), ast::GenericArg::Type(ty) => { @@ -1178,7 +1178,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext<'_>) -> P<hir::Ty> { + fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext<'_>) -> P<hir::Ty<'hir>> { P(self.lower_ty_direct(t, itctx)) } @@ -1189,7 +1189,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { path: &Path, param_mode: ParamMode, itctx: ImplTraitContext<'_>, - ) -> hir::Ty { + ) -> hir::Ty<'hir> { let id = self.lower_node_id(t.id); let qpath = self.lower_qpath(t.id, qself, path, param_mode, itctx); let ty = self.ty_path(id, t.span, qpath); @@ -1199,15 +1199,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ty } - fn ty(&mut self, span: Span, kind: hir::TyKind) -> hir::Ty { + fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> { hir::Ty { hir_id: self.next_id(), kind, span } } - fn ty_tup(&mut self, span: Span, tys: HirVec<hir::Ty>) -> hir::Ty { + fn ty_tup(&mut self, span: Span, tys: HirVec<hir::Ty<'hir>>) -> hir::Ty<'hir> { self.ty(span, hir::TyKind::Tup(tys)) } - fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty { + fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty<'hir> { let kind = match t.kind { TyKind::Infer => hir::TyKind::Infer, TyKind::Err => hir::TyKind::Err, @@ -1376,8 +1376,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { span: Span, fn_def_id: Option<DefId>, opaque_ty_node_id: NodeId, - lower_bounds: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::GenericBounds, - ) -> hir::TyKind { + lower_bounds: impl FnOnce(&mut LoweringContext<'_, '_>) -> hir::GenericBounds<'hir>, + ) -> hir::TyKind<'hir> { debug!( "lower_opaque_impl_trait(fn_def_id={:?}, opaque_ty_node_id={:?}, span={:?})", fn_def_id, opaque_ty_node_id, span, @@ -1433,7 +1433,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn generate_opaque_type( &mut self, opaque_ty_node_id: NodeId, - opaque_ty_item: hir::OpaqueTy, + opaque_ty_item: hir::OpaqueTy<'hir>, span: Span, opaque_ty_span: Span, ) -> hir::HirId { @@ -1461,8 +1461,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, opaque_ty_id: NodeId, parent_index: DefIndex, - bounds: &hir::GenericBounds, - ) -> (HirVec<hir::GenericArg>, HirVec<hir::GenericParam>) { + bounds: &hir::GenericBounds<'hir>, + ) -> (HirVec<hir::GenericArg<'hir>>, HirVec<hir::GenericParam<'hir>>) { debug!( "lifetimes_from_impl_trait_bounds(opaque_ty_id={:?}, \ parent_index={:?}, \ @@ -1480,8 +1480,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { collect_elided_lifetimes: bool, currently_bound_lifetimes: Vec<hir::LifetimeName>, already_defined_lifetimes: FxHashSet<hir::LifetimeName>, - output_lifetimes: Vec<hir::GenericArg>, - output_lifetime_params: Vec<hir::GenericParam>, + output_lifetimes: Vec<hir::GenericArg<'hir>>, + output_lifetime_params: Vec<hir::GenericParam<'hir>>, } impl<'r, 'a, 'v, 'hir> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a, 'hir> { @@ -1491,7 +1491,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::intravisit::NestedVisitorMap::None } - fn visit_generic_args(&mut self, span: Span, parameters: &'v hir::GenericArgs) { + fn visit_generic_args(&mut self, span: Span, parameters: &'v hir::GenericArgs<'v>) { // Don't collect elided lifetimes used inside of `Fn()` syntax. if parameters.parenthesized { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; @@ -1503,7 +1503,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - fn visit_ty(&mut self, t: &'v hir::Ty) { + fn visit_ty(&mut self, t: &'v hir::Ty<'v>) { // Don't collect elided lifetimes used inside of `fn()` syntax. if let hir::TyKind::BareFn(_) = t.kind { let old_collect_elided_lifetimes = self.collect_elided_lifetimes; @@ -1523,7 +1523,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn visit_poly_trait_ref( &mut self, - trait_ref: &'v hir::PolyTraitRef, + trait_ref: &'v hir::PolyTraitRef<'v>, modifier: hir::TraitBoundModifier, ) { // Record the "stack height" of `for<'a>` lifetime bindings @@ -1533,7 +1533,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { self.currently_bound_lifetimes.truncate(old_len); } - fn visit_generic_param(&mut self, param: &'v hir::GenericParam) { + fn visit_generic_param(&mut self, param: &'v hir::GenericParam<'v>) { // Record the introduction of 'a in `for<'a> ...`. if let hir::GenericParamKind::Lifetime { .. } = param.kind { // Introduce lifetimes one at a time so that we can handle @@ -1639,7 +1639,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { p: &Path, param_mode: ParamMode, mut itctx: ImplTraitContext<'_>, - ) -> hir::QPath { + ) -> hir::QPath<'hir> { let qself_position = qself.as_ref().map(|q| q.position); let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx.reborrow())); @@ -1799,7 +1799,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { p: &Path, param_mode: ParamMode, explicit_owner: Option<NodeId>, - ) -> hir::Path { + ) -> hir::Path<'hir> { hir::Path { res, segments: p @@ -1821,7 +1821,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - fn lower_path(&mut self, id: NodeId, p: &Path, param_mode: ParamMode) -> hir::Path { + fn lower_path(&mut self, id: NodeId, p: &Path, param_mode: ParamMode) -> hir::Path<'hir> { let res = self.expect_full_res(id); let res = self.lower_res(res); self.lower_path_extra(res, p, param_mode, None) @@ -1836,7 +1836,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { parenthesized_generic_args: ParenthesizedGenericArgs, itctx: ImplTraitContext<'_>, explicit_owner: Option<NodeId>, - ) -> hir::PathSegment { + ) -> hir::PathSegment<'hir> { let (mut generic_args, infer_args) = if let Some(ref generic_args) = segment.args { let msg = "parenthesized type parameters may only be used with a `Fn` trait"; match **generic_args { @@ -1981,7 +1981,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { data: &AngleBracketedArgs, param_mode: ParamMode, mut itctx: ImplTraitContext<'_>, - ) -> (hir::GenericArgs, bool) { + ) -> (hir::GenericArgs<'hir>, bool) { let &AngleBracketedArgs { ref args, ref constraints, .. } = data; let has_non_lt_args = args.iter().any(|arg| match arg { ast::GenericArg::Lifetime(_) => false, @@ -2004,7 +2004,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_parenthesized_parameter_data( &mut self, data: &ParenthesizedArgs, - ) -> (hir::GenericArgs, bool) { + ) -> (hir::GenericArgs<'hir>, bool) { // Switch to `PassThrough` mode for anonymous lifetimes; this // means that we permit things like `&Ref<T>`, where `Ref` has // a hidden lifetime parameter. This is needed for backwards @@ -2098,10 +2098,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_fn_decl( &mut self, decl: &FnDecl, - mut in_band_ty_params: Option<(DefId, &mut Vec<hir::GenericParam>)>, + mut in_band_ty_params: Option<(DefId, &mut Vec<hir::GenericParam<'hir>>)>, impl_trait_return_allow: bool, make_ret_async: Option<NodeId>, - ) -> P<hir::FnDecl> { + ) -> P<hir::FnDecl<'hir>> { debug!( "lower_fn_decl(\ fn_decl: {:?}, \ @@ -2207,7 +2207,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { output: &FunctionRetTy, fn_def_id: DefId, opaque_ty_node_id: NodeId, - ) -> hir::FunctionRetTy { + ) -> hir::FunctionRetTy<'hir> { debug!( "lower_async_fn_ret_ty(\ output={:?}, \ @@ -2384,7 +2384,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { output: &FunctionRetTy, fn_def_id: DefId, span: Span, - ) -> hir::GenericBound { + ) -> hir::GenericBound<'hir> { // Compute the `T` in `Future<Output = T>` from the return type. let output_ty = match output { FunctionRetTy::Ty(ty) => self.lower_ty(ty, ImplTraitContext::OpaqueTy(Some(fn_def_id))), @@ -2421,7 +2421,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, tpb: &GenericBound, itctx: ImplTraitContext<'_>, - ) -> hir::GenericBound { + ) -> hir::GenericBound<'hir> { match *tpb { GenericBound::Trait(ref ty, modifier) => hir::GenericBound::Trait( self.lower_poly_trait_ref(ty, itctx), @@ -2473,7 +2473,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { params: &[GenericParam], add_bounds: &NodeMap<Vec<GenericBound>>, mut itctx: ImplTraitContext<'_>, - ) -> hir::HirVec<hir::GenericParam> { + ) -> hir::HirVec<hir::GenericParam<'hir>> { params .iter() .map(|param| self.lower_generic_param(param, add_bounds, itctx.reborrow())) @@ -2485,7 +2485,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { param: &GenericParam, add_bounds: &NodeMap<Vec<GenericBound>>, mut itctx: ImplTraitContext<'_>, - ) -> hir::GenericParam { + ) -> hir::GenericParam<'hir> { let mut bounds = self .with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| { this.lower_param_bounds(¶m.bounds, itctx.reborrow()) @@ -2561,7 +2561,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext<'_>) -> hir::TraitRef { + fn lower_trait_ref( + &mut self, + p: &TraitRef, + itctx: ImplTraitContext<'_>, + ) -> hir::TraitRef<'hir> { let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) { hir::QPath::Resolved(None, path) => path, qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath), @@ -2573,7 +2577,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, p: &PolyTraitRef, mut itctx: ImplTraitContext<'_>, - ) -> hir::PolyTraitRef { + ) -> hir::PolyTraitRef<'hir> { let bound_generic_params = self.lower_generic_params( &p.bound_generic_params, &NodeMap::default(), @@ -2586,7 +2590,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::PolyTraitRef { bound_generic_params, trait_ref, span: p.span } } - fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext<'_>) -> hir::MutTy { + fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext<'_>) -> hir::MutTy<'hir> { hir::MutTy { ty: self.lower_ty(&mt.ty, itctx), mutbl: mt.mutbl } } @@ -2594,7 +2598,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, bounds: &[GenericBound], mut itctx: ImplTraitContext<'_>, - ) -> hir::GenericBounds { + ) -> hir::GenericBounds<'hir> { bounds.iter().map(|bound| self.lower_param_bound(bound, itctx.reborrow())).collect() } @@ -3077,9 +3081,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, span: Span, components: &[Symbol], - params: Option<P<hir::GenericArgs>>, + params: Option<P<hir::GenericArgs<'hir>>>, is_value: bool, - ) -> hir::Path { + ) -> hir::Path<'hir> { let ns = if is_value { Namespace::ValueNS } else { Namespace::TypeNS }; let (path, res) = self.resolver.resolve_str_path(span, self.crate_root, components, ns); @@ -3106,7 +3110,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - fn ty_path(&mut self, mut hir_id: hir::HirId, span: Span, qpath: hir::QPath) -> hir::Ty { + fn ty_path( + &mut self, + mut hir_id: hir::HirId, + span: Span, + qpath: hir::QPath<'hir>, + ) -> hir::Ty<'hir> { let kind = match qpath { hir::QPath::Resolved(None, path) => { // Turn trait object paths into `TyKind::TraitObject` instead. diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index 8a9614c6cb2..a5871e02dd0 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -1338,7 +1338,7 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, span: Span, components: &[Symbol], - params: Option<P<hir::GenericArgs>>, + params: Option<P<hir::GenericArgs<'hir>>>, attrs: AttrVec, ) -> hir::Expr<'hir> { let path = self.std_path(span, components, params, true); diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index c82de81e737..d4705e9795c 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -258,7 +258,7 @@ impl<'hir> LoweringContext<'_, 'hir> { id: NodeId, ident: &mut Ident, attrs: &'hir [Attribute], - vis: &mut hir::Visibility, + vis: &mut hir::Visibility<'hir>, i: &ItemKind, ) -> hir::ItemKind<'hir> { match *i { @@ -466,7 +466,7 @@ impl<'hir> LoweringContext<'_, 'hir> { tree: &UseTree, prefix: &Path, id: NodeId, - vis: &mut hir::Visibility, + vis: &mut hir::Visibility<'hir>, ident: &mut Ident, attrs: &'hir [Attribute], ) -> hir::ItemKind<'hir> { @@ -635,7 +635,7 @@ impl<'hir> LoweringContext<'_, 'hir> { /// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated /// many times in the HIR tree; for each occurrence, we need to assign distinct /// `NodeId`s. (See, e.g., #56128.) - fn rebuild_use_path(&mut self, path: &hir::Path) -> hir::Path { + fn rebuild_use_path(&mut self, path: &hir::Path<'hir>) -> hir::Path<'hir> { debug!("rebuild_use_path(path = {:?})", path); let segments = path .segments @@ -651,7 +651,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::Path { span: path.span, res: path.res, segments } } - fn rebuild_vis(&mut self, vis: &hir::Visibility) -> hir::Visibility { + fn rebuild_vis(&mut self, vis: &hir::Visibility<'hir>) -> hir::Visibility<'hir> { let vis_kind = match vis.node { hir::VisibilityKind::Public => hir::VisibilityKind::Public, hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), @@ -918,7 +918,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // [1] since `default impl` is not yet implemented, this is always true in impls } - fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef { + fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef<'hir> { hir::ImplItemRef { id: hir::ImplItemId { hir_id: self.lower_node_id(i.id) }, ident: i.ident, @@ -952,7 +952,7 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, v: &Visibility, explicit_owner: Option<NodeId>, - ) -> hir::Visibility { + ) -> hir::Visibility<'hir> { let node = match v.node { VisibilityKind::Public => hir::VisibilityKind::Public, VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), @@ -1255,7 +1255,7 @@ impl<'hir> LoweringContext<'_, 'hir> { fn_def_id: DefId, impl_trait_return_allow: bool, is_async: Option<NodeId>, - ) -> (hir::Generics, hir::FnSig<'hir>) { + ) -> (hir::Generics<'hir>, hir::FnSig<'hir>) { let header = self.lower_fn_header(sig.header); let (generics, decl) = self.add_in_band_defs( generics, @@ -1316,7 +1316,7 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, generics: &Generics, itctx: ImplTraitContext<'_>, - ) -> hir::Generics { + ) -> hir::Generics<'hir> { // Collect `?Trait` bounds in where clause and move them to parameter definitions. // FIXME: this could probably be done with less rightward drift. It also looks like two // control paths where `report_error` is called are the only paths that advance to after the @@ -1379,7 +1379,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - fn lower_where_clause(&mut self, wc: &WhereClause) -> hir::WhereClause { + fn lower_where_clause(&mut self, wc: &WhereClause) -> hir::WhereClause<'hir> { self.with_anonymous_lifetime_mode(AnonymousLifetimeMode::ReportError, |this| { hir::WhereClause { predicates: wc @@ -1392,7 +1392,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }) } - fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicate { + fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicate<'hir> { match *pred { WherePredicate::BoundPredicate(WhereBoundPredicate { ref bound_generic_params, diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index 6d8fd9d2f01..1267de4d978 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -109,10 +109,10 @@ impl<'a> Code<'a> { /// use when implementing FnLikeNode operations. struct ItemFnParts<'a> { ident: Ident, - decl: &'a ast::FnDecl, + decl: &'a ast::FnDecl<'a>, header: ast::FnHeader, - vis: &'a ast::Visibility, - generics: &'a ast::Generics, + vis: &'a ast::Visibility<'a>, + generics: &'a ast::Generics<'a>, body: ast::BodyId, id: ast::HirId, span: Span, @@ -122,7 +122,7 @@ struct ItemFnParts<'a> { /// These are all the components one can extract from a closure expr /// for use when implementing FnLikeNode operations. struct ClosureParts<'a> { - decl: &'a FnDecl, + decl: &'a FnDecl<'a>, body: ast::BodyId, id: ast::HirId, span: Span, @@ -130,7 +130,13 @@ struct ClosureParts<'a> { } impl<'a> ClosureParts<'a> { - fn new(d: &'a FnDecl, b: ast::BodyId, id: ast::HirId, s: Span, attrs: &'a [Attribute]) -> Self { + fn new( + d: &'a FnDecl<'a>, + b: ast::BodyId, + id: ast::HirId, + s: Span, + attrs: &'a [Attribute], + ) -> Self { ClosureParts { decl: d, body: b, id, span: s, attrs } } } @@ -156,7 +162,7 @@ impl<'a> FnLikeNode<'a> { ) } - pub fn decl(self) -> &'a FnDecl { + pub fn decl(self) -> &'a FnDecl<'a> { self.handle( |i: ItemFnParts<'a>| &*i.decl, |_, _, sig: &'a ast::FnSig<'a>, _, _, _, _| &sig.decl, @@ -210,7 +216,7 @@ impl<'a> FnLikeNode<'a> { ast::HirId, Ident, &'a ast::FnSig<'a>, - Option<&'a ast::Visibility>, + Option<&'a ast::Visibility<'a>>, ast::BodyId, Span, &'a [Attribute], diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 610be0a0753..28eff07a494 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -401,7 +401,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } - fn visit_generic_param(&mut self, param: &'hir GenericParam) { + fn visit_generic_param(&mut self, param: &'hir GenericParam<'hir>) { self.insert(param.span, param.hir_id, Node::GenericParam(param)); intravisit::walk_generic_param(self, param); } @@ -478,14 +478,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } - fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) { + fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment<'hir>) { if let Some(hir_id) = path_segment.hir_id { self.insert(path_span, hir_id, Node::PathSegment(path_segment)); } intravisit::walk_path_segment(self, path_span, path_segment); } - fn visit_ty(&mut self, ty: &'hir Ty) { + fn visit_ty(&mut self, ty: &'hir Ty<'hir>) { self.insert(ty.span, ty.hir_id, Node::Ty(ty)); self.with_parent(ty.hir_id, |this| { @@ -493,7 +493,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } - fn visit_trait_ref(&mut self, tr: &'hir TraitRef) { + fn visit_trait_ref(&mut self, tr: &'hir TraitRef<'hir>) { self.insert(tr.path.span, tr.hir_ref_id, Node::TraitRef(tr)); self.with_parent(tr.hir_ref_id, |this| { @@ -504,7 +504,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { fn visit_fn( &mut self, fk: intravisit::FnKind<'hir>, - fd: &'hir FnDecl, + fd: &'hir FnDecl<'hir>, b: BodyId, s: Span, id: HirId, @@ -529,7 +529,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { self.insert(lifetime.span, lifetime.hir_id, Node::Lifetime(lifetime)); } - fn visit_vis(&mut self, visibility: &'hir Visibility) { + fn visit_vis(&mut self, visibility: &'hir Visibility<'hir>) { match visibility.node { VisibilityKind::Public | VisibilityKind::Crate(_) | VisibilityKind::Inherited => {} VisibilityKind::Restricted { hir_id, .. } => { @@ -550,7 +550,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { }); } - fn visit_variant(&mut self, v: &'hir Variant<'hir>, g: &'hir Generics, item_id: HirId) { + fn visit_variant(&mut self, v: &'hir Variant<'hir>, g: &'hir Generics<'hir>, item_id: HirId) { self.insert(v.span, v.id, Node::Variant(v)); self.with_parent(v.id, |this| { // Register the constructor of this variant. @@ -576,7 +576,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { self.visit_nested_trait_item(id); } - fn visit_impl_item_ref(&mut self, ii: &'hir ImplItemRef) { + fn visit_impl_item_ref(&mut self, ii: &'hir ImplItemRef<'hir>) { // Do not visit the duplicate information in ImplItemRef. We want to // map the actual nodes, not the duplicate ones in the *Ref. let ImplItemRef { id, ident: _, kind: _, span: _, vis: _, defaultness: _ } = *ii; diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 4c250aba96d..a04fc8a562f 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -161,7 +161,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { self.hir_ids_seen.insert(hir_id.local_id); } - fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) { + fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef<'hir>) { // Explicitly do nothing here. ImplItemRefs contain hir::Visibility // values that actually belong to an ImplItem instead of the ItemKind::Impl // we are currently in. So for those it's correct that they have a diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index d933f1e49e4..7f7af331b3c 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -43,7 +43,7 @@ impl<'hir> Entry<'hir> { } } - fn fn_decl(&self) -> Option<&'hir FnDecl> { + fn fn_decl(&self) -> Option<&'hir FnDecl<'hir>> { match self.node { Node::Item(ref item) => match item.kind { ItemKind::Fn(ref sig, _, _) => Some(&sig.decl), @@ -429,7 +429,7 @@ impl<'hir> Map<'hir> { self.forest.krate.body(id) } - pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl> { + pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> { if let Some(entry) = self.find_entry(hir_id) { entry.fn_decl() } else { @@ -584,7 +584,7 @@ impl<'hir> Map<'hir> { self.as_local_hir_id(id).map(|id| self.get(id)) // read recorded by `get` } - pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> { + pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics<'hir>> { self.get_if_local(id).and_then(|node| match node { Node::ImplItem(ref impl_item) => Some(&impl_item.generics), Node::TraitItem(ref trait_item) => Some(&trait_item.generics), diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 84d8fb32e2d..3c6513a137f 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -303,27 +303,27 @@ impl Lifetime { /// `std::cmp::PartialEq`. It's represented as a sequence of identifiers, /// along with a bunch of supporting information. #[derive(RustcEncodable, RustcDecodable, HashStable)] -pub struct Path { +pub struct Path<'hir> { pub span: Span, /// The resolution for the path. pub res: Res, /// The segments in the path: the things separated by `::`. - pub segments: HirVec<PathSegment>, + pub segments: &'hir [PathSegment<'hir>], } -impl Path { +impl Path<'_> { pub fn is_global(&self) -> bool { !self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot } } -impl fmt::Debug for Path { +impl fmt::Debug for Path<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "path({})", self) } } -impl fmt::Display for Path { +impl fmt::Display for Path<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", print::to_string(print::NO_ANN, |s| s.print_path(self, false))) } @@ -332,7 +332,7 @@ impl fmt::Display for Path { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct PathSegment { +pub struct PathSegment<'hir> { /// The identifier portion of this path segment. #[stable_hasher(project(name))] pub ident: Ident, @@ -349,7 +349,7 @@ pub struct PathSegment { /// this is more than just simple syntactic sugar; the use of /// parens affects the region binding rules, so we preserve the /// distinction. - pub args: Option<P<GenericArgs>>, + pub args: Option<&'hir GenericArgs<'hir>>, /// Whether to infer remaining type parameters, if any. /// This only applies to expression and pattern paths, and @@ -358,9 +358,9 @@ pub struct PathSegment { pub infer_args: bool, } -impl PathSegment { +impl<'hir> PathSegment<'hir> { /// Converts an identifier to the corresponding segment. - pub fn from_ident(ident: Ident) -> PathSegment { + pub fn from_ident(ident: Ident) -> PathSegment<'hir> { PathSegment { ident, hir_id: None, res: None, infer_args: true, args: None } } @@ -368,7 +368,7 @@ impl PathSegment { ident: Ident, hir_id: Option<HirId>, res: Option<Res>, - args: GenericArgs, + args: GenericArgs<'_>, infer_args: bool, ) -> Self { PathSegment { @@ -380,11 +380,11 @@ impl PathSegment { } } - pub fn generic_args(&self) -> &GenericArgs { + pub fn generic_args(&self) -> &GenericArgs<'hir> { if let Some(ref args) = self.args { args } else { - const DUMMY: &GenericArgs = &GenericArgs::none(); + const DUMMY: &GenericArgs<'_> = &GenericArgs::none(); DUMMY } } @@ -397,13 +397,13 @@ pub struct ConstArg { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum GenericArg { +pub enum GenericArg<'hir> { Lifetime(Lifetime), - Type(Ty), + Type(Ty<'hir>), Const(ConstArg), } -impl GenericArg { +impl GenericArg<'_> { pub fn span(&self) -> Span { match self { GenericArg::Lifetime(l) => l.span, @@ -429,19 +429,19 @@ impl GenericArg { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct GenericArgs { +pub struct GenericArgs<'hir> { /// The generic arguments for this path segment. - pub args: HirVec<GenericArg>, + pub args: HirVec<GenericArg<'hir>>, /// Bindings (equality constraints) on associated types, if present. /// E.g., `Foo<A = Bar>`. - pub bindings: HirVec<TypeBinding>, + pub bindings: &'hir [TypeBinding<'hir>], /// Were arguments written in parenthesized form `Fn(T) -> U`? /// This is required mostly for pretty-printing and diagnostics, /// but also for changing lifetime elision rules to be "function-like". pub parenthesized: bool, } -impl GenericArgs { +impl GenericArgs<'_> { pub const fn none() -> Self { Self { args: HirVec::new(), bindings: HirVec::new(), parenthesized: false } } @@ -450,7 +450,7 @@ impl GenericArgs { self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized } - pub fn inputs(&self) -> &[Ty] { + pub fn inputs(&self) -> &[Ty<'_>] { if self.parenthesized { for arg in &self.args { match arg { @@ -499,12 +499,12 @@ pub enum TraitBoundModifier { /// the "special" built-in traits (see `middle::lang_items`) and /// detects `Copy`, `Send` and `Sync`. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum GenericBound { - Trait(PolyTraitRef, TraitBoundModifier), +pub enum GenericBound<'hir> { + Trait(PolyTraitRef<'hir>, TraitBoundModifier), Outlives(Lifetime), } -impl GenericBound { +impl GenericBound<'_> { pub fn span(&self) -> Span { match self { &GenericBound::Trait(ref t, ..) => t.span, @@ -513,7 +513,7 @@ impl GenericBound { } } -pub type GenericBounds = HirVec<GenericBound>; +pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>]; #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum LifetimeParamKind { @@ -535,29 +535,29 @@ pub enum LifetimeParamKind { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum GenericParamKind { +pub enum GenericParamKind<'hir> { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime { kind: LifetimeParamKind, }, Type { - default: Option<P<Ty>>, + default: Option<&'hir Ty<'hir>>, synthetic: Option<SyntheticTyParamKind>, }, Const { - ty: P<Ty>, + ty: &'hir Ty<'hir>, }, } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct GenericParam { +pub struct GenericParam<'hir> { pub hir_id: HirId, pub name: ParamName, - pub attrs: HirVec<Attribute>, - pub bounds: GenericBounds, + pub attrs: &'hir [Attribute], + pub bounds: GenericBounds<'hir>, pub span: Span, pub pure_wrt_drop: bool, - pub kind: GenericParamKind, + pub kind: GenericParamKind<'hir>, } #[derive(Default)] @@ -570,14 +570,14 @@ pub struct GenericParamCount { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct Generics { - pub params: HirVec<GenericParam>, - pub where_clause: WhereClause, +pub struct Generics<'hir> { + pub params: HirVec<GenericParam<'hir>>, + pub where_clause: WhereClause<'hir>, pub span: Span, } -impl Generics { - pub const fn empty() -> Generics { +impl Generics<'hir> { + pub const fn empty() -> Generics<'hir> { Generics { params: HirVec::new(), where_clause: WhereClause { predicates: HirVec::new(), span: DUMMY_SP }, @@ -602,7 +602,7 @@ impl Generics { own_counts } - pub fn get_named(&self, name: Symbol) -> Option<&GenericParam> { + pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'_>> { for param in &self.params { if name == param.name.ident().name { return Some(param); @@ -629,13 +629,13 @@ pub enum SyntheticTyParamKind { /// A where-clause in a definition. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct WhereClause { - pub predicates: HirVec<WherePredicate>, +pub struct WhereClause<'hir> { + pub predicates: &'hir [WherePredicate<'hir>], // Only valid if predicates isn't empty. span: Span, } -impl WhereClause { +impl WhereClause<'_> { pub fn span(&self) -> Option<Span> { if self.predicates.is_empty() { None } else { Some(self.span) } } @@ -649,16 +649,16 @@ impl WhereClause { /// A single predicate in a where-clause. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum WherePredicate { +pub enum WherePredicate<'hir> { /// A type binding (e.g., `for<'c> Foo: Send + Clone + 'c`). - BoundPredicate(WhereBoundPredicate), + BoundPredicate(WhereBoundPredicate<'hir>), /// A lifetime predicate (e.g., `'a: 'b + 'c`). - RegionPredicate(WhereRegionPredicate), + RegionPredicate(WhereRegionPredicate<'hir>), /// An equality predicate (unsupported). - EqPredicate(WhereEqPredicate), + EqPredicate(WhereEqPredicate<'hir>), } -impl WherePredicate { +impl WherePredicate<'_> { pub fn span(&self) -> Span { match self { &WherePredicate::BoundPredicate(ref p) => p.span, @@ -670,31 +670,31 @@ impl WherePredicate { /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct WhereBoundPredicate { +pub struct WhereBoundPredicate<'hir> { pub span: Span, /// Any generics from a `for` binding. - pub bound_generic_params: HirVec<GenericParam>, + pub bound_generic_params: &'hir [GenericParam<'hir>], /// The type being bounded. - pub bounded_ty: P<Ty>, + pub bounded_ty: &'hir Ty<'hir>, /// Trait and lifetime bounds (e.g., `Clone + Send + 'static`). - pub bounds: GenericBounds, + pub bounds: GenericBounds<'hir>, } /// A lifetime predicate (e.g., `'a: 'b + 'c`). #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct WhereRegionPredicate { +pub struct WhereRegionPredicate<'hir> { pub span: Span, pub lifetime: Lifetime, - pub bounds: GenericBounds, + pub bounds: GenericBounds<'hir>, } /// An equality predicate (e.g., `T = int`); currently unsupported. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct WhereEqPredicate { +pub struct WhereEqPredicate<'hir> { pub hir_id: HirId, pub span: Span, - pub lhs_ty: P<Ty>, - pub rhs_ty: P<Ty>, + pub lhs_ty: &'hir Ty<'hir>, + pub rhs_ty: &'hir Ty<'hir>, } #[derive(RustcEncodable, RustcDecodable, Debug)] @@ -820,7 +820,7 @@ impl Crate<'_> { #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct MacroDef<'hir> { pub name: Name, - pub vis: Visibility, + pub vis: Visibility<'hir>, pub attrs: &'hir [Attribute], pub hir_id: HirId, pub span: Span, @@ -1003,19 +1003,19 @@ pub enum PatKind<'hir> { /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). /// The `bool` is `true` in the presence of a `..`. - Struct(QPath, &'hir [FieldPat<'hir>], bool), + Struct(QPath<'hir>, &'hir [FieldPat<'hir>], bool), /// A tuple struct/variant pattern `Variant(x, y, .., z)`. /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position. /// `0 <= position <= subpats.len()` - TupleStruct(QPath, &'hir [&'hir Pat<'hir>], Option<usize>), + TupleStruct(QPath<'hir>, &'hir [&'hir Pat<'hir>], Option<usize>), /// An or-pattern `A | B | C`. /// Invariant: `pats.len() >= 2`. Or(&'hir [&'hir Pat<'hir>]), /// A path pattern for an unit struct/variant or a (maybe-associated) constant. - Path(QPath), + Path(QPath<'hir>), /// A tuple pattern (e.g., `(a, b)`). /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position. @@ -1258,7 +1258,7 @@ impl StmtKind<'hir> { pub struct Local<'hir> { pub pat: &'hir Pat<'hir>, /// Type annotation, if any (otherwise the type will be inferred). - pub ty: Option<&'hir Ty>, + pub ty: Option<&'hir Ty<'hir>>, /// Initializer expression to set the value, if any. pub init: Option<&'hir Expr<'hir>>, pub hir_id: HirId, @@ -1583,7 +1583,7 @@ pub fn is_range_literal(sm: &SourceMap, expr: &Expr<'_>) -> bool { // Returns whether the given path represents a (desugared) range, // either in std or core, i.e. has either a `::std::ops::Range` or // `::core::ops::Range` prefix. - fn is_range_path(path: &Path) -> bool { + fn is_range_path(path: &Path<'_>) -> bool { let segs: Vec<_> = path.segments.iter().map(|seg| seg.ident.to_string()).collect(); let segs: Vec<_> = segs.iter().map(|seg| &**seg).collect(); @@ -1663,7 +1663,7 @@ pub enum ExprKind<'hir> { /// the `hir_id` of the `MethodCall` node itself. /// /// [`type_dependent_def_id`]: ../ty/struct.TypeckTables.html#method.type_dependent_def_id - MethodCall(&'hir PathSegment, Span, &'hir [Expr<'hir>]), + MethodCall(&'hir PathSegment<'hir>, Span, &'hir [Expr<'hir>]), /// A tuple (e.g., `(a, b, c, d)`). Tup(&'hir [Expr<'hir>]), /// A binary operation (e.g., `a + b`, `a * b`). @@ -1673,9 +1673,9 @@ pub enum ExprKind<'hir> { /// A literal (e.g., `1`, `"foo"`). Lit(Lit), /// A cast (e.g., `foo as f64`). - Cast(&'hir Expr<'hir>, &'hir Ty), + Cast(&'hir Expr<'hir>, &'hir Ty<'hir>), /// A type reference (e.g., `Foo`). - Type(&'hir Expr<'hir>, &'hir Ty), + Type(&'hir Expr<'hir>, &'hir Ty<'hir>), /// Wraps the expression in a terminating scope. /// This makes it semantically equivalent to `{ let _t = expr; _t }`. /// @@ -1695,7 +1695,7 @@ pub enum ExprKind<'hir> { /// /// This may also be a generator literal or an `async block` as indicated by the /// `Option<Movability>`. - Closure(CaptureBy, &'hir FnDecl, BodyId, Span, Option<Movability>), + Closure(CaptureBy, &'hir FnDecl<'hir>, BodyId, Span, Option<Movability>), /// A block (e.g., `'label: { ... }`). Block(&'hir Block<'hir>, Option<Label>), @@ -1711,7 +1711,7 @@ pub enum ExprKind<'hir> { Index(&'hir Expr<'hir>, &'hir Expr<'hir>), /// Path to a definition, possibly containing lifetime or type parameters. - Path(QPath), + Path(QPath<'hir>), /// A referencing operation (i.e., `&a` or `&mut a`). AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>), @@ -1729,7 +1729,7 @@ pub enum ExprKind<'hir> { /// /// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. base}`, /// where `base` is the `Option<Expr>`. - Struct(&'hir QPath, &'hir [Field<'hir>], Option<&'hir Expr<'hir>>), + Struct(&'hir QPath<'hir>, &'hir [Field<'hir>], Option<&'hir Expr<'hir>>), /// An array literal constructed from one repeated element. /// @@ -1750,14 +1750,14 @@ pub enum ExprKind<'hir> { /// /// [`qpath_res`]: ../ty/struct.TypeckTables.html#method.qpath_res #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum QPath { +pub enum QPath<'hir> { /// Path to a definition, optionally "fully-qualified" with a `Self` /// type, if the path points to an associated item in a trait. /// /// E.g., an unqualified path like `Clone::clone` has `None` for `Self`, /// while `<Vec<T> as Clone>::clone` has `Some(Vec<T>)` for `Self`, /// even though they both have the same two-segment `Clone::clone` `Path`. - Resolved(Option<P<Ty>>, P<Path>), + Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>), /// Type-related paths (e.g., `<T>::default` or `<T>::Output`). /// Will be resolved by type-checking to an associated item. @@ -1765,7 +1765,7 @@ pub enum QPath { /// UFCS source paths can desugar into this, with `Vec::new` turning into /// `<Vec>::new`, and `T::X::Y::method` into `<<<T>::X>::Y>::method`, /// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`. - TypeRelative(P<Ty>, P<PathSegment>), + TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>), } /// Hints at the original code for a let statement. @@ -1909,8 +1909,8 @@ impl From<GeneratorKind> for YieldSource { // N.B., if you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct MutTy { - pub ty: P<Ty>, +pub struct MutTy<'hir> { + pub ty: &'hir Ty<'hir>, pub mutbl: Mutability, } @@ -1919,7 +1919,7 @@ pub struct MutTy { #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct FnSig<'hir> { pub header: FnHeader, - pub decl: &'hir FnDecl, + pub decl: &'hir FnDecl<'hir>, } // The bodies for items are stored "out of line", in a separate @@ -1939,7 +1939,7 @@ pub struct TraitItem<'hir> { pub ident: Ident, pub hir_id: HirId, pub attrs: &'hir [Attribute], - pub generics: Generics, + pub generics: Generics<'hir>, pub kind: TraitItemKind<'hir>, pub span: Span, } @@ -1958,12 +1958,12 @@ pub enum TraitMethod<'hir> { #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum TraitItemKind<'hir> { /// An associated constant with an optional value (otherwise `impl`s must contain a value). - Const(&'hir Ty, Option<BodyId>), + Const(&'hir Ty<'hir>, Option<BodyId>), /// A method with an optional body. Method(FnSig<'hir>, TraitMethod<'hir>), /// An associated type with (possibly empty) bounds and optional concrete /// type. - Type(GenericBounds, Option<&'hir Ty>), + Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>), } // The bodies for items are stored "out of line", in a separate @@ -1979,10 +1979,10 @@ pub struct ImplItemId { pub struct ImplItem<'hir> { pub ident: Ident, pub hir_id: HirId, - pub vis: Visibility, + pub vis: Visibility<'hir>, pub defaultness: Defaultness, pub attrs: &'hir [Attribute], - pub generics: Generics, + pub generics: Generics<'hir>, pub kind: ImplItemKind<'hir>, pub span: Span, } @@ -1992,13 +1992,13 @@ pub struct ImplItem<'hir> { pub enum ImplItemKind<'hir> { /// An associated constant of the given type, set to the constant result /// of the expression. - Const(&'hir Ty, BodyId), + Const(&'hir Ty<'hir>, BodyId), /// A method implementation with the given signature and body. Method(FnSig<'hir>, BodyId), /// An associated type. - TyAlias(&'hir Ty), + TyAlias(&'hir Ty<'hir>), /// An associated `type = impl Trait`. - OpaqueTy(GenericBounds), + OpaqueTy(GenericBounds<'hir>), } /// Bind a type to an associated type (i.e., `A = Foo`). @@ -2017,25 +2017,25 @@ pub enum ImplItemKind<'hir> { /// } /// ``` #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct TypeBinding { +pub struct TypeBinding<'hir> { pub hir_id: HirId, #[stable_hasher(project(name))] pub ident: Ident, - pub kind: TypeBindingKind, + pub kind: TypeBindingKind<'hir>, pub span: Span, } // Represents the two kinds of type bindings. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum TypeBindingKind { +pub enum TypeBindingKind<'hir> { /// E.g., `Foo<Bar: Send>`. - Constraint { bounds: HirVec<GenericBound> }, + Constraint { bounds: &'hir [GenericBound<'hir>] }, /// E.g., `Foo<Bar = ()>`. - Equality { ty: P<Ty> }, + Equality { ty: &'hir Ty<'hir> }, } -impl TypeBinding { - pub fn ty(&self) -> &Ty { +impl TypeBinding<'_> { + pub fn ty(&self) -> &Ty<'_> { match self.kind { TypeBindingKind::Equality { ref ty } => ty, _ => bug!("expected equality type binding for parenthesized generic args"), @@ -2044,13 +2044,13 @@ impl TypeBinding { } #[derive(RustcEncodable, RustcDecodable)] -pub struct Ty { +pub struct Ty<'hir> { pub hir_id: HirId, - pub kind: TyKind, + pub kind: TyKind<'hir>, pub span: Span, } -impl fmt::Debug for Ty { +impl fmt::Debug for Ty<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "type({})", print::to_string(print::NO_ANN, |s| s.print_type(self))) } @@ -2068,18 +2068,18 @@ pub enum PrimTy { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct BareFnTy { +pub struct BareFnTy<'hir> { pub unsafety: Unsafety, pub abi: Abi, - pub generic_params: HirVec<GenericParam>, - pub decl: P<FnDecl>, - pub param_names: HirVec<Ident>, + pub generic_params: &'hir [GenericParam<'hir>], + pub decl: &'hir FnDecl<'hir>, + pub param_names: &'hir [Ident], } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct OpaqueTy { - pub generics: Generics, - pub bounds: GenericBounds, +pub struct OpaqueTy<'hir> { + pub generics: Generics<'hir>, + pub bounds: GenericBounds<'hir>, pub impl_trait_fn: Option<DefId>, pub origin: OpaqueTyOrigin, } @@ -2097,35 +2097,35 @@ pub enum OpaqueTyOrigin { /// The various kinds of types recognized by the compiler. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum TyKind { +pub enum TyKind<'hir> { /// A variable length slice (i.e., `[T]`). - Slice(P<Ty>), + Slice(&'hir Ty<'hir>), /// A fixed length array (i.e., `[T; n]`). - Array(P<Ty>, AnonConst), + Array(&'hir Ty<'hir>, AnonConst), /// A raw pointer (i.e., `*const T` or `*mut T`). - Ptr(MutTy), + Ptr(MutTy<'hir>), /// A reference (i.e., `&'a T` or `&'a mut T`). - Rptr(Lifetime, MutTy), + Rptr(Lifetime, MutTy<'hir>), /// A bare function (e.g., `fn(usize) -> bool`). - BareFn(P<BareFnTy>), + BareFn(&'hir BareFnTy<'hir>), /// The never type (`!`). Never, /// A tuple (`(A, B, C, D, ...)`). - Tup(HirVec<Ty>), + Tup(&'hir [Ty<'hir>]), /// A path to a type definition (`module::module::...::Type`), or an /// associated type (e.g., `<Vec<T> as Trait>::Type` or `<T>::Target`). /// /// Type parameters may be stored in each `PathSegment`. - Path(QPath), + Path(QPath<'hir>), /// A type definition itself. This is currently only used for the `type Foo = impl Trait` /// item that `impl Trait` in return position desugars to. /// /// The generic argument list contains the lifetimes (and in the future possibly parameters) /// that are actually bound on the `impl Trait`. - Def(ItemId, HirVec<GenericArg>), + Def(ItemId, &'hir [GenericArg<'hir>]), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. - TraitObject(HirVec<PolyTraitRef>, Lifetime), + TraitObject(&'hir [PolyTraitRef<'hir>], Lifetime), /// Unused for now. Typeof(AnonConst), /// `TyKind::Infer` means the type should be inferred instead of it having been @@ -2175,12 +2175,12 @@ pub struct Param<'hir> { /// Represents the header (not the body) of a function declaration. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct FnDecl { +pub struct FnDecl<'hir> { /// The types of the function's parameters. /// /// Additional argument data is stored in the function's [body](Body::parameters). - pub inputs: HirVec<Ty>, - pub output: FunctionRetTy, + pub inputs: &'hir [Ty<'hir>], + pub output: FunctionRetTy<'hir>, pub c_variadic: bool, /// Does the function have an implicit self? pub implicit_self: ImplicitSelfKind, @@ -2256,7 +2256,7 @@ impl Defaultness { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub enum FunctionRetTy { +pub enum FunctionRetTy<'hir> { /// Return type is not specified. /// /// Functions default to `()` and @@ -2264,10 +2264,10 @@ pub enum FunctionRetTy { /// type would be inserted. DefaultReturn(Span), /// Everything else. - Return(P<Ty>), + Return(&'hir Ty<'hir>), } -impl fmt::Display for FunctionRetTy { +impl fmt::Display for FunctionRetTy<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Return(ref ty) => print::to_string(print::NO_ANN, |s| s.print_type(ty)).fmt(f), @@ -2276,7 +2276,7 @@ impl fmt::Display for FunctionRetTy { } } -impl FunctionRetTy { +impl FunctionRetTy<'_> { pub fn span(&self) -> Span { match *self { DefaultReturn(span) => span, @@ -2350,14 +2350,14 @@ pub enum UseKind { /// trait being referred to but just a unique `HirId` that serves as a key /// within the resolution map. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct TraitRef { - pub path: P<Path>, +pub struct TraitRef<'hir> { + pub path: &'hir Path<'hir>, // Don't hash the `ref_id`. It is tracked via the thing it is used to access. #[stable_hasher(ignore)] pub hir_ref_id: HirId, } -impl TraitRef { +impl TraitRef<'_> { /// Gets the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias. pub fn trait_def_id(&self) -> DefId { match self.path.res { @@ -2372,27 +2372,27 @@ impl TraitRef { } #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct PolyTraitRef { +pub struct PolyTraitRef<'hir> { /// The `'a` in `<'a> Foo<&'a T>`. - pub bound_generic_params: HirVec<GenericParam>, + pub bound_generic_params: &'hir [GenericParam<'hir>], /// The `Foo<&'a T>` in `<'a> Foo<&'a T>`. - pub trait_ref: TraitRef, + pub trait_ref: TraitRef<'hir>, pub span: Span, } -pub type Visibility = Spanned<VisibilityKind>; +pub type Visibility<'hir> = Spanned<VisibilityKind<'hir>>; #[derive(RustcEncodable, RustcDecodable, Debug)] -pub enum VisibilityKind { +pub enum VisibilityKind<'hir> { Public, Crate(CrateSugar), - Restricted { path: P<Path>, hir_id: HirId }, + Restricted { path: &'hir Path<'hir>, hir_id: HirId }, Inherited, } -impl VisibilityKind { +impl VisibilityKind<'_> { pub fn is_pub(&self) -> bool { match *self { VisibilityKind::Public => true, @@ -2422,9 +2422,9 @@ pub struct StructField<'hir> { pub span: Span, #[stable_hasher(project(name))] pub ident: Ident, - pub vis: Visibility, + pub vis: Visibility<'hir>, pub hir_id: HirId, - pub ty: &'hir Ty, + pub ty: &'hir Ty<'hir>, pub attrs: &'hir [Attribute], } @@ -2488,7 +2488,7 @@ pub struct Item<'hir> { pub hir_id: HirId, pub attrs: &'hir [Attribute], pub kind: ItemKind<'hir>, - pub vis: Visibility, + pub vis: Visibility<'hir>, pub span: Span, } @@ -2521,14 +2521,14 @@ pub enum ItemKind<'hir> { /// or just /// /// `use foo::bar::baz;` (with `as baz` implicitly on the right). - Use(&'hir Path, UseKind), + Use(&'hir Path<'hir>, UseKind), /// A `static` item. - Static(&'hir Ty, Mutability, BodyId), + Static(&'hir Ty<'hir>, Mutability, BodyId), /// A `const` item. - Const(&'hir Ty, BodyId), + Const(&'hir Ty<'hir>, BodyId), /// A function declaration. - Fn(FnSig<'hir>, Generics, BodyId), + Fn(FnSig<'hir>, Generics<'hir>, BodyId), /// A module. Mod(Mod<'hir>), /// An external module, e.g. `extern { .. }`. @@ -2536,29 +2536,29 @@ pub enum ItemKind<'hir> { /// Module-level inline assembly (from `global_asm!`). GlobalAsm(&'hir GlobalAsm), /// A type alias, e.g., `type Foo = Bar<u8>`. - TyAlias(&'hir Ty, Generics), + TyAlias(&'hir Ty<'hir>, Generics<'hir>), /// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`. - OpaqueTy(OpaqueTy), + OpaqueTy(OpaqueTy<'hir>), /// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`. - Enum(EnumDef<'hir>, Generics), + Enum(EnumDef<'hir>, Generics<'hir>), /// A struct definition, e.g., `struct Foo<A> {x: A}`. - Struct(VariantData<'hir>, Generics), + Struct(VariantData<'hir>, Generics<'hir>), /// A union definition, e.g., `union Foo<A, B> {x: A, y: B}`. - Union(VariantData<'hir>, Generics), + Union(VariantData<'hir>, Generics<'hir>), /// A trait definition. - Trait(IsAuto, Unsafety, Generics, GenericBounds, &'hir [TraitItemRef]), + Trait(IsAuto, Unsafety, Generics<'hir>, GenericBounds<'hir>, &'hir [TraitItemRef]), /// A trait alias. - TraitAlias(Generics, GenericBounds), + TraitAlias(Generics<'hir>, GenericBounds<'hir>), /// An implementation, e.g., `impl<A> Trait for Foo { .. }`. Impl( Unsafety, ImplPolarity, Defaultness, - Generics, - Option<TraitRef>, // (optional) trait this impl implements - &'hir Ty, // self - &'hir [ImplItemRef], + Generics<'hir>, + Option<TraitRef<'hir>>, // (optional) trait this impl implements + &'hir Ty<'hir>, // self + &'hir [ImplItemRef<'hir>], ), } @@ -2593,7 +2593,7 @@ impl ItemKind<'_> { } } - pub fn generics(&self) -> Option<&Generics> { + pub fn generics(&self) -> Option<&Generics<'_>> { Some(match *self { ItemKind::Fn(_, ref generics, _) | ItemKind::TyAlias(_, ref generics) @@ -2631,13 +2631,13 @@ pub struct TraitItemRef { /// passes to find the impl they want without loading the ID (which /// means fewer edges in the incremental compilation graph). #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] -pub struct ImplItemRef { +pub struct ImplItemRef<'hir> { pub id: ImplItemId, #[stable_hasher(project(name))] pub ident: Ident, pub kind: AssocItemKind, pub span: Span, - pub vis: Visibility, + pub vis: Visibility<'hir>, pub defaultness: Defaultness, } @@ -2657,16 +2657,16 @@ pub struct ForeignItem<'hir> { pub kind: ForeignItemKind<'hir>, pub hir_id: HirId, pub span: Span, - pub vis: Visibility, + pub vis: Visibility<'hir>, } /// An item within an `extern` block. #[derive(RustcEncodable, RustcDecodable, Debug, HashStable)] pub enum ForeignItemKind<'hir> { /// A foreign function. - Fn(&'hir FnDecl, &'hir [Ident], Generics), + Fn(&'hir FnDecl<'hir>, &'hir [Ident], Generics<'hir>), /// A foreign static item (`static ext: u8`). - Static(&'hir Ty, Mutability), + Static(&'hir Ty<'hir>, Mutability), /// A foreign type. Type, } @@ -2837,9 +2837,9 @@ pub enum Node<'hir> { AnonConst(&'hir AnonConst), Expr(&'hir Expr<'hir>), Stmt(&'hir Stmt<'hir>), - PathSegment(&'hir PathSegment), - Ty(&'hir Ty), - TraitRef(&'hir TraitRef), + PathSegment(&'hir PathSegment<'hir>), + Ty(&'hir Ty<'hir>), + TraitRef(&'hir TraitRef<'hir>), Binding(&'hir Pat<'hir>), Pat(&'hir Pat<'hir>), Arm(&'hir Arm<'hir>), @@ -2852,8 +2852,8 @@ pub enum Node<'hir> { Ctor(&'hir VariantData<'hir>), Lifetime(&'hir Lifetime), - GenericParam(&'hir GenericParam), - Visibility(&'hir Visibility), + GenericParam(&'hir GenericParam<'hir>), + Visibility(&'hir Visibility<'hir>), Crate, } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 9e2702a0ff2..84e824f64df 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -140,7 +140,7 @@ where printer.s.eof() } -pub fn visibility_qualified<S: Into<Cow<'static, str>>>(vis: &hir::Visibility, w: S) -> String { +pub fn visibility_qualified<S: Into<Cow<'static, str>>>(vis: &hir::Visibility<'_>, w: S) -> String { to_string(NO_ANN, |s| { s.print_visibility(vis); s.s.word(w) @@ -266,7 +266,7 @@ impl<'a> State<'a> { } } - pub fn print_type(&mut self, ty: &hir::Ty) { + pub fn print_type(&mut self, ty: &hir::Ty<'_>) { self.maybe_print_comment(ty.span.lo()); self.ibox(0); match ty.kind { @@ -398,9 +398,9 @@ impl<'a> State<'a> { fn print_associated_const( &mut self, ident: ast::Ident, - ty: &hir::Ty, + ty: &hir::Ty<'_>, default: Option<hir::BodyId>, - vis: &hir::Visibility, + vis: &hir::Visibility<'_>, ) { self.s.word(visibility_qualified(vis, "")); self.word_space("const"); @@ -418,8 +418,8 @@ impl<'a> State<'a> { fn print_associated_type( &mut self, ident: ast::Ident, - bounds: Option<&hir::GenericBounds>, - ty: Option<&hir::Ty>, + bounds: Option<&hir::GenericBounds<'_>>, + ty: Option<&hir::Ty<'_>>, ) { self.word_space("type"); self.print_ident(ident); @@ -437,7 +437,7 @@ impl<'a> State<'a> { fn print_item_type( &mut self, item: &hir::Item<'_>, - generics: &hir::Generics, + generics: &hir::Generics<'_>, inner: impl Fn(&mut Self), ) { self.head(visibility_qualified(&item.vis, "type")); @@ -682,11 +682,11 @@ impl<'a> State<'a> { self.ann.post(self, AnnNode::Item(item)) } - pub fn print_trait_ref(&mut self, t: &hir::TraitRef) { + pub fn print_trait_ref(&mut self, t: &hir::TraitRef<'_>) { self.print_path(&t.path, false) } - fn print_formal_generic_params(&mut self, generic_params: &[hir::GenericParam]) { + fn print_formal_generic_params(&mut self, generic_params: &[hir::GenericParam<'_>]) { if !generic_params.is_empty() { self.s.word("for"); self.print_generic_params(generic_params); @@ -694,7 +694,7 @@ impl<'a> State<'a> { } } - fn print_poly_trait_ref(&mut self, t: &hir::PolyTraitRef) { + fn print_poly_trait_ref(&mut self, t: &hir::PolyTraitRef<'_>) { self.print_formal_generic_params(&t.bound_generic_params); self.print_trait_ref(&t.trait_ref) } @@ -702,10 +702,10 @@ impl<'a> State<'a> { pub fn print_enum_def( &mut self, enum_definition: &hir::EnumDef<'_>, - generics: &hir::Generics, + generics: &hir::Generics<'_>, name: ast::Name, span: syntax_pos::Span, - visibility: &hir::Visibility, + visibility: &hir::Visibility<'_>, ) { self.head(visibility_qualified(visibility, "enum")); self.print_name(name); @@ -730,7 +730,7 @@ impl<'a> State<'a> { self.bclose(span) } - pub fn print_visibility(&mut self, vis: &hir::Visibility) { + pub fn print_visibility(&mut self, vis: &hir::Visibility<'_>) { match vis.node { hir::VisibilityKind::Public => self.word_nbsp("pub"), hir::VisibilityKind::Crate(ast::CrateSugar::JustCrate) => self.word_nbsp("crate"), @@ -761,7 +761,7 @@ impl<'a> State<'a> { pub fn print_struct( &mut self, struct_def: &hir::VariantData<'_>, - generics: &hir::Generics, + generics: &hir::Generics<'_>, name: ast::Name, span: syntax_pos::Span, print_finalizer: bool, @@ -823,8 +823,8 @@ impl<'a> State<'a> { &mut self, ident: ast::Ident, m: &hir::FnSig<'_>, - generics: &hir::Generics, - vis: &hir::Visibility, + generics: &hir::Generics<'_>, + vis: &hir::Visibility<'_>, arg_names: &[ast::Ident], body_id: Option<hir::BodyId>, ) { @@ -1044,7 +1044,7 @@ impl<'a> State<'a> { fn print_expr_struct( &mut self, - qpath: &hir::QPath, + qpath: &hir::QPath<'_>, fields: &[hir::Field<'_>], wth: &Option<&'hir hir::Expr<'_>>, ) { @@ -1103,7 +1103,7 @@ impl<'a> State<'a> { self.print_call_post(args) } - fn print_expr_method_call(&mut self, segment: &hir::PathSegment, args: &[hir::Expr<'_>]) { + fn print_expr_method_call(&mut self, segment: &hir::PathSegment<'_>, args: &[hir::Expr<'_>]) { let base_args = &args[1..]; self.print_expr_maybe_paren(&args[0], parser::PREC_POSTFIX); self.s.word("."); @@ -1440,7 +1440,7 @@ impl<'a> State<'a> { self.print_expr(coll) } - pub fn print_path(&mut self, path: &hir::Path, colons_before_params: bool) { + pub fn print_path(&mut self, path: &hir::Path<'_>, colons_before_params: bool) { self.maybe_print_comment(path.span.lo()); for (i, segment) in path.segments.iter().enumerate() { @@ -1458,14 +1458,14 @@ impl<'a> State<'a> { } } - pub fn print_path_segment(&mut self, segment: &hir::PathSegment) { + pub fn print_path_segment(&mut self, segment: &hir::PathSegment<'_>) { if segment.ident.name != kw::PathRoot { self.print_ident(segment.ident); self.print_generic_args(segment.generic_args(), segment.infer_args, false); } } - pub fn print_qpath(&mut self, qpath: &hir::QPath, colons_before_params: bool) { + pub fn print_qpath(&mut self, qpath: &hir::QPath<'_>, colons_before_params: bool) { match *qpath { hir::QPath::Resolved(None, ref path) => self.print_path(path, colons_before_params), hir::QPath::Resolved(Some(ref qself), ref path) => { @@ -1523,7 +1523,7 @@ impl<'a> State<'a> { fn print_generic_args( &mut self, - generic_args: &hir::GenericArgs, + generic_args: &hir::GenericArgs<'_>, infer_args: bool, colons_before_params: bool, ) { @@ -1814,11 +1814,11 @@ impl<'a> State<'a> { pub fn print_fn( &mut self, - decl: &hir::FnDecl, + decl: &hir::FnDecl<'_>, header: hir::FnHeader, name: Option<ast::Name>, - generics: &hir::Generics, - vis: &hir::Visibility, + generics: &hir::Generics<'_>, + vis: &hir::Visibility<'_>, arg_names: &[ast::Ident], body_id: Option<hir::BodyId>, ) { @@ -1858,7 +1858,7 @@ impl<'a> State<'a> { self.print_where_clause(&generics.where_clause) } - fn print_closure_params(&mut self, decl: &hir::FnDecl, body_id: hir::BodyId) { + fn print_closure_params(&mut self, decl: &hir::FnDecl<'_>, body_id: hir::BodyId) { self.s.word("|"); let mut i = 0; self.commasep(Inconsistent, &decl.inputs, |s, ty| { @@ -1903,7 +1903,7 @@ impl<'a> State<'a> { pub fn print_bounds<'b>( &mut self, prefix: &'static str, - bounds: impl IntoIterator<Item = &'b hir::GenericBound>, + bounds: impl IntoIterator<Item = &'b hir::GenericBound<'b>>, ) { let mut first = true; for bound in bounds { @@ -1933,7 +1933,7 @@ impl<'a> State<'a> { } } - pub fn print_generic_params(&mut self, generic_params: &[GenericParam]) { + pub fn print_generic_params(&mut self, generic_params: &[GenericParam<'_>]) { if !generic_params.is_empty() { self.s.word("<"); @@ -1943,7 +1943,7 @@ impl<'a> State<'a> { } } - pub fn print_generic_param(&mut self, param: &GenericParam) { + pub fn print_generic_param(&mut self, param: &GenericParam<'_>) { if let GenericParamKind::Const { .. } = param.kind { self.word_space("const"); } @@ -1986,7 +1986,7 @@ impl<'a> State<'a> { self.print_ident(lifetime.name.ident()) } - pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause) { + pub fn print_where_clause(&mut self, where_clause: &hir::WhereClause<'_>) { if where_clause.predicates.is_empty() { return; } @@ -2056,12 +2056,12 @@ impl<'a> State<'a> { } } - pub fn print_mt(&mut self, mt: &hir::MutTy, print_const: bool) { + pub fn print_mt(&mut self, mt: &hir::MutTy<'_>, print_const: bool) { self.print_mutability(mt.mutbl, print_const); self.print_type(&mt.ty) } - pub fn print_fn_output(&mut self, decl: &hir::FnDecl) { + pub fn print_fn_output(&mut self, decl: &hir::FnDecl<'_>) { if let hir::DefaultReturn(..) = decl.output { return; } @@ -2085,9 +2085,9 @@ impl<'a> State<'a> { &mut self, abi: Abi, unsafety: hir::Unsafety, - decl: &hir::FnDecl, + decl: &hir::FnDecl<'_>, name: Option<ast::Name>, - generic_params: &[hir::GenericParam], + generic_params: &[hir::GenericParam<'_>], arg_names: &[ast::Ident], ) { self.ibox(INDENT_UNIT); @@ -2164,7 +2164,7 @@ impl<'a> State<'a> { } } - pub fn print_fn_header_info(&mut self, header: hir::FnHeader, vis: &hir::Visibility) { + pub fn print_fn_header_info(&mut self, header: hir::FnHeader, vis: &hir::Visibility<'_>) { self.s.word(visibility_qualified(vis, "")); match header.constness { diff --git a/src/librustc/hir/upvars.rs b/src/librustc/hir/upvars.rs index d7de226df59..827cf751394 100644 --- a/src/librustc/hir/upvars.rs +++ b/src/librustc/hir/upvars.rs @@ -73,7 +73,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { NestedVisitorMap::None } - fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) { + fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) { if let Res::Local(var_id) = path.res { self.visit_local_use(var_id, path.span); } diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 31d4f8513b2..214a50456d5 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -106,7 +106,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItemId { } } -impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty { +impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty<'_> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { hcx.while_hashing_hir_bodies(true, |hcx| { let hir::Ty { hir_id: _, ref kind, ref span } = *self; @@ -168,7 +168,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem<'_> { } } -impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind { +impl<'a> HashStable<StableHashingContext<'a>> for hir::VisibilityKind<'_> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(hcx, hasher); match *self { diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 6b977393806..5a6d336ee1b 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -107,7 +107,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { fn closure_return_type_suggestion( span: Span, err: &mut DiagnosticBuilder<'_>, - output: &FunctionRetTy, + output: &FunctionRetTy<'_>, body: &Body<'_>, descr: &str, name: &str, @@ -460,7 +460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { /// needed, suggest annotating the call, otherwise point out the resulting type of the call. fn annotate_method_call( &self, - segment: &hir::PathSegment, + segment: &hir::PathSegment<'_>, e: &Expr<'_>, err: &mut DiagnosticBuilder<'_>, ) { diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index decc00826dd..9077a48f850 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -25,7 +25,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { &self, region: Region<'tcx>, br: &ty::BoundRegion, - ) -> Option<(&hir::Ty, &hir::FnDecl)> { + ) -> Option<(&hir::Ty<'_>, &hir::FnDecl<'_>)> { if let Some(anon_reg) = self.tcx().is_suitable_region(region) { let def_id = anon_reg.def_id; if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) { @@ -57,9 +57,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { // to the anonymous region. fn find_component_for_bound_region( &self, - arg: &'tcx hir::Ty, + arg: &'tcx hir::Ty<'tcx>, br: &ty::BoundRegion, - ) -> Option<&'tcx hir::Ty> { + ) -> Option<&'tcx hir::Ty<'tcx>> { let mut nested_visitor = FindNestedTypeVisitor { tcx: self.tcx(), bound_region: *br, @@ -85,7 +85,7 @@ struct FindNestedTypeVisitor<'tcx> { bound_region: ty::BoundRegion, // The type where the anonymous lifetime appears // for e.g., Vec<`&u8`> and <`&u8`> - found_type: Option<&'tcx hir::Ty>, + found_type: Option<&'tcx hir::Ty<'tcx>>, current_index: ty::DebruijnIndex, } @@ -94,7 +94,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir()) } - fn visit_ty(&mut self, arg: &'tcx hir::Ty) { + fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) { match arg.kind { hir::TyKind::BareFn(_) => { self.current_index.shift_in(1); @@ -250,7 +250,7 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> { } } - fn visit_ty(&mut self, arg: &'tcx hir::Ty) { + fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) { // ignore nested types // // If you have a type like `Foo<'a, &Ty>` we diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index 638c8f52007..95feef313c0 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -106,7 +106,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { &self, scope_def_id: DefId, br: ty::BoundRegion, - decl: &hir::FnDecl, + decl: &hir::FnDecl<'_>, ) -> Option<Span> { let ret_ty = self.tcx().type_of(scope_def_id); if let ty::FnDef(_, _) = ret_ty.kind { diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4e1e62512ac..44258b62ca3 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -452,7 +452,7 @@ pub struct LateContext<'a, 'tcx> { last_node_with_lint_attrs: hir::HirId, /// Generic type parameters in scope for the item we are in. - pub generics: Option<&'tcx hir::Generics>, + pub generics: Option<&'tcx hir::Generics<'tcx>>, /// We are only looking at one module only_module: bool, @@ -956,7 +956,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> fn visit_fn( &mut self, fk: hir_visit::FnKind<'tcx>, - decl: &'tcx hir::FnDecl, + decl: &'tcx hir::FnDecl<'tcx>, body_id: hir::BodyId, span: Span, id: hir::HirId, @@ -976,7 +976,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> &mut self, s: &'tcx hir::VariantData<'tcx>, _: ast::Name, - _: &'tcx hir::Generics, + _: &'tcx hir::Generics<'tcx>, _: hir::HirId, _: Span, ) { @@ -995,7 +995,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> fn visit_variant( &mut self, v: &'tcx hir::Variant<'tcx>, - g: &'tcx hir::Generics, + g: &'tcx hir::Generics<'tcx>, item_id: hir::HirId, ) { self.with_lint_attrs(v.id, &v.attrs, |cx| { @@ -1005,7 +1005,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> }) } - fn visit_ty(&mut self, t: &'tcx hir::Ty) { + fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) { lint_callback!(self, check_ty, t); hir_visit::walk_ty(self, t); } @@ -1038,22 +1038,26 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> hir_visit::walk_arm(self, a); } - fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam) { + fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) { lint_callback!(self, check_generic_param, p); hir_visit::walk_generic_param(self, p); } - fn visit_generics(&mut self, g: &'tcx hir::Generics) { + fn visit_generics(&mut self, g: &'tcx hir::Generics<'tcx>) { lint_callback!(self, check_generics, g); hir_visit::walk_generics(self, g); } - fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate) { + fn visit_where_predicate(&mut self, p: &'tcx hir::WherePredicate<'tcx>) { lint_callback!(self, check_where_predicate, p); hir_visit::walk_where_predicate(self, p); } - fn visit_poly_trait_ref(&mut self, t: &'tcx hir::PolyTraitRef, m: hir::TraitBoundModifier) { + fn visit_poly_trait_ref( + &mut self, + t: &'tcx hir::PolyTraitRef<'tcx>, + m: hir::TraitBoundModifier, + ) { lint_callback!(self, check_poly_trait_ref, t, m); hir_visit::walk_poly_trait_ref(self, t, m); } @@ -1089,7 +1093,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx> hir_visit::walk_lifetime(self, lt); } - fn visit_path(&mut self, p: &'tcx hir::Path, id: hir::HirId) { + fn visit_path(&mut self, p: &'tcx hir::Path<'tcx>, id: hir::HirId) { lint_callback!(self, check_path, p, id); hir_visit::walk_path(self, p); } diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs index 55ed46e774d..bd75eda1879 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc/lint/internal.rs @@ -76,7 +76,7 @@ declare_lint_pass!(TyTyKind => [ ]); impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind { - fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) { + fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path<'tcx>, _: HirId) { let segments = path.segments.iter().rev().skip(1).rev(); if let Some(last) = segments.last() { @@ -94,7 +94,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind { } } - fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) { + fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty<'tcx>) { match &ty.kind { TyKind::Path(qpath) => { if let QPath::Resolved(_, path) = qpath { @@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyTyKind { } } -fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool { +fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment<'_>) -> bool { if let Some(res) = segment.res { if let Some(did) = res.opt_def_id() { return cx.tcx.is_diagnostic_item(sym::TyKind, did); @@ -169,7 +169,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool { false } -fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty) -> Option<String> { +fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty<'_>) -> Option<String> { match &ty.kind { TyKind::Path(qpath) => { if let QPath::Resolved(_, path) = qpath { @@ -187,7 +187,7 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_, '_>, ty: &Ty) -> Option<String> { None } -fn gen_args(segment: &PathSegment) -> String { +fn gen_args(segment: &PathSegment<'_>) -> String { if let Some(args) = &segment.args { let lifetimes = args .args diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 97b38db4165..f4684bd5222 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -107,20 +107,20 @@ macro_rules! late_lint_methods { fn check_pat(a: &$hir hir::Pat<$hir>); fn check_expr(a: &$hir hir::Expr<$hir>); fn check_expr_post(a: &$hir hir::Expr<$hir>); - fn check_ty(a: &$hir hir::Ty); - fn check_generic_param(a: &$hir hir::GenericParam); - fn check_generics(a: &$hir hir::Generics); - fn check_where_predicate(a: &$hir hir::WherePredicate); - fn check_poly_trait_ref(a: &$hir hir::PolyTraitRef, b: hir::TraitBoundModifier); + fn check_ty(a: &$hir hir::Ty<$hir>); + fn check_generic_param(a: &$hir hir::GenericParam<$hir>); + fn check_generics(a: &$hir hir::Generics<$hir>); + fn check_where_predicate(a: &$hir hir::WherePredicate<$hir>); + fn check_poly_trait_ref(a: &$hir hir::PolyTraitRef<$hir>, b: hir::TraitBoundModifier); fn check_fn( a: hir::intravisit::FnKind<$hir>, - b: &$hir hir::FnDecl, + b: &$hir hir::FnDecl<$hir>, c: &$hir hir::Body<$hir>, d: Span, e: hir::HirId); fn check_fn_post( a: hir::intravisit::FnKind<$hir>, - b: &$hir hir::FnDecl, + b: &$hir hir::FnDecl<$hir>, c: &$hir hir::Body<$hir>, d: Span, e: hir::HirId @@ -135,7 +135,7 @@ macro_rules! late_lint_methods { fn check_variant(a: &$hir hir::Variant<$hir>); fn check_variant_post(a: &$hir hir::Variant<$hir>); fn check_lifetime(a: &$hir hir::Lifetime); - fn check_path(a: &$hir hir::Path, b: hir::HirId); + fn check_path(a: &$hir hir::Path<$hir>, b: hir::HirId); fn check_attribute(a: &$hir ast::Attribute); /// Called when entering a syntax node that can have lint attributes such @@ -643,7 +643,7 @@ impl intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { fn visit_variant( &mut self, v: &'tcx hir::Variant<'tcx>, - g: &'tcx hir::Generics, + g: &'tcx hir::Generics<'tcx>, item_id: hir::HirId, ) { self.with_lint_attrs(v.id, &v.attrs, |builder| { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 7950ff421b4..82f19478b94 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -44,7 +44,7 @@ pub enum LifetimeDefOrigin { } impl LifetimeDefOrigin { - fn from_param(param: &GenericParam) -> Self { + fn from_param(param: &GenericParam<'_>) -> Self { match param.kind { GenericParamKind::Lifetime { kind } => match kind { LifetimeParamKind::InBand => LifetimeDefOrigin::InBand, @@ -74,7 +74,7 @@ pub enum Region { } impl Region { - fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam) -> (ParamName, Region) { + fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam<'_>) -> (ParamName, Region) { let i = *index; *index += 1; let def_id = hir_map.local_def_id(param.hir_id); @@ -83,7 +83,7 @@ impl Region { (param.name.modern(), Region::EarlyBound(i, def_id, origin)) } - fn late(hir_map: &Map<'_>, param: &GenericParam) -> (ParamName, Region) { + fn late(hir_map: &Map<'_>, param: &GenericParam<'_>) -> (ParamName, Region) { let depth = ty::INNERMOST; let def_id = hir_map.local_def_id(param.hir_id); let origin = LifetimeDefOrigin::from_param(param); @@ -517,7 +517,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } } - fn visit_ty(&mut self, ty: &'tcx hir::Ty) { + fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) { debug!("visit_ty: id={:?} ty={:?}", ty.hir_id, ty); debug!("visit_ty: ty.kind={:?}", ty.kind); match ty.kind { @@ -881,7 +881,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { self.resolve_lifetime_ref(lifetime_ref); } - fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) { + fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) { for (i, segment) in path.segments.iter().enumerate() { let depth = path.segments.len() - i - 1; if let Some(ref args) = segment.args { @@ -890,7 +890,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { } } - fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl) { + fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) { let output = match fd.output { hir::DefaultReturn(_) => None, hir::Return(ref ty) => Some(&**ty), @@ -898,7 +898,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { self.visit_fn_like_elision(&fd.inputs, output); } - fn visit_generics(&mut self, generics: &'tcx hir::Generics) { + fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) { check_mixed_explicit_and_in_band_defs(self.tcx, &generics.params); for param in &generics.params { match param.kind { @@ -976,7 +976,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_poly_trait_ref( &mut self, - trait_ref: &'tcx hir::PolyTraitRef, + trait_ref: &'tcx hir::PolyTraitRef<'tcx>, _modifier: hir::TraitBoundModifier, ) { debug!("visit_poly_trait_ref(trait_ref={:?})", trait_ref); @@ -1046,7 +1046,7 @@ fn shadower_label(span: Span) -> Shadower { fn original_lifetime(span: Span) -> Original { Original { kind: ShadowKind::Lifetime, span: span } } -fn shadower_lifetime(param: &hir::GenericParam) -> Shadower { +fn shadower_lifetime(param: &hir::GenericParam<'_>) -> Shadower { Shadower { kind: ShadowKind::Lifetime, span: param.span } } @@ -1059,7 +1059,7 @@ impl ShadowKind { } } -fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::GenericParam]>) { +fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_>, params: &P<[hir::GenericParam<'_>]>) { let lifetime_params: Vec<_> = params .iter() .filter_map(|param| match param.kind { @@ -1252,9 +1252,9 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet /// for each type parameter. fn object_lifetime_defaults_for_item( tcx: TyCtxt<'_>, - generics: &hir::Generics, + generics: &hir::Generics<'_>, ) -> Vec<ObjectLifetimeDefault> { - fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound]) { + fn add_bounds(set: &mut Set1<hir::LifetimeName>, bounds: &[hir::GenericBound<'_>]) { for bound in bounds { if let hir::GenericBound::Outlives(ref lifetime) = *bound { set.insert(lifetime.name.modern()); @@ -1368,7 +1368,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { /// helper method to determine the span to remove when suggesting the /// deletion of a lifetime - fn lifetime_deletion_span(&self, name: ast::Ident, generics: &hir::Generics) -> Option<Span> { + fn lifetime_deletion_span( + &self, + name: ast::Ident, + generics: &hir::Generics<'_>, + ) -> Option<Span> { generics.params.iter().enumerate().find_map(|(i, param)| { if param.name.ident() == name { let mut in_band = false; @@ -1417,7 +1421,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let mut remove_use = None; let mut elide_use = None; - let mut find_arg_use_span = |inputs: &hir::HirVec<hir::Ty>| { + let mut find_arg_use_span = |inputs: &hir::HirVec<hir::Ty<'_>>| { for input in inputs { match input.kind { hir::TyKind::Rptr(lt, _) => { @@ -1656,8 +1660,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { fn visit_early_late<F>( &mut self, parent_id: Option<hir::HirId>, - decl: &'tcx hir::FnDecl, - generics: &'tcx hir::Generics, + decl: &'tcx hir::FnDecl<'tcx>, + generics: &'tcx hir::Generics<'tcx>, walk: F, ) where F: for<'b, 'c> FnOnce(&'b mut LifetimeContext<'c, 'tcx>), @@ -1854,7 +1858,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - fn visit_segment_args(&mut self, res: Res, depth: usize, generic_args: &'tcx hir::GenericArgs) { + fn visit_segment_args( + &mut self, + res: Res, + depth: usize, + generic_args: &'tcx hir::GenericArgs<'tcx>, + ) { debug!( "visit_segment_args(res={:?}, depth={:?}, generic_args={:?})", res, depth, generic_args, @@ -2045,7 +2054,11 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tcx hir::Ty>) { + fn visit_fn_like_elision( + &mut self, + inputs: &'tcx [hir::Ty<'tcx>], + output: Option<&'tcx hir::Ty<'tcx>>, + ) { debug!("visit_fn_like_elision: enter"); let mut arg_elide = Elide::FreshLateAnon(Cell::new(0)); let arg_scope = Scope::Elision { elide: arg_elide.clone(), s: self.scope }; @@ -2125,7 +2138,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { if has_self { struct SelfVisitor<'a> { map: &'a NamedRegionMap, - impl_self: Option<&'a hir::TyKind>, + impl_self: Option<&'a hir::TyKind<'a>>, lifetime: Set1<Region>, } @@ -2163,7 +2176,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { NestedVisitorMap::None } - fn visit_ty(&mut self, ty: &'a hir::Ty) { + fn visit_ty(&mut self, ty: &'a hir::Ty<'a>) { if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.kind { if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.kind { @@ -2251,7 +2264,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { NestedVisitorMap::None } - fn visit_ty(&mut self, ty: &hir::Ty) { + fn visit_ty(&mut self, ty: &hir::Ty<'_>) { if let hir::TyKind::BareFn(_) = ty.kind { self.outer_index.shift_in(1); } @@ -2276,7 +2289,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - fn visit_generic_param(&mut self, param: &hir::GenericParam) { + fn visit_generic_param(&mut self, param: &hir::GenericParam<'_>) { if let hir::GenericParamKind::Lifetime { .. } = param.kind { // FIXME(eddyb) Do we want this? It only makes a difference // if this `for<'a>` lifetime parameter is never used. @@ -2288,7 +2301,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { fn visit_poly_trait_ref( &mut self, - trait_ref: &hir::PolyTraitRef, + trait_ref: &hir::PolyTraitRef<'_>, modifier: hir::TraitBoundModifier, ) { self.outer_index.shift_in(1); @@ -2523,7 +2536,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { fn check_lifetime_params( &mut self, old_scope: ScopeRef<'_>, - params: &'tcx [hir::GenericParam], + params: &'tcx [hir::GenericParam<'tcx>], ) { let lifetimes: Vec<_> = params .iter() @@ -2617,7 +2630,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { fn check_lifetime_param_for_shadowing( &self, mut old_scope: ScopeRef<'_>, - param: &'tcx hir::GenericParam, + param: &'tcx hir::GenericParam<'tcx>, ) { for label in &self.labels_in_fn { // FIXME (#24278): non-hygienic comparison @@ -2755,8 +2768,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { /// T as Trait<''b>>::Foo` does not constrain `'a` or `'b`. fn insert_late_bound_lifetimes( map: &mut NamedRegionMap, - decl: &hir::FnDecl, - generics: &hir::Generics, + decl: &hir::FnDecl<'_>, + generics: &hir::Generics<'_>, ) { debug!("insert_late_bound_lifetimes(decl={:?}, generics={:?})", decl, generics); @@ -2840,7 +2853,7 @@ fn insert_late_bound_lifetimes( NestedVisitorMap::None } - fn visit_ty(&mut self, ty: &'v hir::Ty) { + fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) { match ty.kind { hir::TyKind::Path(hir::QPath::Resolved(Some(_), _)) | hir::TyKind::Path(hir::QPath::TypeRelative(..)) => { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index f1c07f36da5..b692459eb51 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -306,7 +306,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { }); } - fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics, item_id: HirId) { + fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, item_id: HirId) { self.annotate(var.id, &var.attrs, var.span, AnnotationKind::Required, |v| { if let Some(ctor_hir_id) = var.data.ctor_hir_id() { v.annotate(ctor_hir_id, &var.attrs, var.span, AnnotationKind::Required, |_| {}); @@ -381,7 +381,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> { intravisit::walk_impl_item(self, ii); } - fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics, item_id: HirId) { + fn visit_variant(&mut self, var: &'tcx Variant<'tcx>, g: &'tcx Generics<'tcx>, item_id: HirId) { self.check_missing_stability(var.id, var.span, "variant"); intravisit::walk_variant(self, var, g, item_id); } @@ -886,7 +886,7 @@ impl Visitor<'tcx> for Checker<'tcx> { intravisit::walk_item(self, item); } - fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) { + fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) { if let Some(def_id) = path.res.opt_def_id() { self.tcx.check_stability(def_id, Some(id), path.span) } diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f7d9cb34fa9..878675f9812 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1154,7 +1154,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }; let suggest_restriction = - |generics: &hir::Generics, msg, err: &mut DiagnosticBuilder<'_>| { + |generics: &hir::Generics<'_>, msg, err: &mut DiagnosticBuilder<'_>| { let span = generics.where_clause.span_for_predicates_or_empty_place(); if !span.from_expansion() && span.desugaring_kind().is_none() { err.span_suggestion( @@ -2851,7 +2851,7 @@ impl ArgKind { /// Suggest restricting a type param with a new bound. pub fn suggest_constraining_type_param( - generics: &hir::Generics, + generics: &hir::Generics<'_>, err: &mut DiagnosticBuilder<'_>, param_name: &str, constraint: &str, diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2659caf030b..d92fd34d7e4 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -464,7 +464,7 @@ impl<'tcx> TypeckTables<'tcx> { } /// Returns the final resolution of a `QPath` in an `Expr` or `Pat` node. - pub fn qpath_res(&self, qpath: &hir::QPath, id: hir::HirId) -> Res { + pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res { match *qpath { hir::QPath::Resolved(_, ref path) => path.res, hir::QPath::TypeRelative(..) => self diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 8834e0e5a08..2c40c9dc9ef 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -298,7 +298,7 @@ impl<'tcx> DefIdTree for TyCtxt<'tcx> { } impl Visibility { - pub fn from_hir(visibility: &hir::Visibility, id: hir::HirId, tcx: TyCtxt<'_>) -> Self { + pub fn from_hir(visibility: &hir::Visibility<'_>, id: hir::HirId, tcx: TyCtxt<'_>) -> Self { match visibility.node { hir::VisibilityKind::Public => Visibility::Public, hir::VisibilityKind::Crate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)), @@ -2757,7 +2757,7 @@ impl<'tcx> TyCtxt<'tcx> { fn associated_item_from_trait_item_ref( self, parent_def_id: DefId, - parent_vis: &hir::Visibility, + parent_vis: &hir::Visibility<'_>, trait_item_ref: &hir::TraitItemRef, ) -> AssocItem { let def_id = self.hir().local_def_id(trait_item_ref.id.hir_id); @@ -2783,7 +2783,7 @@ impl<'tcx> TyCtxt<'tcx> { fn associated_item_from_impl_item_ref( self, parent_def_id: DefId, - impl_item_ref: &hir::ImplItemRef, + impl_item_ref: &hir::ImplItemRef<'_>, ) -> AssocItem { let def_id = self.hir().local_def_id(impl_item_ref.id.hir_id); let (kind, has_self) = match impl_item_ref.kind { diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 900c425fac2..afd1b690232 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -694,7 +694,7 @@ pub fn object_region_bounds<'tcx>( /// Find the span of a generic bound affecting an associated type. fn get_generic_bound_spans( - generics: &hir::Generics, + generics: &hir::Generics<'_>, trait_name: Option<&Ident>, assoc_item_name: Ident, ) -> Vec<Span> { @@ -729,7 +729,7 @@ fn get_generic_bound_spans( bounds } -fn is_self_path(kind: &hir::TyKind) -> bool { +fn is_self_path(kind: &hir::TyKind<'_>) -> bool { match kind { hir::TyKind::Path(hir::QPath::Resolved(None, path)) => { let mut s = path.segments.iter(); |
