From c9d26c18ea6010082851ce26dcf951a8f89be3c4 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:16:05 +0000 Subject: [PATCH 1/8] compiler: Rename `GenericArgKind::{Lifetime => Region}` --- .../src/diagnostics/region_name.rs | 6 ++-- .../rustc_borrowck/src/region_infer/mod.rs | 2 +- .../src/region_infer/opaque_types.rs | 4 +-- .../src/type_check/constraint_conversion.rs | 2 +- .../src/transform/check_consts/check.rs | 2 +- .../rustc_const_eval/src/util/type_name.rs | 2 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 4 +-- .../src/outlives/implicit_infer.rs | 2 +- .../rustc_hir_analysis/src/outlives/mod.rs | 2 +- .../rustc_hir_analysis/src/outlives/utils.rs | 2 +- .../src/variance/constraints.rs | 16 +++++------ .../rustc_hir_typeck/src/method/suggest.rs | 2 +- compiler/rustc_infer/src/infer/at.rs | 8 +++--- .../src/infer/canonical/query_response.rs | 12 ++++---- .../src/infer/canonical/substitute.rs | 10 +++---- .../infer/error_reporting/need_type_info.rs | 8 +++--- compiler/rustc_infer/src/infer/mod.rs | 2 +- .../rustc_infer/src/infer/opaque_types.rs | 2 +- .../src/infer/outlives/components.rs | 14 +++++----- .../src/infer/outlives/obligations.rs | 4 +-- compiler/rustc_middle/src/infer/canonical.rs | 4 +-- .../rustc_middle/src/mir/interpret/mod.rs | 2 +- compiler/rustc_middle/src/ty/fast_reject.rs | 2 +- compiler/rustc_middle/src/ty/flags.rs | 2 +- compiler/rustc_middle/src/ty/impls_ty.rs | 4 +-- compiler/rustc_middle/src/ty/opaque_types.rs | 2 +- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- compiler/rustc_middle/src/ty/relate.rs | 6 ++-- compiler/rustc_middle/src/ty/subst.rs | 28 +++++++++---------- .../rustc_middle/src/ty/typeck_results.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 10 +++---- compiler/rustc_middle/src/ty/walk.rs | 2 +- .../src/thir/pattern/const_to_pat.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- compiler/rustc_symbol_mangling/src/legacy.rs | 2 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 2 +- compiler/rustc_symbol_mangling/src/v0.rs | 8 +++--- .../src/solve/eval_ctxt/canonical.rs | 4 +-- .../src/traits/project.rs | 2 +- .../rustc_trait_selection/src/traits/wf.rs | 6 ++-- compiler/rustc_traits/src/chalk/db.rs | 2 +- compiler/rustc_traits/src/chalk/lowering.rs | 4 +-- .../src/implied_outlives_bounds.rs | 2 +- compiler/rustc_ty_utils/src/ty.rs | 4 +-- 44 files changed, 104 insertions(+), 108 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index f69c4829ae299..d71513871a03a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -597,7 +597,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { ) -> Option<&'hir hir::Lifetime> { for (kind, hir_arg) in iter::zip(substs, args.args) { match (kind.unpack(), hir_arg) { - (GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => { + (GenericArgKind::Region(r), hir::GenericArg::Lifetime(lt)) => { if r.as_var() == needle_fr { return Some(lt); } @@ -613,9 +613,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> { } ( - GenericArgKind::Lifetime(_) - | GenericArgKind::Type(_) - | GenericArgKind::Const(_), + GenericArgKind::Region(_) | GenericArgKind::Type(_) | GenericArgKind::Const(_), _, ) => { // HIR lowering sometimes doesn't catch this in erroneous diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 729f3dbff3b46..161db0ac14d09 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1114,7 +1114,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { let substs = std::iter::zip(substs, tcx.variances_of(def_id)).map(|(arg, v)| { match (arg.unpack(), v) { - (ty::GenericArgKind::Lifetime(_), ty::Bivariant) => { + (ty::GenericArgKind::Region(_), ty::Bivariant) => { tcx.lifetimes.re_static.into() } _ => arg.fold_with(self), diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 2b16655cf7d5a..975b9680210c3 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -367,8 +367,8 @@ fn check_opaque_type_parameter_valid( for (i, arg) in opaque_type_key.substs.iter().enumerate() { let arg_is_param = match arg.unpack() { GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)), - GenericArgKind::Lifetime(lt) => { - matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_)) + GenericArgKind::Region(re) => { + matches!(*re, ty::ReEarlyBound(_) | ty::ReFree(_)) } GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)), }; diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs index 71eae7b27d1db..ecc5b6a661dff 100644 --- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs +++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs @@ -141,7 +141,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { let ty::OutlivesPredicate(k1, r2) = predicate; match k1.unpack() { - GenericArgKind::Lifetime(r1) => { + GenericArgKind::Region(r1) => { let r1_vid = self.to_region_vid(r1); let r2_vid = self.to_region_vid(r2); self.add_outlives(r1_vid, r2_vid, constraint_category); diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 9dad947905397..86d2dbbf0a839 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -346,7 +346,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { // No constraints on lifetimes or constants, except potentially // constants' types, but `walk` will get to them as well. - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => continue, }; match *ty.kind() { diff --git a/compiler/rustc_const_eval/src/util/type_name.rs b/compiler/rustc_const_eval/src/util/type_name.rs index 4e80a28518668..7aba94f7de08d 100644 --- a/compiler/rustc_const_eval/src/util/type_name.rs +++ b/compiler/rustc_const_eval/src/util/type_name.rs @@ -131,7 +131,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { ) -> Result { self = print_prefix(self)?; let args = - args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_))); + args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Region(_))); if args.clone().next().is_some() { self.generic_delimiters(|cx| cx.comma_sep(args)) } else { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 53197bc849106..a0e8ecef9fb8c 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -718,8 +718,8 @@ impl<'tcx> TypeVisitor> for GATSubstCollector<'tcx> { ty::Alias(ty::Projection, p) if p.def_id == self.gat => { for (idx, subst) in p.substs.iter().enumerate() { match subst.unpack() { - GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => { - self.regions.insert((lt, idx)); + GenericArgKind::Region(re) if !re.is_late_bound() => { + self.regions.insert((re, idx)); } GenericArgKind::Type(t) => { self.types.insert((t, idx)); diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index d53c429ca15ca..013a2cd78c3a3 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -99,7 +99,7 @@ fn insert_required_predicates_to_be_wf<'tcx>( // No predicates from lifetimes or constants, except potentially // constants' types, but `walk` will get to them as well. - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => continue, }; match *ty.kind() { diff --git a/compiler/rustc_hir_analysis/src/outlives/mod.rs b/compiler/rustc_hir_analysis/src/outlives/mod.rs index da72d2584e335..0083dd7b792c3 100644 --- a/compiler/rustc_hir_analysis/src/outlives/mod.rs +++ b/compiler/rustc_hir_analysis/src/outlives/mod.rs @@ -105,7 +105,7 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> { ty::Clause::TypeOutlives(ty::OutlivesPredicate(ty1, *region2)), span, )), - GenericArgKind::Lifetime(region1) => Some(( + GenericArgKind::Region(region1) => Some(( ty::Clause::RegionOutlives(ty::OutlivesPredicate(region1, *region2)), span, )), diff --git a/compiler/rustc_hir_analysis/src/outlives/utils.rs b/compiler/rustc_hir_analysis/src/outlives/utils.rs index c5c5f63a108b3..136f9a772c771 100644 --- a/compiler/rustc_hir_analysis/src/outlives/utils.rs +++ b/compiler/rustc_hir_analysis/src/outlives/utils.rs @@ -127,7 +127,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>( } } - GenericArgKind::Lifetime(r) => { + GenericArgKind::Region(r) => { if !is_free_region(r) { return; } diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index 408bec71ee015..df3469c3577da 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -186,12 +186,12 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { for k in substs { match k.unpack() { - GenericArgKind::Lifetime(lt) => { - self.add_constraints_from_region(current, lt, variance_i) + GenericArgKind::Region(re) => { + self.add_constraints_from_region(current, re, variance_i) } GenericArgKind::Type(ty) => self.add_constraints_from_ty(current, ty, variance_i), - GenericArgKind::Const(val) => { - self.add_constraints_from_const(current, val, variance_i) + GenericArgKind::Const(ct) => { + self.add_constraints_from_const(current, ct, variance_i) } } } @@ -345,13 +345,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { variance_decl, variance_i ); match k.unpack() { - GenericArgKind::Lifetime(lt) => { - self.add_constraints_from_region(current, lt, variance_i) + GenericArgKind::Region(re) => { + self.add_constraints_from_region(current, re, variance_i) } GenericArgKind::Type(ty) => self.add_constraints_from_ty(current, ty, variance_i), - GenericArgKind::Const(val) => { - self.add_constraints_from_const(current, val, variance) - } + GenericArgKind::Const(ct) => self.add_constraints_from_const(current, ct, variance), } } } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index db1f10f645fd4..442a8068661cc 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1315,7 +1315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if !arg.is_suggestable(self.tcx, true) { has_unsuggestable_args = true; match arg.unpack() { - GenericArgKind::Lifetime(_) => self + GenericArgKind::Region(_) => self .next_region_var(RegionVariableOrigin::MiscVariable( rustc_span::DUMMY_SP, )) diff --git a/compiler/rustc_infer/src/infer/at.rs b/compiler/rustc_infer/src/infer/at.rs index d240d8e491faf..0ee845f913be2 100644 --- a/compiler/rustc_infer/src/infer/at.rs +++ b/compiler/rustc_infer/src/infer/at.rs @@ -407,15 +407,15 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> { TypeTrace { cause: cause.clone(), values: match (a.unpack(), b.unpack()) { - (Lifetime(a), Lifetime(b)) => Regions(ExpectedFound::new(a_is_expected, a, b)), + (Region(a), Region(b)) => Regions(ExpectedFound::new(a_is_expected, a, b)), (Type(a), Type(b)) => Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())), (Const(a), Const(b)) => { Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())) } - (Lifetime(_), Type(_) | Const(_)) - | (Type(_), Lifetime(_) | Const(_)) - | (Const(_), Lifetime(_) | Type(_)) => { + (Region(_), Type(_) | Const(_)) + | (Type(_), Region(_) | Const(_)) + | (Const(_), Region(_) | Type(_)) => { bug!("relating different kinds: {a:?} {b:?}") } }, diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index 257d36259291e..a49fb7d8443e5 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -267,13 +267,13 @@ impl<'tcx> InferCtxt<'tcx> { v.var_values[BoundVar::new(index)] }); match (original_value.unpack(), result_value.unpack()) { - (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2)) + (GenericArgKind::Region(re1), GenericArgKind::Region(re2)) if re1.is_erased() && re2.is_erased() => { // No action needed. } - (GenericArgKind::Lifetime(v_o), GenericArgKind::Lifetime(v_r)) => { + (GenericArgKind::Region(v_o), GenericArgKind::Region(v_r)) => { // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`. if v_o != v_r { output_query_region_constraints @@ -456,7 +456,7 @@ impl<'tcx> InferCtxt<'tcx> { opt_values[b.var] = Some(*original_value); } } - GenericArgKind::Lifetime(result_value) => { + GenericArgKind::Region(result_value) => { // e.g., here `result_value` might be `'?1` in the example above... if let ty::ReLateBound(debruijn, br) = *result_value { // ... in which case we would set `canonical_vars[0]` to `Some('static)`. @@ -568,7 +568,7 @@ impl<'tcx> InferCtxt<'tcx> { let ty::OutlivesPredicate(k1, r2) = predicate; let atom = match k1.unpack() { - GenericArgKind::Lifetime(r1) => { + GenericArgKind::Region(r1) => { ty::PredicateKind::Clause(ty::Clause::RegionOutlives(ty::OutlivesPredicate(r1, r2))) } GenericArgKind::Type(t1) => { @@ -607,12 +607,12 @@ impl<'tcx> InferCtxt<'tcx> { .into_obligations(), ); } - (GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2)) + (GenericArgKind::Region(re1), GenericArgKind::Region(re2)) if re1.is_erased() && re2.is_erased() => { // no action needed } - (GenericArgKind::Lifetime(v1), GenericArgKind::Lifetime(v2)) => { + (GenericArgKind::Region(v1), GenericArgKind::Region(v2)) => { obligations.extend( self.at(cause, param_env) .eq(DefineOpaqueTypes::Yes, v1, v2)? diff --git a/compiler/rustc_infer/src/infer/canonical/substitute.rs b/compiler/rustc_infer/src/infer/canonical/substitute.rs index cac3b40725158..08d0c1be6b830 100644 --- a/compiler/rustc_infer/src/infer/canonical/substitute.rs +++ b/compiler/rustc_infer/src/infer/canonical/substitute.rs @@ -74,17 +74,17 @@ where value } else { let delegate = FnMutDelegate { - regions: &mut |br: ty::BoundRegion| match var_values[br.var].unpack() { - GenericArgKind::Lifetime(l) => l, - r => bug!("{:?} is a region but value is {:?}", br, r), + regions: &mut |bound_re: ty::BoundRegion| match var_values[bound_re.var].unpack() { + GenericArgKind::Region(re) => re, + v => bug!("{bound_re:?} is a region but value is {v:?}"), }, types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].unpack() { GenericArgKind::Type(ty) => ty, - r => bug!("{:?} is a type but value is {:?}", bound_ty, r), + v => bug!("{bound_ty:?} is a type but value is {v:?}"), }, consts: &mut |bound_ct: ty::BoundVar, _| match var_values[bound_ct].unpack() { GenericArgKind::Const(ct) => ct, - c => bug!("{:?} is a const but value is {:?}", bound_ct, c), + v => bug!("{bound_ct:?} is a const but value is {v:?}"), }, }; diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index 58e3159a4e217..9eff26e49cfb6 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -329,7 +329,7 @@ impl<'tcx> InferCtxt<'tcx> { } } } - GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"), + GenericArgKind::Region(_) => bug!("unexpected region"), } } @@ -486,7 +486,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } match arg.unpack() { - GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"), + GenericArgKind::Region(_) => bug!("unexpected region"), GenericArgKind::Type(_) => self .next_ty_var(TypeVariableOrigin { span: rustc_span::DUMMY_SP, @@ -756,7 +756,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { impl<'tcx> CostCtxt<'tcx> { fn arg_cost(self, arg: GenericArg<'tcx>) -> usize { match arg.unpack() { - GenericArgKind::Lifetime(_) => 0, // erased + GenericArgKind::Region(_) => 0, // erased GenericArgKind::Type(ty) => self.ty_cost(ty), GenericArgKind::Const(_) => 3, // some non-zero value } @@ -884,7 +884,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> { return true; } match inner.unpack() { - GenericArgKind::Lifetime(_) => {} + GenericArgKind::Region(_) => {} GenericArgKind::Type(ty) => { if matches!( ty.kind(), diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index f263a0773e4e1..def7a6542212c 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1740,7 +1740,7 @@ impl<'tcx> TyOrConstInferVar<'tcx> { match arg.unpack() { GenericArgKind::Type(ty) => Self::maybe_from_ty(ty), GenericArgKind::Const(ct) => Self::maybe_from_const(ct), - GenericArgKind::Lifetime(_) => None, + GenericArgKind::Region(_) => None, } } diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 680465bdab690..e8bc8e4fe9d16 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -351,7 +351,7 @@ impl<'tcx> InferCtxt<'tcx> { .enumerate() .filter(|(i, _)| variances[*i] == ty::Variance::Invariant) .filter_map(|(_, arg)| match arg.unpack() { - GenericArgKind::Lifetime(r) => Some(r), + GenericArgKind::Region(r) => Some(r), GenericArgKind::Type(_) | GenericArgKind::Const(_) => None, }) .chain(std::iter::once(self.tcx.lifetimes.re_static)) diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index cb63d2f18b634..8c8c324ebdd60 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -84,7 +84,7 @@ fn compute_components<'tcx>( GenericArgKind::Type(ty) => { compute_components(tcx, ty, out, visited); } - GenericArgKind::Lifetime(_) => {} + GenericArgKind::Region(_) => {} GenericArgKind::Const(_) => { compute_components_recursive(tcx, child, out, visited); } @@ -212,10 +212,10 @@ pub(super) fn compute_alias_components_recursive<'tcx>( GenericArgKind::Type(ty) => { compute_components(tcx, ty, out, visited); } - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Region(re) => { // Ignore late-bound regions. - if !lt.is_late_bound() { - out.push(Component::Region(lt)); + if !re.is_late_bound() { + out.push(Component::Region(re)); } } GenericArgKind::Const(_) => { @@ -240,10 +240,10 @@ fn compute_components_recursive<'tcx>( GenericArgKind::Type(ty) => { compute_components(tcx, ty, out, visited); } - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Region(re) => { // Ignore late-bound regions. - if !lt.is_late_bound() { - out.push(Component::Region(lt)); + if !re.is_late_bound() { + out.push(Component::Region(re)); } } GenericArgKind::Const(_) => { diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 2f5e2e417a6fd..0760c82d55279 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -408,7 +408,7 @@ where let constraint = origin.to_constraint_category(); for (index, k) in substs.iter().enumerate() { match k.unpack() { - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Region(re) => { let variance = if let Some(variances) = opt_variances { variances[index] } else { @@ -418,7 +418,7 @@ where self.delegate.push_sub_region_constraint( origin.clone(), region, - lt, + re, constraint, ); } diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs index c4e41e00520e6..b01c4128a9b54 100644 --- a/compiler/rustc_middle/src/infer/canonical.rs +++ b/compiler/rustc_middle/src/infer/canonical.rs @@ -69,7 +69,7 @@ pub struct CanonicalVarValues<'tcx> { impl CanonicalVarValues<'_> { pub fn is_identity(&self) -> bool { self.var_values.iter().enumerate().all(|(bv, arg)| match arg.unpack() { - ty::GenericArgKind::Lifetime(r) => { + ty::GenericArgKind::Region(r) => { matches!(*r, ty::ReLateBound(ty::INNERMOST, br) if br.var.as_usize() == bv) } ty::GenericArgKind::Type(ty) => { @@ -83,7 +83,7 @@ impl CanonicalVarValues<'_> { pub fn is_identity_modulo_regions(&self) -> bool { self.var_values.iter().enumerate().all(|(bv, arg)| match arg.unpack() { - ty::GenericArgKind::Lifetime(_) => true, + ty::GenericArgKind::Region(_) => true, ty::GenericArgKind::Type(ty) => { matches!(*ty.kind(), ty::Bound(ty::INNERMOST, bt) if bt.var.as_usize() == bv) } diff --git a/compiler/rustc_middle/src/mir/interpret/mod.rs b/compiler/rustc_middle/src/mir/interpret/mod.rs index 1f8b650e34cfc..0b3f7e1297fdf 100644 --- a/compiler/rustc_middle/src/mir/interpret/mod.rs +++ b/compiler/rustc_middle/src/mir/interpret/mod.rs @@ -534,7 +534,7 @@ impl<'tcx> TyCtxt<'tcx> { let is_generic = instance .substs .into_iter() - .any(|kind| !matches!(kind.unpack(), GenericArgKind::Lifetime(_))); + .any(|kind| !matches!(kind.unpack(), GenericArgKind::Region(_))); if is_generic { // Get a fresh ID. let mut alloc_map = self.alloc_map.lock(); diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 76f61d9ac9c2d..ba29f5807bd17 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -196,7 +196,7 @@ impl DeepRejectCtxt { iter::zip(obligation_substs, impl_substs).all(|(obl, imp)| { match (obl.unpack(), imp.unpack()) { // We don't fast reject based on regions for now. - (GenericArgKind::Lifetime(_), GenericArgKind::Lifetime(_)) => true, + (GenericArgKind::Region(_), GenericArgKind::Region(_)) => true, (GenericArgKind::Type(obl), GenericArgKind::Type(imp)) => { self.types_may_unify(obl, imp) } diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 68002bfcfbd13..f79657cbfddd6 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -380,7 +380,7 @@ impl FlagComputation { for kind in substs { match kind.unpack() { GenericArgKind::Type(ty) => self.add_ty(ty), - GenericArgKind::Lifetime(lt) => self.add_region(lt), + GenericArgKind::Region(re) => self.add_region(re), GenericArgKind::Const(ct) => self.add_const(ct), } } diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 4c7822acdf785..888ffe2e649d8 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -93,9 +93,9 @@ impl<'a, 'tcx> HashStable> for ty::subst::GenericArgKin 0xF3u8.hash_stable(hcx, hasher); ct.hash_stable(hcx, hasher); } - ty::subst::GenericArgKind::Lifetime(lt) => { + ty::subst::GenericArgKind::Region(re) => { 0xF5u8.hash_stable(hcx, hasher); - lt.hash_stable(hcx, hasher); + re.hash_stable(hcx, hasher); } } } diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 751f3066c9cc6..0fa1e0c7a318d 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -123,7 +123,7 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { } match self.map.get(&r.into()).map(|k| k.unpack()) { - Some(GenericArgKind::Lifetime(r1)) => r1, + Some(GenericArgKind::Region(r1)) => r1, Some(u) => panic!("region mapped to unexpected kind: {:?}", u), None if self.do_not_error => self.tcx.lifetimes.re_static, None => { diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index af76cf7cc4e0d..fca6cd16e3606 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2862,7 +2862,7 @@ define_print_and_forward_display! { GenericArg<'tcx> { match self.unpack() { - GenericArgKind::Lifetime(lt) => p!(print(lt)), + GenericArgKind::Region(re) => p!(print(re)), GenericArgKind::Type(ty) => p!(print(ty)), GenericArgKind::Const(ct) => p!(print(ct)), } diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index c6d10f4741aff..874993803672e 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -782,8 +782,8 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> { b: GenericArg<'tcx>, ) -> RelateResult<'tcx, GenericArg<'tcx>> { match (a.unpack(), b.unpack()) { - (GenericArgKind::Lifetime(a_lt), GenericArgKind::Lifetime(b_lt)) => { - Ok(relation.relate(a_lt, b_lt)?.into()) + (GenericArgKind::Region(a_re), GenericArgKind::Region(b_re)) => { + Ok(relation.relate(a_re, b_re)?.into()) } (GenericArgKind::Type(a_ty), GenericArgKind::Type(b_ty)) => { Ok(relation.relate(a_ty, b_ty)?.into()) @@ -791,7 +791,7 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> { (GenericArgKind::Const(a_ct), GenericArgKind::Const(b_ct)) => { Ok(relation.relate(a_ct, b_ct)?.into()) } - (GenericArgKind::Lifetime(unpacked), x) => { + (GenericArgKind::Region(unpacked), x) => { bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) } (GenericArgKind::Type(unpacked), x) => { diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 3e1b0706f6688..36c849aa4e356 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -50,7 +50,7 @@ const CONST_TAG: usize = 0b10; #[derive(Debug, TyEncodable, TyDecodable, PartialEq, Eq, PartialOrd, Ord)] pub enum GenericArgKind<'tcx> { - Lifetime(ty::Region<'tcx>), + Region(ty::Region<'tcx>), Type(Ty<'tcx>), Const(ty::Const<'tcx>), } @@ -71,10 +71,10 @@ impl<'tcx> GenericArgKind<'tcx> { #[inline] fn pack(self) -> GenericArg<'tcx> { let (tag, ptr) = match self { - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Region(re) => { // Ensure we can use the tag bits. - assert_eq!(mem::align_of_val(&*lt.0.0) & TAG_MASK, 0); - (REGION_TAG, lt.0.0 as *const ty::RegionKind<'tcx> as usize) + assert_eq!(mem::align_of_val(&*re.0.0) & TAG_MASK, 0); + (REGION_TAG, re.0.0 as *const ty::RegionKind<'tcx> as usize) } GenericArgKind::Type(ty) => { // Ensure we can use the tag bits. @@ -95,7 +95,7 @@ impl<'tcx> GenericArgKind<'tcx> { impl<'tcx> fmt::Debug for GenericArg<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.unpack() { - GenericArgKind::Lifetime(lt) => lt.fmt(f), + GenericArgKind::Region(re) => re.fmt(f), GenericArgKind::Type(ty) => ty.fmt(f), GenericArgKind::Const(ct) => ct.fmt(f), } @@ -117,7 +117,7 @@ impl<'tcx> PartialOrd for GenericArg<'tcx> { impl<'tcx> From> for GenericArg<'tcx> { #[inline] fn from(r: ty::Region<'tcx>) -> GenericArg<'tcx> { - GenericArgKind::Lifetime(r).pack() + GenericArgKind::Region(r).pack() } } @@ -153,7 +153,7 @@ impl<'tcx> GenericArg<'tcx> { // and this is just going in the other direction. unsafe { match ptr & TAG_MASK { - REGION_TAG => GenericArgKind::Lifetime(ty::Region(Interned::new_unchecked( + REGION_TAG => GenericArgKind::Region(ty::Region(Interned::new_unchecked( &*((ptr & !TAG_MASK) as *const ty::RegionKind<'tcx>), ))), TYPE_TAG => GenericArgKind::Type(Ty(Interned::new_unchecked( @@ -178,7 +178,7 @@ impl<'tcx> GenericArg<'tcx> { #[inline] pub fn as_region(self) -> Option> { match self.unpack() { - GenericArgKind::Lifetime(re) => Some(re), + GenericArgKind::Region(re) => Some(re), _ => None, } } @@ -210,7 +210,7 @@ impl<'tcx> GenericArg<'tcx> { pub fn is_non_region_infer(self) -> bool { match self.unpack() { - GenericArgKind::Lifetime(_) => false, + GenericArgKind::Region(_) => false, GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(), GenericArgKind::Const(ct) => ct.is_ct_infer(), } @@ -222,7 +222,7 @@ impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a> { fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option { match self.unpack() { - GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()), + GenericArgKind::Region(re) => tcx.lift(re).map(|re| re.into()), GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()), GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()), } @@ -235,7 +235,7 @@ impl<'tcx> TypeFoldable> for GenericArg<'tcx> { folder: &mut F, ) -> Result { match self.unpack() { - GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into), + GenericArgKind::Region(re) => re.try_fold_with(folder).map(Into::into), GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into), GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into), } @@ -245,7 +245,7 @@ impl<'tcx> TypeFoldable> for GenericArg<'tcx> { impl<'tcx> TypeVisitable> for GenericArg<'tcx> { fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { match self.unpack() { - GenericArgKind::Lifetime(lt) => lt.visit_with(visitor), + GenericArgKind::Region(re) => re.visit_with(visitor), GenericArgKind::Type(ty) => ty.visit_with(visitor), GenericArgKind::Const(ct) => ct.visit_with(visitor), } @@ -402,7 +402,7 @@ impl<'tcx> InternalSubsts<'tcx> { &'tcx self, ) -> impl DoubleEndedIterator> + 'tcx { self.iter().filter_map(|k| match k.unpack() { - GenericArgKind::Lifetime(_) => None, + GenericArgKind::Region(_) => None, generic => Some(generic), }) } @@ -825,7 +825,7 @@ impl<'a, 'tcx> TypeFolder> for SubstFolder<'a, 'tcx> { ty::ReEarlyBound(data) => { let rk = self.substs.get(data.index as usize).map(|k| k.unpack()); match rk { - Some(GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt), + Some(GenericArgKind::Region(re)) => self.shift_region_through_binders(re), Some(other) => region_param_invalid(data, other), None => region_param_out_of_range(data, self.substs), } diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 47943b94c3b18..74e0675ac6bc3 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -675,7 +675,7 @@ impl<'tcx> CanonicalUserType<'tcx> { _ => false, }, - GenericArgKind::Lifetime(r) => match *r { + GenericArgKind::Region(r) => match *r { ty::ReLateBound(debruijn, br) => { // We only allow a `ty::INNERMOST` index in substitutions. assert_eq!(debruijn, ty::INNERMOST); diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index dbe2eebe33604..6bda778c2d2e0 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -430,7 +430,7 @@ impl<'tcx> TyCtxt<'tcx> { let result = iter::zip(item_substs, impl_substs) .filter(|&(_, k)| { match k.unpack() { - GenericArgKind::Lifetime(region) => match region.kind() { + GenericArgKind::Region(region) => match region.kind() { ty::ReEarlyBound(ref ebr) => { !impl_generics.region_param(ebr, self).pure_wrt_drop } @@ -466,13 +466,13 @@ impl<'tcx> TyCtxt<'tcx> { let mut seen = GrowableBitSet::default(); for arg in substs { match arg.unpack() { - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Region(re) => { if ignore_regions == IgnoreRegions::No { - let ty::ReEarlyBound(p) = lt.kind() else { - return Err(NotUniqueParam::NotParam(lt.into())) + let ty::ReEarlyBound(p) = re.kind() else { + return Err(NotUniqueParam::NotParam(re.into())) }; if !seen.insert(p.index) { - return Err(NotUniqueParam::DuplicateParam(lt.into())); + return Err(NotUniqueParam::DuplicateParam(re.into())); } } } diff --git a/compiler/rustc_middle/src/ty/walk.rs b/compiler/rustc_middle/src/ty/walk.rs index 04a635a68034d..c731218eed72a 100644 --- a/compiler/rustc_middle/src/ty/walk.rs +++ b/compiler/rustc_middle/src/ty/walk.rs @@ -203,7 +203,7 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>) stack.extend(sig.skip_binder().inputs().iter().copied().rev().map(|ty| ty.into())); } }, - GenericArgKind::Lifetime(_) => {} + GenericArgKind::Region(_) => {} GenericArgKind::Const(parent_ct) => { stack.push(parent_ct.ty().into()); match parent_ct.kind() { diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index c99fc73fe8a34..43f4967559028 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -204,7 +204,7 @@ impl<'tcx> ConstToPat<'tcx> { // not *yet* implement `PartialEq`. So for now we leave this here. has_impl || ty.walk().any(|t| match t.unpack() { - ty::subst::GenericArgKind::Lifetime(_) => false, + ty::subst::GenericArgKind::Region(_) => false, ty::subst::GenericArgKind::Type(t) => t.is_fn_ptr(), ty::subst::GenericArgKind::Const(_) => false, }) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 2ed628871d2d7..784e85b8147ff 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -636,7 +636,7 @@ fn check_type_length_limit<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { .flat_map(|arg| arg.walk()) .filter(|arg| match arg.unpack() { GenericArgKind::Type(_) | GenericArgKind::Const(_) => true, - GenericArgKind::Lifetime(_) => false, + GenericArgKind::Region(_) => false, }) .count(); debug!(" => type length={}", type_length); diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 6a0ca06f69caa..ffc5f349c6c79 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -355,7 +355,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> { self = print_prefix(self)?; let args = - args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_))); + args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Region(_))); if args.clone().next().is_some() { self.generic_delimiters(|cx| cx.comma_sep(args)) diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index a9152b8113f67..9fcaee3d5c169 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -323,7 +323,7 @@ fn encode_substs<'tcx>( s.push('I'); for subst in substs { match subst.unpack() { - GenericArgKind::Lifetime(region) => { + GenericArgKind::Region(region) => { s.push_str(&encode_region(tcx, region, dict, options)); } GenericArgKind::Type(ty) => { diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 2235524129e62..339f57d68d948 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -808,11 +808,11 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { ) -> Result { // Don't print any regions if they're all erased. let print_regions = args.iter().any(|arg| match arg.unpack() { - GenericArgKind::Lifetime(r) => !r.is_erased(), + GenericArgKind::Region(r) => !r.is_erased(), _ => false, }); let args = args.iter().cloned().filter(|arg| match arg.unpack() { - GenericArgKind::Lifetime(_) => print_regions, + GenericArgKind::Region(_) => print_regions, _ => true, }); @@ -824,8 +824,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { self = print_prefix(self)?; for arg in args { match arg.unpack() { - GenericArgKind::Lifetime(lt) => { - self = lt.print(self)?; + GenericArgKind::Region(re) => { + self = re.print(self)?; } GenericArgKind::Type(ty) => { self = ty.print(self)?; diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs index 23cf0f0c724ba..47545924a67d0 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs @@ -149,7 +149,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { opt_values[b.var] = Some(*original_value); } } - GenericArgKind::Lifetime(r) => { + GenericArgKind::Region(r) => { if let ty::ReLateBound(debruijn, br) = *r { assert_eq!(debruijn, ty::INNERMOST); opt_values[br.var] = Some(*original_value); @@ -217,7 +217,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { fn register_region_constraints(&mut self, region_constraints: &QueryRegionConstraints<'tcx>) { for &(ty::OutlivesPredicate(lhs, rhs), _) in ®ion_constraints.outlives { match lhs.unpack() { - GenericArgKind::Lifetime(lhs) => self.register_region_outlives(lhs, rhs), + GenericArgKind::Region(lhs) => self.register_region_outlives(lhs, rhs), GenericArgKind::Type(lhs) => self.register_ty_outlives(lhs, rhs), GenericArgKind::Const(_) => bug!("const outlives: {lhs:?}: {rhs:?}"), } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 5e042ffc60367..55923161be3da 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -2177,7 +2177,7 @@ fn check_substs_compatible<'tcx>( for (param, arg) in std::iter::zip(&generics.params, own_args) { match (¶m.kind, arg.unpack()) { (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_)) - | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_)) + | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Region(_)) | (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {} _ => return false, } diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 6808861d643ca..b7c48e5e8e533 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -55,7 +55,7 @@ pub fn obligations<'tcx>( .into() } // There is nothing we have to do for lifetimes. - GenericArgKind::Lifetime(..) => return Some(Vec::new()), + GenericArgKind::Region(..) => return Some(Vec::new()), }; let mut wf = WfPredicates { @@ -84,7 +84,7 @@ pub fn unnormalized_obligations<'tcx>( param_env: ty::ParamEnv<'tcx>, arg: GenericArg<'tcx>, ) -> Option>> { - if let ty::GenericArgKind::Lifetime(..) = arg.unpack() { + if let ty::GenericArgKind::Region(..) = arg.unpack() { return Some(vec![]); } @@ -472,7 +472,7 @@ impl<'tcx> WfPredicates<'tcx> { // No WF constraints for lifetimes being present, any outlives // obligations are handled by the parent (e.g. `ty::Ref`). - GenericArgKind::Lifetime(_) => continue, + GenericArgKind::Region(_) => continue, GenericArgKind::Const(ct) => { match ct.kind() { diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 9683e48478edc..baeff5484d1d1 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -751,7 +751,7 @@ fn binders_for<'tcx>( chalk_ir::VariableKinds::from_iter( interner, bound_vars.iter().map(|arg| match arg.unpack() { - ty::subst::GenericArgKind::Lifetime(_re) => chalk_ir::VariableKind::Lifetime, + ty::subst::GenericArgKind::Region(_re) => chalk_ir::VariableKind::Lifetime, ty::subst::GenericArgKind::Type(_ty) => { chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General) } diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 4d225e36b22cd..ce3b33de60a4c 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -209,7 +209,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData>> for ty::Predi GenericArgKind::Const(..) => { chalk_ir::GoalData::All(chalk_ir::Goals::empty(interner)) } - GenericArgKind::Lifetime(lt) => bug!("unexpected well formed predicate: {:?}", lt), + GenericArgKind::Region(re) => bug!("unexpected well formed predicate: {:?}", re), }, ty::PredicateKind::ObjectSafe(t) => chalk_ir::GoalData::DomainGoal( @@ -602,7 +602,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GenericArg>> for Generic ty::subst::GenericArgKind::Type(ty) => { chalk_ir::GenericArgData::Ty(ty.lower_into(interner)) } - ty::subst::GenericArgKind::Lifetime(lifetime) => { + ty::subst::GenericArgKind::Region(lifetime) => { chalk_ir::GenericArgData::Lifetime(lifetime.lower_into(interner)) } ty::subst::GenericArgKind::Const(c) => { diff --git a/compiler/rustc_traits/src/implied_outlives_bounds.rs b/compiler/rustc_traits/src/implied_outlives_bounds.rs index f5bba14d2fb9c..08a0ea5d0747a 100644 --- a/compiler/rustc_traits/src/implied_outlives_bounds.rs +++ b/compiler/rustc_traits/src/implied_outlives_bounds.rs @@ -144,7 +144,7 @@ fn compute_implied_outlives_bounds<'tcx>( let implied_bounds = outlives_bounds .into_iter() .flat_map(|ty::OutlivesPredicate(a, r_b)| match a.unpack() { - ty::GenericArgKind::Lifetime(r_a) => vec![OutlivesBound::RegionSubRegion(r_b, r_a)], + ty::GenericArgKind::Region(r_a) => vec![OutlivesBound::RegionSubRegion(r_b, r_a)], ty::GenericArgKind::Type(ty_a) => { let ty_a = ocx.infcx.resolve_vars_if_possible(ty_a); let mut components = smallvec![]; diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index cb06c7acff02a..0112d18af1105 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -436,7 +436,7 @@ fn well_formed_types_in_env(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::List None, + GenericArgKind::Region(_) => None, // FIXME(eddyb) support const generics in Chalk GenericArgKind::Const(_) => None, @@ -532,7 +532,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BitSet None, + ty::GenericArgKind::Region(_) => None, ty::GenericArgKind::Const(ct) => match ct.kind() { ty::ConstKind::Param(p) => Some(p.index), From d27d846bd10e194aee6ea01f67ec32a84ae864b7 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:16:44 +0000 Subject: [PATCH 2/8] librustdoc: use `GenericArgKind::Region`'s new name --- src/librustdoc/clean/utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index cca50df0db213..1726d0cbd0cc7 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -83,8 +83,8 @@ pub(crate) fn substs_to_args<'tcx>( 0 })); ret_val.extend(substs.iter().filter_map(|kind| match kind.skip_binder().unpack() { - GenericArgKind::Lifetime(lt) => { - Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided()))) + GenericArgKind::Region(re) => { + Some(GenericArg::Lifetime(clean_middle_region(re).unwrap_or(Lifetime::elided()))) } GenericArgKind::Type(_) if skip_first => { skip_first = false; From 38c1caf3087cf99e9dcaadf866a128523a822636 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:17:02 +0000 Subject: [PATCH 3/8] clippy: use `GenericArgKind::Region`'s new name --- src/tools/clippy/clippy_lints/src/let_underscore.rs | 2 +- .../clippy/clippy_lints/src/methods/unnecessary_sort_by.rs | 2 +- .../clippy/clippy_lints/src/methods/unnecessary_to_owned.rs | 2 +- .../clippy/clippy_lints/src/non_send_fields_in_send_ty.rs | 2 +- src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs | 2 +- src/tools/clippy/clippy_lints/src/returns.rs | 2 +- src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs | 2 +- src/tools/clippy/clippy_utils/src/ty.rs | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/let_underscore.rs b/src/tools/clippy/clippy_lints/src/let_underscore.rs index 51b5de27de89b..151c190cbcc82 100644 --- a/src/tools/clippy/clippy_lints/src/let_underscore.rs +++ b/src/tools/clippy/clippy_lints/src/let_underscore.rs @@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { let init_ty = cx.typeck_results().expr_ty(init); let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() { GenericArgKind::Type(inner_ty) => SYNC_GUARD_PATHS.iter().any(|path| match_type(cx, inner_ty, path)), - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => false, }); if contains_sync_guard { span_lint_and_help( diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs index 67618f7038add..cb85bc578714d 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_sort_by.rs @@ -172,7 +172,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { let ty = cx.typeck_results().expr_ty(expr); - matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_))) + matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Region(_))) } pub(super) fn check<'tcx>( diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index 4c4c003ca4691..59282eb22e4d3 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -458,7 +458,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty< } fn has_lifetime(ty: Ty<'_>) -> bool { - ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Lifetime(_))) + ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Region(_))) } /// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`. diff --git a/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs b/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs index 839c3a3815c29..bb2620764ded5 100644 --- a/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs +++ b/src/tools/clippy/clippy_lints/src/non_send_fields_in_send_ty.rs @@ -212,7 +212,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t substs.iter().all(|generic_arg| match generic_arg.unpack() { GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait), // Lifetimes and const generics are not solid part of ADT and ignored - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => true, }) } else { false diff --git a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs index 8b77a5c99f767..ffe2ed2ed99cd 100644 --- a/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs @@ -385,7 +385,7 @@ fn has_matching_substs(kind: FnKind, substs: SubstsRef<'_>) -> bool { match kind { FnKind::Fn => true, FnKind::TraitFn => substs.iter().enumerate().all(|(idx, subst)| match subst.unpack() { - GenericArgKind::Lifetime(_) => true, + GenericArgKind::Region(_) => true, GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx), GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx), }), diff --git a/src/tools/clippy/clippy_lints/src/returns.rs b/src/tools/clippy/clippy_lints/src/returns.rs index df126d7617ebe..13d68667735c4 100644 --- a/src/tools/clippy/clippy_lints/src/returns.rs +++ b/src/tools/clippy/clippy_lints/src/returns.rs @@ -333,7 +333,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) .skip_binder() .output() .walk() - .any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_))) + .any(|arg| matches!(arg.unpack(), GenericArgKind::Region(_))) { ControlFlow::Break(()) } else { diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 354b6d71aa466..ba2c268efaee9 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -77,7 +77,7 @@ fn check_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) -> McfResult { // No constraints on lifetimes or constants, except potentially // constants' types, but `walk` will get to them as well. - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => continue, }; match ty.kind() { diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 8b996c188161d..3bcfe8f994fca 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -59,7 +59,7 @@ pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool pub fn contains_adt_constructor<'tcx>(ty: Ty<'tcx>, adt: AdtDef<'tcx>) -> bool { ty.walk().any(|inner| match inner.unpack() { GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt), - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => false, }) } @@ -121,7 +121,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<' false }, - GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false, + GenericArgKind::Region(_) | GenericArgKind::Const(_) => false, }) } @@ -1070,7 +1070,7 @@ pub fn make_projection<'tcx>( .find(|(_, (param, arg))| { !matches!( (param, arg), - (ty::GenericParamDefKind::Lifetime, GenericArgKind::Lifetime(_)) + (ty::GenericParamDefKind::Lifetime, GenericArgKind::Region(_)) | (ty::GenericParamDefKind::Type { .. }, GenericArgKind::Type(_)) | (ty::GenericParamDefKind::Const { .. }, GenericArgKind::Const(_)) ) From 4e5e61a59ad1121b660adfb48deb809fe3482213 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:28:47 +0000 Subject: [PATCH 4/8] compiler: Rename `GenericParamDefKind::{Lifetime => Region}` --- .../src/coverageinfo/mod.rs | 2 +- .../src/astconv/generics.rs | 4 ++-- .../rustc_hir_analysis/src/astconv/mod.rs | 10 ++++----- .../src/check/compare_impl_item.rs | 10 ++++----- .../rustc_hir_analysis/src/check/wfcheck.rs | 6 ++--- .../src/collect/generics_of.rs | 2 +- .../src/collect/resolve_bound_vars.rs | 2 +- .../rustc_hir_analysis/src/impl_wf_check.rs | 2 +- .../rustc_hir_analysis/src/variance/mod.rs | 2 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 4 ++-- .../rustc_hir_typeck/src/method/confirm.rs | 2 +- compiler/rustc_hir_typeck/src/method/mod.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 2 +- .../src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_infer/src/infer/mod.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 4 ++-- compiler/rustc_middle/src/ty/generics.rs | 22 +++++++++---------- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- .../rustc_monomorphize/src/polymorphize.rs | 2 +- compiler/rustc_privacy/src/lib.rs | 4 ++-- .../error_reporting/on_unimplemented.rs | 4 ++-- .../src/traits/error_reporting/suggestions.rs | 2 +- .../src/traits/project.rs | 2 +- .../src/traits/select/confirmation.rs | 2 +- .../src/traits/vtable.rs | 2 +- compiler/rustc_traits/src/chalk/db.rs | 2 +- 27 files changed, 52 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index 3dc0ac03312e9..eb8d911e5b563 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -187,7 +187,7 @@ fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance< let instance = Instance::new( def_id, InternalSubsts::for_item(tcx, def_id, |param, _| { - if let ty::GenericParamDefKind::Lifetime = param.kind { + if let ty::GenericParamDefKind::Region = param.kind { tcx.lifetimes.re_erased.into() } else { tcx.mk_param_from_def(param) diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index 3b5c67de2390e..c8b0cebd37a12 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -242,7 +242,7 @@ pub fn create_substs_for_generic_args<'tcx, 'a>( match (args.peek(), params.peek()) { (Some(&arg), Some(¶m)) => { match (arg, ¶m.kind, arg_count.explicit_late_bound) { - (GenericArg::Lifetime(_), GenericParamDefKind::Lifetime, _) + (GenericArg::Lifetime(_), GenericParamDefKind::Region, _) | ( GenericArg::Type(_) | GenericArg::Infer(_), GenericParamDefKind::Type { .. }, @@ -259,7 +259,7 @@ pub fn create_substs_for_generic_args<'tcx, 'a>( } ( GenericArg::Infer(_) | GenericArg::Type(_) | GenericArg::Const(_), - GenericParamDefKind::Lifetime, + GenericParamDefKind::Region, _, ) => { // We expected a lifetime argument, but got a type or const diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 7eb12d380a769..027121f80b9f9 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -437,7 +437,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { }; match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Region, GenericArg::Lifetime(lt)) => { self.astconv.ast_region_to_region(lt, Some(param)).into() } (&GenericParamDefKind::Type { has_default, .. }, GenericArg::Type(ty)) => { @@ -481,7 +481,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) -> subst::GenericArg<'tcx> { let tcx = self.astconv.tcx(); match param.kind { - GenericParamDefKind::Lifetime => self + GenericParamDefKind::Region => self .astconv .re_infer(Some(param), self.span) .unwrap_or_else(|| { @@ -1175,7 +1175,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let substs = candidate.skip_binder().substs.extend_to(tcx, assoc_item.def_id, |param, _| { let subst = match param.kind { - GenericParamDefKind::Lifetime => tcx + GenericParamDefKind::Region => tcx .mk_re_late_bound( ty::INNERMOST, ty::BoundRegion { @@ -3274,7 +3274,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { if let Some(i) = (param.index as usize).checked_sub(generics.count() - lifetimes.len()) { // Resolve our own lifetime parameters. - let GenericParamDefKind::Lifetime { .. } = param.kind else { bug!() }; + let GenericParamDefKind::Region { .. } = param.kind else { bug!() }; let hir::GenericArg::Lifetime(lifetime) = &lifetimes[i] else { bug!() }; self.ast_region_to_region(lifetime, None).into() } else { @@ -3651,7 +3651,7 @@ pub trait InferCtxtExt<'tcx> { impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { InternalSubsts::for_item(self.tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => self.tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => self.tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } => self .next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::SubstitutionPlaceholder, diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index fe87aae8ed111..80f627d4d9939 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1429,11 +1429,11 @@ fn compare_synthetic_generics<'tcx>( let trait_m_generics = tcx.generics_of(trait_m.def_id); let impl_m_type_params = impl_m_generics.params.iter().filter_map(|param| match param.kind { GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)), - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None, + GenericParamDefKind::Region | GenericParamDefKind::Const { .. } => None, }); let trait_m_type_params = trait_m_generics.params.iter().filter_map(|param| match param.kind { GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)), - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None, + GenericParamDefKind::Region | GenericParamDefKind::Const { .. } => None, }); for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) in iter::zip(impl_m_type_params, trait_m_type_params) @@ -1599,7 +1599,7 @@ fn compare_generic_param_kinds<'tcx>( // this is exhaustive so that anyone adding new generic param kinds knows // to make sure this error is reported for them. (Const { .. }, Const { .. }) | (Type { .. }, Type { .. }) => false, - (Lifetime { .. }, _) | (_, Lifetime { .. }) => unreachable!(), + (Region { .. }, _) | (_, Region { .. }) => unreachable!(), } { let param_impl_span = tcx.def_span(param_impl.def_id); let param_trait_span = tcx.def_span(param_trait.def_id); @@ -1623,7 +1623,7 @@ fn compare_generic_param_kinds<'tcx>( ) } Type { .. } => format!("{} type parameter", prefix), - Lifetime { .. } => unreachable!(), + Region { .. } => unreachable!(), }; let trait_header_span = tcx.def_ident_span(tcx.parent(trait_item.def_id)).unwrap(); @@ -1916,7 +1916,7 @@ pub(super) fn check_type_bounds<'tcx>( ) .into() } - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index a0e8ecef9fb8c..72337bc62d02f 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1273,7 +1273,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id | GenericParamDefKind::Const { has_default } => { has_default && def.index >= generics.parent_count as u32 } - GenericParamDefKind::Lifetime => unreachable!(), + GenericParamDefKind::Region => unreachable!(), }; // Check that concrete defaults are well-formed. See test `type-check-defaults.rs`. @@ -1316,7 +1316,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id } } // Doesn't have defaults. - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Region => {} } } @@ -1330,7 +1330,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id // First we build the defaulted substitution. let substs = InternalSubsts::for_item(tcx, def_id.to_def_id(), |param, _| { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { // All regions are identity. tcx.mk_param_from_def(param) } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 119933697a165..c82b1af4f8571 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -242,7 +242,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { index: own_start + i as u32, def_id: param.def_id.to_def_id(), pure_wrt_drop: param.pure_wrt_drop, - kind: ty::GenericParamDefKind::Lifetime, + kind: ty::GenericParamDefKind::Region, })); // Now create the real type and const parameters. diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 3cb217335bda0..de016b59ab6ba 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -1667,7 +1667,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { .params .iter() .map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => ty::BoundVariableKind::Region( + ty::GenericParamDefKind::Region => ty::BoundVariableKind::Region( ty::BoundRegionKind::BrNamed(param.def_id, param.name), ), ty::GenericParamDefKind::Type { .. } => ty::BoundVariableKind::Ty( diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index 82a96f8e67408..2f2481a3529ec 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -123,7 +123,7 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId) report_unused_parameter(tcx, tcx.def_span(param.def_id), "type", param_ty.name); } } - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Region => { let param_lt = cgp::Parameter::from(param.to_early_bound_region_data()); if lifetimes_in_associated_types.contains(¶m_lt) && // (*) !input_parameters.contains(¶m_lt) diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index 4d240e90b143d..e8dad1ab0ae7c 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -140,7 +140,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc generics = tcx.generics_of(def_id); for param in &generics.params { match param.kind { - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Region => { variances[param.index as usize] = ty::Bivariant; } ty::GenericParamDefKind::Type { .. } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 13a869caa8fa6..ec6defc4dfa79 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1260,7 +1260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { arg: &GenericArg<'_>, ) -> ty::GenericArg<'tcx> { match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Region, GenericArg::Lifetime(lt)) => { self.fcx.astconv().ast_region_to_region(lt, Some(param)).into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { @@ -1296,7 +1296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> ty::GenericArg<'tcx> { let tcx = self.fcx.tcx(); match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { self.fcx.re_infer(Some(param), self.span).unwrap().into() } GenericParamDefKind::Type { has_default, .. } => { diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 9155a3d8daa19..d4b137f82fb43 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -370,7 +370,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { arg: &GenericArg<'_>, ) -> subst::GenericArg<'tcx> { match (¶m.kind, arg) { - (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => { + (GenericParamDefKind::Region, GenericArg::Lifetime(lt)) => { self.cfcx.fcx.astconv().ast_region_to_region(lt, Some(param)).into() } (GenericParamDefKind::Type { .. }, GenericArg::Type(ty)) => { diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index 0456dd56c340e..59612599a8cfd 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -305,7 +305,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Construct a trait-reference `self_ty : Trait` let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| { match param.kind { - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => {} + GenericParamDefKind::Region | GenericParamDefKind::Const { .. } => {} GenericParamDefKind::Type { .. } => { if param.index == 0 { return self_ty.into(); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 4fd778910bacb..9467ef2d5ee40 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1877,7 +1877,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { substs[i] } else { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { // In general, during probe we erase regions. self.tcx.lifetimes.re_erased.into() } diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index b0c376a26f614..fbb262c717b85 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2284,7 +2284,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let lts_names = iter::successors(Some(generics), |g| g.parent.map(|p| self.tcx.generics_of(p))) .flat_map(|g| &g.params) - .filter(|p| matches!(p.kind, ty::GenericParamDefKind::Lifetime)) + .filter(|p| matches!(p.kind, ty::GenericParamDefKind::Region)) .map(|p| p.name.as_str()) .collect::>(); possible diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index def7a6542212c..2438586f62329 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1117,7 +1117,7 @@ impl<'tcx> InferCtxt<'tcx> { pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { // Create a region inference variable for the given // region parameter definition. self.next_region_var(EarlyBoundRegion(span, param.name)).into() diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f9d3ffc8f0063..5ce2ad85d469e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1749,7 +1749,7 @@ impl<'tcx> TyCtxt<'tcx> { let adt_def = self.adt_def(wrapper_def_id); let substs = InternalSubsts::for_item(self, wrapper_def_id, |param, substs| match param.kind { - GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => bug!(), + GenericParamDefKind::Region | GenericParamDefKind::Const { .. } => bug!(), GenericParamDefKind::Type { has_default, .. } => { if param.index == 0 { ty_param.into() @@ -2008,7 +2008,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> { match param.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { self.mk_re_early_bound(param.to_early_bound_region_data()).into() } GenericParamDefKind::Type { .. } => self.mk_ty_param(param.index, param.name).into(), diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index baef4ffeda732..69df6f21fd701 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -10,7 +10,7 @@ use super::{EarlyBoundRegion, InstantiatedPredicates, ParamConst, ParamTy, Predi #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)] pub enum GenericParamDefKind { - Lifetime, + Region, Type { has_default: bool, synthetic: bool }, Const { has_default: bool }, } @@ -18,14 +18,14 @@ pub enum GenericParamDefKind { impl GenericParamDefKind { pub fn descr(&self) -> &'static str { match self { - GenericParamDefKind::Lifetime => "lifetime", + GenericParamDefKind::Region => "lifetime", GenericParamDefKind::Type { .. } => "type", GenericParamDefKind::Const { .. } => "constant", } } pub fn to_ord(&self) -> ast::ParamKindOrd { match self { - GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime, + GenericParamDefKind::Region => ast::ParamKindOrd::Lifetime, GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { ast::ParamKindOrd::TypeOrConst } @@ -34,7 +34,7 @@ impl GenericParamDefKind { pub fn is_ty_or_const(&self) -> bool { match self { - GenericParamDefKind::Lifetime => false, + GenericParamDefKind::Region => false, GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => true, } } @@ -63,7 +63,7 @@ pub struct GenericParamDef { impl GenericParamDef { pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion { - if let GenericParamDefKind::Lifetime = self.kind { + if let GenericParamDefKind::Region = self.kind { ty::EarlyBoundRegion { def_id: self.def_id, index: self.index, name: self.name } } else { bug!("cannot convert a non-lifetime parameter def to an early bound region") @@ -72,7 +72,7 @@ impl GenericParamDef { pub fn is_anonymous_lifetime(&self) -> bool { match self.kind { - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { self.name == kw::UnderscoreLifetime || self.name == kw::Empty } _ => false, @@ -100,7 +100,7 @@ impl GenericParamDef { preceding_substs: &[ty::GenericArg<'tcx>], ) -> ty::GenericArg<'tcx> { match &self.kind { - ty::GenericParamDefKind::Lifetime => tcx.mk_re_error_misc().into(), + ty::GenericParamDefKind::Region => tcx.mk_re_error_misc().into(), ty::GenericParamDefKind::Type { .. } => tcx.ty_error_misc().into(), ty::GenericParamDefKind::Const { .. } => { tcx.const_error(tcx.type_of(self.def_id).subst(tcx, preceding_substs)).into() @@ -164,7 +164,7 @@ impl<'tcx> Generics { for param in &self.params { match param.kind { - GenericParamDefKind::Lifetime => own_counts.lifetimes += 1, + GenericParamDefKind::Region => own_counts.lifetimes += 1, GenericParamDefKind::Type { .. } => own_counts.types += 1, GenericParamDefKind::Const { .. } => own_counts.consts += 1, } @@ -178,7 +178,7 @@ impl<'tcx> Generics { for param in &self.params { match param.kind { - GenericParamDefKind::Lifetime => (), + GenericParamDefKind::Region => (), GenericParamDefKind::Type { has_default, .. } => { own_defaults.types += has_default as usize; } @@ -210,7 +210,7 @@ impl<'tcx> Generics { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { return true; } - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Region => {} } } false @@ -243,7 +243,7 @@ impl<'tcx> Generics { ) -> &'tcx GenericParamDef { let param = self.param_at(param.index as usize, tcx); match param.kind { - GenericParamDefKind::Lifetime => param, + GenericParamDefKind::Region => param, _ => bug!("expected lifetime parameter, but found another generic parameter"), } } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index e73225f70ccca..9833277f578ca 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -363,7 +363,7 @@ impl<'tcx> Instance<'tcx> { pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { let substs = InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + ty::GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), ty::GenericParamDefKind::Type { .. } => { bug!("Instance::mono: {:?} has type parameters", def_id) } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 784e85b8147ff..5259b29993642 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1360,7 +1360,7 @@ fn create_mono_items_for_default_impls<'tcx>( // we use the ReErased, which has no lifetime information associated with // it, to validate whether or not the impl is legal to instantiate at all. let only_region_params = |param: &ty::GenericParamDef, _: &_| match param.kind { - GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { unreachable!( "`own_requires_monomorphization` check means that \ diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index 63263a642acc1..a70e42d1e2661 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -170,7 +170,7 @@ fn mark_used_by_default_parameters<'tcx>( | DefKind::Impl { .. } => { for param in &generics.params { debug!(?param, "(other)"); - if let ty::GenericParamDefKind::Lifetime = param.kind { + if let ty::GenericParamDefKind::Region = param.kind { unused_parameters.mark_used(param.index); } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 9567329192d52..bb3ec30aa3fb2 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -850,7 +850,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> { fn generics(&mut self) -> &mut Self { for param in &self.ev.tcx.generics_of(self.item_def_id).params { match param.kind { - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Region => {} GenericParamDefKind::Type { has_default, .. } => { if has_default { self.visit(self.ev.tcx.type_of(param.def_id).subst_identity()); @@ -1755,7 +1755,7 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> { fn generics(&mut self) -> &mut Self { for param in &self.tcx.generics_of(self.item_def_id).params { match param.kind { - GenericParamDefKind::Lifetime => {} + GenericParamDefKind::Region => {} GenericParamDefKind::Type { has_default, .. } => { if has_default { self.visit(self.tcx.type_of(param.def_id).subst_identity()); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs index a9c4e12681635..f618b43c5747d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs @@ -219,7 +219,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { substs[param.index as usize].to_string() } - GenericParamDefKind::Lifetime => continue, + GenericParamDefKind::Region => continue, }; let name = param.name; flags.push((name, Some(value))); @@ -631,7 +631,7 @@ impl<'tcx> OnUnimplementedFormatString { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize].to_string() } - GenericParamDefKind::Lifetime => return None, + GenericParamDefKind::Region => return None, }; let name = param.name; Some((name, value)) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 73207f183a1d8..060b025e6fce8 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3803,7 +3803,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { return prev_ty.into(); } } - ty::GenericParamDefKind::Lifetime | ty::GenericParamDefKind::Const { .. } => {} + ty::GenericParamDefKind::Region | ty::GenericParamDefKind::Const { .. } => {} } self.var_for_def(span, param) }); diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 55923161be3da..5cb6f9339c854 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -2177,7 +2177,7 @@ fn check_substs_compatible<'tcx>( for (param, arg) in std::iter::zip(&generics.params, own_args) { match (¶m.kind, arg.unpack()) { (ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_)) - | (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Region(_)) + | (ty::GenericParamDefKind::Region, ty::GenericArgKind::Region(_)) | (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {} _ => return false, } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 3bba11262f5b8..b0e961d3c333e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -536,7 +536,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ) .into() } - GenericParamDefKind::Lifetime => { + GenericParamDefKind::Region => { let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index a4e9928f8b2cf..88b88d060d5d5 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -242,7 +242,7 @@ fn vtable_entries<'tcx>( // The method may have some early-bound lifetimes; add regions for those. let substs = trait_ref.map_bound(|trait_ref| { InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize] diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index baeff5484d1d1..43a62eeca19d8 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -727,7 +727,7 @@ fn bound_vars_for_item(tcx: TyCtxt<'_>, def_id: DefId) -> SubstsRef<'_> { ) .into(), - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Region => { let br = ty::BoundRegion { var: ty::BoundVar::from_usize(substs.len()), kind: ty::BrAnon(None), From a8651ed60f54e8df408b32e13f9645f1f6c78fbb Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:29:11 +0000 Subject: [PATCH 5/8] librustdoc: use `GenericParamDefKind::Region`'s new name --- src/librustdoc/clean/auto_trait.rs | 2 +- src/librustdoc/clean/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index eeee12a431065..737de612b80cf 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -58,7 +58,7 @@ where .params .iter() .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => Some(param.name), + ty::GenericParamDefKind::Region => Some(param.name), _ => None, }) .map(|name| (name, Lifetime(name))) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 04379c2bca97d..0478d5ccc075b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -473,7 +473,7 @@ fn clean_generic_param_def<'tcx>( cx: &mut DocContext<'tcx>, ) -> GenericParamDef { let (name, kind) = match def.kind { - ty::GenericParamDefKind::Lifetime => { + ty::GenericParamDefKind::Region => { (def.name, GenericParamDefKind::Lifetime { outlives: vec![] }) } ty::GenericParamDefKind::Type { has_default, synthetic, .. } => { @@ -733,8 +733,8 @@ fn clean_ty_generics<'tcx>( .params .iter() .filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime if param.is_anonymous_lifetime() => None, - ty::GenericParamDefKind::Lifetime => Some(clean_generic_param_def(param, cx)), + ty::GenericParamDefKind::Region if param.is_anonymous_lifetime() => None, + ty::GenericParamDefKind::Region => Some(clean_generic_param_def(param, cx)), ty::GenericParamDefKind::Type { synthetic, .. } => { if param.name == kw::SelfUpper { assert_eq!(param.index, 0); From f9c39c747b4a81068e56071890c072f1246abf37 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:30:00 +0000 Subject: [PATCH 6/8] clippy: use `GenericParamDefKind::Region`'s new name --- src/tools/clippy/clippy_utils/src/ty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 3bcfe8f994fca..ff2cb62fc2bf0 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -1070,7 +1070,7 @@ pub fn make_projection<'tcx>( .find(|(_, (param, arg))| { !matches!( (param, arg), - (ty::GenericParamDefKind::Lifetime, GenericArgKind::Region(_)) + (ty::GenericParamDefKind::Region, GenericArgKind::Region(_)) | (ty::GenericParamDefKind::Type { .. }, GenericArgKind::Type(_)) | (ty::GenericParamDefKind::Const { .. }, GenericArgKind::Const(_)) ) From 322e4d4367ce0964b8bed1d2086f787650a624e4 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:39:51 +0000 Subject: [PATCH 7/8] compiler: Rename `tcx.{lifetimes => regions}` (and related) --- .../rustc_borrowck/src/diagnostics/mod.rs | 2 +- .../rustc_borrowck/src/region_infer/mod.rs | 4 +- .../src/region_infer/opaque_types.rs | 2 +- .../rustc_borrowck/src/universal_regions.rs | 4 +- .../rustc_codegen_cranelift/src/abi/mod.rs | 2 +- .../src/coverageinfo/mod.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 2 +- .../interpret/intrinsics/caller_location.rs | 2 +- .../rustc_const_eval/src/interpret/place.rs | 7 ++- .../src/transform/promote_consts.rs | 6 +-- .../rustc_hir_analysis/src/astconv/mod.rs | 12 ++--- compiler/rustc_hir_analysis/src/collect.rs | 4 +- .../rustc_hir_analysis/src/collect/type_of.rs | 2 +- .../rustc_hir_analysis/src/hir_wf_check.rs | 2 +- compiler/rustc_hir_typeck/src/cast.rs | 4 +- compiler/rustc_hir_typeck/src/demand.rs | 6 +-- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 2 +- .../src/generator_interior/mod.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 4 +- .../rustc_hir_typeck/src/method/suggest.rs | 4 +- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_hir_typeck/src/upvar.rs | 4 +- compiler/rustc_hir_typeck/src/writeback.rs | 4 +- .../src/infer/error_reporting/mod.rs | 2 +- .../rustc_infer/src/infer/free_regions.rs | 4 +- compiler/rustc_infer/src/infer/freshen.rs | 2 +- .../src/infer/lexical_region_resolve/mod.rs | 18 +++---- .../rustc_infer/src/infer/opaque_types.rs | 2 +- .../rustc_infer/src/infer/outlives/mod.rs | 2 +- .../src/infer/outlives/test_type_match.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 50 +++++++++---------- compiler/rustc_middle/src/ty/erase_regions.rs | 2 +- compiler/rustc_middle/src/ty/fold.rs | 2 +- compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/layout.rs | 9 ++-- compiler/rustc_middle/src/ty/opaque_types.rs | 2 +- compiler/rustc_middle/src/ty/util.rs | 4 +- .../src/build/custom/parse/instruction.rs | 2 +- .../src/build/expr/as_place.rs | 4 +- .../src/build/expr/as_rvalue.rs | 2 +- .../rustc_mir_build/src/build/expr/into.rs | 2 +- .../rustc_mir_build/src/build/matches/mod.rs | 10 ++-- .../rustc_mir_build/src/build/matches/test.rs | 2 +- compiler/rustc_mir_build/src/thir/cx/mod.rs | 4 +- .../rustc_mir_dataflow/src/elaborate_drops.rs | 4 +- compiler/rustc_mir_transform/src/generator.rs | 2 +- compiler/rustc_mir_transform/src/inline.rs | 2 +- compiler/rustc_mir_transform/src/shim.rs | 10 ++-- compiler/rustc_monomorphize/src/collector.rs | 2 +- compiler/rustc_query_impl/src/plumbing.rs | 2 +- .../src/typeid/typeid_itanium_cxx_abi.rs | 4 +- .../src/traits/auto_trait.rs | 2 +- .../src/traits/error_reporting/suggestions.rs | 12 ++--- .../src/traits/object_safety.rs | 2 +- .../src/traits/vtable.rs | 2 +- compiler/rustc_traits/src/chalk/lowering.rs | 4 +- 56 files changed, 125 insertions(+), 137 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 4a85df9f8c09e..1eb16524b73a0 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1047,7 +1047,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { type_known_to_meet_bound_modulo_regions( &infcx, self.param_env, - tcx.mk_imm_ref(tcx.lifetimes.re_erased, tcx.erase_regions(ty)), + tcx.mk_imm_ref(tcx.regions.erased, tcx.erase_regions(ty)), def_id, ) } diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 161db0ac14d09..c14bc6b0f05b0 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -1115,7 +1115,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { std::iter::zip(substs, tcx.variances_of(def_id)).map(|(arg, v)| { match (arg.unpack(), v) { (ty::GenericArgKind::Region(_), ty::Bivariant) => { - tcx.lifetimes.re_static.into() + tcx.regions.re_static.into() } _ => arg.fold_with(self), } @@ -1142,7 +1142,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .map(|u_r| tcx.mk_re_var(u_r)) // In the case of a failure, use `ReErased`. We will eventually // return `None` in this case. - .unwrap_or(tcx.lifetimes.re_erased) + .unwrap_or(tcx.regions.erased) }); debug!("try_promote_type_test_subject: folded ty = {:?}", ty); diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 975b9680210c3..589eafc2ecafa 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -131,7 +131,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .iter() .find(|ur_vid| self.eval_equal(vid, **ur_vid)) .and_then(|ur_vid| self.definitions[*ur_vid].external_name) - .unwrap_or(infcx.tcx.lifetimes.re_erased), + .unwrap_or(infcx.tcx.regions.erased), _ => region, }); debug!(?universal_concrete_type); diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 74241f722a67e..643547e824da5 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -248,7 +248,7 @@ impl<'tcx> UniversalRegions<'tcx> { closure_def_id: LocalDefId, ) -> IndexVec> { let mut region_mapping = IndexVec::with_capacity(expected_num_vars); - region_mapping.push(tcx.lifetimes.re_static); + region_mapping.push(tcx.regions.re_static); tcx.for_each_free_region(&closure_substs, |fr| { region_mapping.push(fr); }); @@ -632,7 +632,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs, }; - let global_mapping = iter::once((tcx.lifetimes.re_static, fr_static)); + let global_mapping = iter::once((tcx.regions.re_static, fr_static)); let subst_mapping = iter::zip(identity_substs.regions(), fr_substs.regions().map(|r| r.as_var())); diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index 91c085d3d6986..36d2232dd4cba 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -668,7 +668,7 @@ pub(crate) fn codegen_drop<'tcx>( let arg_value = drop_place.place_ref( fx, fx.layout_of(fx.tcx.mk_ref( - fx.tcx.lifetimes.re_erased, + fx.tcx.regions.erased, TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut }, )), ); diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs index eb8d911e5b563..12eebbb3d0318 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs @@ -188,7 +188,7 @@ fn declare_unused_fn<'tcx>(cx: &CodegenCx<'_, 'tcx>, def_id: DefId) -> Instance< def_id, InternalSubsts::for_item(tcx, def_id, |param, _| { if let ty::GenericParamDefKind::Region = param.kind { - tcx.lifetimes.re_erased.into() + tcx.regions.erased.into() } else { tcx.mk_param_from_def(param) } diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index bd11d47500a55..1a552a0bd5c31 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -573,7 +573,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { mir::Rvalue::Ref(_, bk, place) => { let mk_ref = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| { tcx.mk_ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, ty::TypeAndMut { ty, mutbl: bk.to_mutbl_lossy() }, ) }; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs index 3701eb93ec834..64e96cc8370ce 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs @@ -96,7 +96,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let loc_ty = self .tcx .type_of(self.tcx.require_lang_item(LangItem::PanicLocation, None)) - .subst(*self.tcx, self.tcx.mk_substs(&[self.tcx.lifetimes.re_erased.into()])); + .subst(*self.tcx, self.tcx.mk_substs(&[self.tcx.regions.erased.into()])); let loc_layout = self.layout_of(loc_ty).unwrap(); let location = self.allocate(loc_layout, MemoryKind::CallerLocation).unwrap(); diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 03b09cf830b71..614b4b162ab04 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -775,10 +775,9 @@ where let meta = Scalar::from_target_usize(u64::try_from(str.len()).unwrap(), self); let mplace = MemPlace { ptr: ptr.into(), meta: MemPlaceMeta::Meta(meta) }; - let ty = self.tcx.mk_ref( - self.tcx.lifetimes.re_static, - ty::TypeAndMut { ty: self.tcx.types.str_, mutbl }, - ); + let ty = self + .tcx + .mk_ref(self.tcx.regions.re_static, ty::TypeAndMut { ty: self.tcx.types.str_, mutbl }); let layout = self.layout_of(ty).unwrap(); Ok(MPlaceTy { mplace, layout, align: layout.align.abi }) } diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs index 7919aed097a45..4a2019b6f36cb 100644 --- a/compiler/rustc_const_eval/src/transform/promote_consts.rs +++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs @@ -859,11 +859,11 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { let span = statement.source_info.span; let ref_ty = tcx.mk_ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, ty::TypeAndMut { ty, mutbl: borrow_kind.to_mutbl_lossy() }, ); - *region = tcx.lifetimes.re_erased; + *region = tcx.regions.erased; let mut projection = vec![PlaceElem::Deref]; projection.extend(place.projection); @@ -887,7 +887,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { self.extra_statements.push((loc, promoted_ref_statement)); Rvalue::Ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, *borrow_kind, Place { local: mem::replace(&mut place.local, promoted_ref), diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 027121f80b9f9..5217d6bca033c 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -229,7 +229,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let lifetime_name = |def_id| tcx.hir().name(tcx.hir().local_def_id_to_hir_id(def_id)); match tcx.named_bound_var(lifetime.hir_id) { - Some(rbv::ResolvedArg::StaticLifetime) => tcx.lifetimes.re_static, + Some(rbv::ResolvedArg::StaticLifetime) => tcx.regions.re_static, Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => { let name = lifetime_name(def_id.expect_local()); @@ -2340,7 +2340,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let self_ty = tcx.replace_escaping_bound_vars_uncached( self_ty, FnMutDelegate { - regions: &mut |_| tcx.lifetimes.re_erased, + regions: &mut |_| tcx.regions.erased, types: &mut |bv| { tcx.mk_placeholder(ty::PlaceholderType { universe, bound: bv }) }, @@ -2520,7 +2520,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { tcx, infcx.fresh_substs_for_item(DUMMY_SP, impl_def_id), ); - let value = tcx.fold_regions(qself_ty, |_, _| tcx.lifetimes.re_erased); + let value = tcx.fold_regions(qself_ty, |_, _| tcx.regions.erased); // FIXME: Don't bother dealing with non-lifetime binders here... if value.has_escaping_bound_vars() { return false; @@ -3227,7 +3227,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { hir::TyKind::Typeof(e) => { let ty_erased = tcx.type_of(e.def_id).subst_identity(); let ty = tcx.fold_regions(ty_erased, |r, _| { - if r.is_erased() { tcx.lifetimes.re_static } else { r } + if r.is_erased() { tcx.regions.re_static } else { r } }); let span = ast_ty.span; let (ty, opt_sugg) = if let Some(ty) = ty.make_suggestable(tcx, false) { @@ -3519,7 +3519,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // If any of the derived region bounds are 'static, that is always // the best choice. if derived_region_bounds.iter().any(|r| r.is_static()) { - return Some(tcx.lifetimes.re_static); + return Some(tcx.regions.re_static); } // Determine whether there is exactly one unique region in the set @@ -3651,7 +3651,7 @@ pub trait InferCtxtExt<'tcx> { impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> { fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> { InternalSubsts::for_item(self.tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Region => self.tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => self.tcx.regions.erased.into(), GenericParamDefKind::Type { .. } => self .next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::SubstitutionPlaceholder, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 7c07a1ebaec07..96e422d0bfe05 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -387,7 +387,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> { fn ct_infer(&self, ty: Ty<'tcx>, _: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx> { let ty = self.tcx.fold_regions(ty, |r, _| match *r { - ty::ReErased => self.tcx.lifetimes.re_static, + ty::ReErased => self.tcx.regions.re_static, _ => r, }); self.tcx().const_error_with_message(ty, span, "bad placeholder constant") @@ -1141,7 +1141,7 @@ fn infer_return_ty_for_fn_sig<'tcx>( let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id]; // Typeck doesn't expect erased regions to be returned from `type_of`. let fn_sig = tcx.fold_regions(fn_sig, |r, _| match *r { - ty::ReErased => tcx.lifetimes.re_static, + ty::ReErased => tcx.regions.re_static, _ => r, }); diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index f82fad474224b..0cf3477682032 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -932,7 +932,7 @@ fn infer_placeholder_type<'a>( // Typeck doesn't expect erased regions to be returned from `type_of`. tcx.fold_regions(ty, |r, _| match *r { - ty::ReErased => tcx.lifetimes.re_static, + ty::ReErased => tcx.regions.re_static, _ => r, }) } diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index 8269a6ddea5f4..f7e65b9c7d34f 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -194,6 +194,6 @@ impl<'tcx> TypeFolder> for EraseAllBoundRegions<'tcx> { self.tcx } fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> { - if r.is_late_bound() { self.tcx.lifetimes.re_erased } else { r } + if r.is_late_bound() { self.tcx.regions.erased } else { r } } } diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 1481c038cfebb..e945a7802a364 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -394,7 +394,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { .try_coerce( self.expr, fcx.tcx.mk_ref( - fcx.tcx.lifetimes.re_erased, + fcx.tcx.regions.erased, TypeAndMut { ty: expr_ty, mutbl }, ), self.cast_ty, @@ -442,7 +442,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { .try_coerce( self.expr, fcx.tcx.mk_ref( - fcx.tcx.lifetimes.re_erased, + fcx.tcx.regions.erased, TypeAndMut { ty: self.expr_ty, mutbl }, ), self.cast_ty, diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 525acfdaa8124..e14d036975aa6 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -282,7 +282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty } }, - lt_op: |_| self.tcx.lifetimes.re_erased, + lt_op: |_| self.tcx.regions.erased, ct_op: |ct| { if let ty::ConstKind::Infer(_) = ct.kind() { self.next_const_var( @@ -1293,10 +1293,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // ``` let ref_ty = match mutability { hir::Mutability::Mut => { - self.tcx.mk_mut_ref(self.tcx.lifetimes.re_static, checked_ty) + self.tcx.mk_mut_ref(self.tcx.regions.re_static, checked_ty) } hir::Mutability::Not => { - self.tcx.mk_imm_ref(self.tcx.lifetimes.re_static, checked_ty) + self.tcx.mk_imm_ref(self.tcx.regions.re_static, checked_ty) } }; if self.can_coerce(ref_ty, expected) { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index ea1b52daaa5e5..2b3b7c758a704 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1289,7 +1289,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match lit.node { ast::LitKind::Str(..) => tcx.mk_static_str(), ast::LitKind::ByteStr(ref v, _) => { - tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_array(tcx.types.u8, v.len() as u64)) + tcx.mk_imm_ref(tcx.regions.re_static, tcx.mk_array(tcx.types.u8, v.len() as u64)) } ast::LitKind::Byte(_) => tcx.types.u8, ast::LitKind::Char(_) => tcx.types.char, diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 8feef332de8a7..d4b84b97b4549 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> { let ty = tcx.mk_ref( // Use `ReErased` as `resolve_interior` is going to replace all the // regions anyway. - tcx.lifetimes.re_erased, + tcx.regions.erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Not }, ); self.interior_visitor.record( diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 9467ef2d5ee40..e44394202dd21 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -1212,7 +1212,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let tcx = self.tcx; // In general, during probing we erase regions. - let region = tcx.lifetimes.re_erased; + let region = tcx.regions.erased; let autoref_ty = tcx.mk_ref(region, ty::TypeAndMut { ty: self_ty, mutbl }); self.pick_method(autoref_ty, unstable_candidates).map(|r| { @@ -1879,7 +1879,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { match param.kind { GenericParamDefKind::Region => { // In general, during probe we erase regions. - self.tcx.lifetimes.re_erased.into() + self.tcx.regions.erased.into() } GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { self.var_for_def(self.span, param) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 442a8068661cc..ae40489eb6326 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -2380,8 +2380,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // just this list. for (rcvr_ty, post) in &[ (rcvr_ty, ""), - (self.tcx.mk_mut_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&mut "), - (self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, rcvr_ty), "&"), + (self.tcx.mk_mut_ref(self.tcx.regions.erased, rcvr_ty), "&mut "), + (self.tcx.mk_imm_ref(self.tcx.regions.erased, rcvr_ty), "&"), ] { match self.lookup_probe_for_diagnostic( item_name, diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 7160d1c67b251..cec7266c9ea29 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -403,7 +403,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .borrow_mut() .treat_byte_string_as_slice .insert(lt.hir_id.local_id); - pat_ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_slice(tcx.types.u8)); + pat_ty = tcx.mk_imm_ref(tcx.regions.re_static, tcx.mk_slice(tcx.types.u8)); } } diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 147b3e74d0f8a..41a7e0ed8d010 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -964,7 +964,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx, ty, max_capture_info.capture_kind, - Some(self.tcx.lifetimes.re_erased), + Some(self.tcx.regions.erased), ) } }; @@ -990,7 +990,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx, capture.place.ty(), capture.info.capture_kind, - Some(self.tcx.lifetimes.re_erased), + Some(self.tcx.regions.erased), ); // Checks if a capture implements any of the auto traits diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index e876fa27593d4..5d5dec756587f 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -774,7 +774,7 @@ impl<'tcx> TypeFolder> for EraseEarlyRegions<'tcx> { } } fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - if r.is_late_bound() { r } else { self.tcx.lifetimes.re_erased } + if r.is_late_bound() { r } else { self.tcx.regions.erased } } } @@ -803,7 +803,7 @@ impl<'cx, 'tcx> TypeFolder> for Resolver<'cx, 'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { debug_assert!(!r.is_late_bound(), "Should not be resolving bound region."); - self.tcx.lifetimes.re_erased + self.tcx.regions.erased } fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> { diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index fbb262c717b85..b8e509106cb8d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -503,7 +503,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // placeholder. In practice, we expect more // tailored errors that don't really use this // value. - let sub_r = self.tcx.lifetimes.re_erased; + let sub_r = self.tcx.regions.erased; self.report_placeholder_failure(sup_origin, sub_r, sup_r).emit(); } diff --git a/compiler/rustc_infer/src/infer/free_regions.rs b/compiler/rustc_infer/src/infer/free_regions.rs index 2402a7ea7c741..7ee6ed0fc3bdb 100644 --- a/compiler/rustc_infer/src/infer/free_regions.rs +++ b/compiler/rustc_infer/src/infer/free_regions.rs @@ -60,7 +60,7 @@ impl<'tcx> FreeRegionMap<'tcx> { r_b: Region<'tcx>, ) -> bool { assert!(r_a.is_free_or_static() && r_b.is_free_or_static()); - let re_static = tcx.lifetimes.re_static; + let re_static = tcx.regions.re_static; if self.check_relation(re_static, r_b) { // `'a <= 'static` is always true, and not stored in the // relation explicitly, so check if `'b` is `'static` (or @@ -93,7 +93,7 @@ impl<'tcx> FreeRegionMap<'tcx> { r_a } else { match self.relation.postdom_upper_bound(r_a, r_b) { - None => tcx.lifetimes.re_static, + None => tcx.regions.re_static, Some(r) => r, } }; diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index d89f63e5c53e9..8db62eb9efe4e 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -121,7 +121,7 @@ impl<'a, 'tcx> TypeFolder> for TypeFreshener<'a, 'tcx> { | ty::RePlaceholder(..) | ty::ReStatic | ty::ReError(_) - | ty::ReErased => self.interner().lifetimes.re_erased, + | ty::ReErased => self.interner().regions.erased, } } diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index df15cab00b487..8d15e115b708e 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -179,7 +179,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { ReStatic => { // nothing lives longer than `'static` - Ok(self.tcx().lifetimes.re_static) + Ok(self.tcx().regions.re_static) } ReError(_) => Ok(a_region), @@ -244,7 +244,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { Err(placeholder) if a_universe == placeholder.universe => { cur_region } - Err(_) => self.tcx().lifetimes.re_static, + Err(_) => self.tcx().regions.re_static, }; if lub == cur_region { @@ -338,7 +338,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { Err(placeholder) if empty_ui.can_name(placeholder.universe) => { self.tcx().mk_re_placeholder(placeholder) } - Err(_) => self.tcx().lifetimes.re_static, + Err(_) => self.tcx().regions.re_static, }; debug!("Expanding value of {:?} from empty lifetime to {:?}", b_vid, lub); @@ -367,7 +367,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { // // (This might e.g. arise from being asked to prove `for<'a> { 'b: 'a }`.) if let ty::RePlaceholder(p) = *lub && b_universe.cannot_name(p.universe) { - lub = self.tcx().lifetimes.re_static; + lub = self.tcx().regions.re_static; } debug!("Expanding value of {:?} from {:?} to {:?}", b_vid, cur_region, lub); @@ -469,7 +469,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { // Check for the case where we know that `'b: 'static` -- in that case, // `a <= b` for all `a`. let b_free_or_static = b.is_free_or_static(); - if b_free_or_static && sub_free_regions(tcx.lifetimes.re_static, b) { + if b_free_or_static && sub_free_regions(tcx.regions.re_static, b) { return true; } @@ -516,7 +516,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { (ReStatic, _) | (_, ReStatic) => { // nothing lives longer than `'static` - self.tcx().lifetimes.re_static + self.tcx().regions.re_static } (ReEarlyBound(_) | ReFree(_), ReEarlyBound(_) | ReFree(_)) => { @@ -529,7 +529,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { if a == b { a } else { - self.tcx().lifetimes.re_static + self.tcx().regions.re_static } } } @@ -759,7 +759,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { for lower_bound in &lower_bounds { let effective_lower_bound = if let ty::RePlaceholder(p) = *lower_bound.region { if node_universe.cannot_name(p.universe) { - self.tcx().lifetimes.re_static + self.tcx().regions.re_static } else { lower_bound.region } @@ -1012,7 +1012,7 @@ impl<'tcx> LexicalRegionResolutions<'tcx> { ty::ReVar(rid) => match self.values[rid] { VarValue::Empty(_) => r, VarValue::Value(r) => r, - VarValue::ErrorValue => tcx.lifetimes.re_static, + VarValue::ErrorValue => tcx.regions.re_static, }, _ => r, }; diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index e8bc8e4fe9d16..fc37eb9ebe327 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -354,7 +354,7 @@ impl<'tcx> InferCtxt<'tcx> { GenericArgKind::Region(r) => Some(r), GenericArgKind::Type(_) | GenericArgKind::Const(_) => None, }) - .chain(std::iter::once(self.tcx.lifetimes.re_static)) + .chain(std::iter::once(self.tcx.regions.re_static)) .collect(), ); diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs index 9a9a1696b0063..f64829a4ca80e 100644 --- a/compiler/rustc_infer/src/infer/outlives/mod.rs +++ b/compiler/rustc_infer/src/infer/outlives/mod.rs @@ -62,7 +62,7 @@ impl<'tcx> InferCtxt<'tcx> { let lexical_region_resolutions = LexicalRegionResolutions { values: rustc_index::vec::IndexVec::from_elem_n( - crate::infer::lexical_region_resolve::VarValue::Value(self.tcx.lifetimes.re_erased), + crate::infer::lexical_region_resolve::VarValue::Value(self.tcx.regions.erased), var_infos.len(), ), }; diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 01f900f050ee9..e57321704f7b2 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -53,7 +53,7 @@ pub fn extract_verify_if_eq<'tcx>( None => { // If there is no mapping, then this region is unconstrained. // In that case, we escalate to `'static`. - Some(tcx.lifetimes.re_static) + Some(tcx.regions.re_static) } } } else { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 5ce2ad85d469e..c3aca36f0ed3d 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -303,20 +303,20 @@ pub struct CommonTypes<'tcx> { pub fresh_float_tys: Vec>, } -pub struct CommonLifetimes<'tcx> { - /// `ReStatic` +pub struct CommonRegions<'tcx> { + /// [`ty::ReStatic`]. pub re_static: Region<'tcx>, /// Erased region, used outside of type inference. - pub re_erased: Region<'tcx>, + pub erased: Region<'tcx>, /// Pre-interned `ReVar(ty::RegionVar(n))` for small values of `n`. - pub re_vars: Vec>, + pub vars: Vec>, /// Pre-interned values of the form: /// `ReLateBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon(None) })` /// for small values of `i` and `v`. - pub re_late_bounds: Vec>>, + pub late_bounds: Vec>>, } pub struct CommonConsts<'tcx> { @@ -372,8 +372,8 @@ impl<'tcx> CommonTypes<'tcx> { } } -impl<'tcx> CommonLifetimes<'tcx> { - fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> { +impl<'tcx> CommonRegions<'tcx> { + fn new(interners: &CtxtInterners<'tcx>) -> CommonRegions<'tcx> { let mk = |r| { Region(Interned::new_unchecked( interners.region.intern(r, |r| InternedInSet(interners.arena.alloc(r))).0, @@ -396,11 +396,11 @@ impl<'tcx> CommonLifetimes<'tcx> { }) .collect(); - CommonLifetimes { + CommonRegions { re_static: mk(ty::ReStatic), - re_erased: mk(ty::ReErased), - re_vars, - re_late_bounds, + erased: mk(ty::ReErased), + vars: re_vars, + late_bounds: re_late_bounds, } } } @@ -507,8 +507,8 @@ pub struct GlobalCtxt<'tcx> { /// Common types, pre-interned for your convenience. pub types: CommonTypes<'tcx>, - /// Common lifetimes, pre-interned for your convenience. - pub lifetimes: CommonLifetimes<'tcx>, + /// Common regions, pre-interned for your convenience. + pub regions: CommonRegions<'tcx>, /// Common consts, pre-interned for your convenience. pub consts: CommonConsts<'tcx>, @@ -693,7 +693,7 @@ impl<'tcx> TyCtxt<'tcx> { }); let interners = CtxtInterners::new(arena); let common_types = CommonTypes::new(&interners, s, &untracked); - let common_lifetimes = CommonLifetimes::new(&interners); + let common_lifetimes = CommonRegions::new(&interners); let common_consts = CommonConsts::new(&interners, &common_types); GlobalCtxt { @@ -705,7 +705,7 @@ impl<'tcx> TyCtxt<'tcx> { dep_graph, prof: s.prof.clone(), types: common_types, - lifetimes: common_lifetimes, + regions: common_lifetimes, consts: common_consts, untracked, on_disk_cache, @@ -1198,9 +1198,9 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns `&'static core::panic::Location<'static>`. pub fn caller_location_ty(self) -> Ty<'tcx> { self.mk_imm_ref( - self.lifetimes.re_static, + self.regions.re_static, self.type_of(self.require_lang_item(LangItem::PanicLocation, None)) - .subst(self, self.mk_substs(&[self.lifetimes.re_static.into()])), + .subst(self, self.mk_substs(&[self.regions.re_static.into()])), ) } @@ -1731,7 +1731,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_static_str(self) -> Ty<'tcx> { - self.mk_imm_ref(self.lifetimes.re_static, self.types.str_) + self.mk_imm_ref(self.regions.re_static, self.types.str_) } #[inline] @@ -1936,9 +1936,9 @@ impl<'tcx> TyCtxt<'tcx> { pub fn mk_task_context(self) -> Ty<'tcx> { let context_did = self.require_lang_item(LangItem::Context, None); let context_adt_ref = self.adt_def(context_did); - let context_substs = self.mk_substs(&[self.lifetimes.re_erased.into()]); + let context_substs = self.mk_substs(&[self.regions.erased.into()]); let context_ty = self.mk_adt(context_adt_ref, context_substs); - self.mk_mut_ref(self.lifetimes.re_erased, context_ty) + self.mk_mut_ref(self.regions.erased, context_ty) } #[inline] @@ -2062,7 +2062,7 @@ impl<'tcx> TyCtxt<'tcx> { ) -> Region<'tcx> { // Use a pre-interned one when possible. if let ty::BoundRegion { var, kind: ty::BrAnon(None) } = bound_region - && let Some(inner) = self.lifetimes.re_late_bounds.get(debruijn.as_usize()) + && let Some(inner) = self.regions.late_bounds.get(debruijn.as_usize()) && let Some(re) = inner.get(var.as_usize()).copied() { re @@ -2079,8 +2079,8 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_re_var(self, v: ty::RegionVid) -> Region<'tcx> { // Use a pre-interned one when possible. - self.lifetimes - .re_vars + self.regions + .vars .get(v.as_usize()) .copied() .unwrap_or_else(|| self.intern_region(ty::ReVar(v))) @@ -2100,10 +2100,10 @@ impl<'tcx> TyCtxt<'tcx> { ty::ReFree(ty::FreeRegion { scope, bound_region }) => { self.mk_re_free(scope, bound_region) } - ty::ReStatic => self.lifetimes.re_static, + ty::ReStatic => self.regions.re_static, ty::ReVar(vid) => self.mk_re_var(vid), ty::RePlaceholder(region) => self.mk_re_placeholder(region), - ty::ReErased => self.lifetimes.re_erased, + ty::ReErased => self.regions.erased, ty::ReError(reported) => self.mk_re_error(reported), } } diff --git a/compiler/rustc_middle/src/ty/erase_regions.rs b/compiler/rustc_middle/src/ty/erase_regions.rs index 3837732483244..b445c6a42887c 100644 --- a/compiler/rustc_middle/src/ty/erase_regions.rs +++ b/compiler/rustc_middle/src/ty/erase_regions.rs @@ -62,7 +62,7 @@ impl<'tcx> TypeFolder> for RegionEraserVisitor<'tcx> { // whenever a substitution occurs. match *r { ty::ReLateBound(..) => r, - _ => self.tcx.lifetimes.re_erased, + _ => self.tcx.regions.erased, } } } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 25890eb15cde4..41681ca353b5b 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -362,7 +362,7 @@ impl<'tcx> TyCtxt<'tcx> { where T: TypeFoldable>, { - self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0 + self.replace_late_bound_regions(value, |_| self.regions.erased).0 } /// Anonymize all bound variables in `value`, this is mostly used to improve caching. diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index 9833277f578ca..addb459bdbaff 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -363,7 +363,7 @@ impl<'tcx> Instance<'tcx> { pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { let substs = InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - ty::GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), + ty::GenericParamDefKind::Region => tcx.regions.erased.into(), ty::GenericParamDefKind::Type { .. } => { bug!("Instance::mono: {:?} has type parameters", def_id) } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 1e2fd86e13dc8..cb1defc4e8a96 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -796,7 +796,7 @@ where let unit_ptr_ty = if this.ty.is_unsafe_ptr() { tcx.mk_mut_ptr(nil) } else { - tcx.mk_mut_ref(tcx.lifetimes.re_static, nil) + tcx.mk_mut_ref(tcx.regions.re_static, nil) }; // NOTE(eddyb) using an empty `ParamEnv`, and `unwrap`-ing @@ -809,7 +809,7 @@ where } let mk_dyn_vtable = || { - tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_array(tcx.types.usize, 3)) + tcx.mk_imm_ref(tcx.regions.re_static, tcx.mk_array(tcx.types.usize, 3)) /* FIXME: use actual fn pointers Warning: naively computing the number of entries in the vtable by counting the methods on the trait + methods on @@ -911,10 +911,7 @@ where } else if i == 1 { // FIXME(dyn-star) same FIXME as above applies here too TyMaybeWithLayout::Ty( - tcx.mk_imm_ref( - tcx.lifetimes.re_static, - tcx.mk_array(tcx.types.usize, 3), - ), + tcx.mk_imm_ref(tcx.regions.re_static, tcx.mk_array(tcx.types.usize, 3)), ) } else { bug!("no field {i} on dyn*") diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 0fa1e0c7a318d..5a4a8b3ed9d3c 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -125,7 +125,7 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { match self.map.get(&r.into()).map(|k| k.unpack()) { Some(GenericArgKind::Region(r1)) => r1, Some(u) => panic!("region mapped to unexpected kind: {:?}", u), - None if self.do_not_error => self.tcx.lifetimes.re_static, + None if self.do_not_error => self.tcx.regions.re_static, None => { let e = self .tcx diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 6bda778c2d2e0..2999c26e55ee9 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -619,7 +619,7 @@ impl<'tcx> TyCtxt<'tcx> { self.mk_imm_ptr(static_ty) } else { // FIXME: These things don't *really* have 'static lifetime. - self.mk_imm_ref(self.lifetimes.re_static, static_ty) + self.mk_imm_ref(self.regions.re_static, static_ty) } } @@ -638,7 +638,7 @@ impl<'tcx> TyCtxt<'tcx> { } else if self.is_foreign_item(def_id) { self.mk_imm_ptr(static_ty) } else { - self.mk_imm_ref(self.lifetimes.re_erased, static_ty) + self.mk_imm_ref(self.regions.erased, static_ty) } } diff --git a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs index 931fe1b2433a0..6066a2d862ac4 100644 --- a/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs +++ b/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs @@ -155,7 +155,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { }, @call("mir_len", args) => Ok(Rvalue::Len(self.parse_place(args[0])?)), ExprKind::Borrow { borrow_kind, arg } => Ok( - Rvalue::Ref(self.tcx.lifetimes.re_erased, *borrow_kind, self.parse_place(*arg)?) + Rvalue::Ref(self.tcx.regions.erased, *borrow_kind, self.parse_place(*arg)?) ), ExprKind::AddressOf { mutability, arg } => Ok( Rvalue::AddressOf(*mutability, self.parse_place(*arg)?) diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index fb775766c6541..dc7e721128277 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -687,7 +687,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) .ty; let fake_borrow_ty = - tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty); + tcx.mk_imm_ref(tcx.regions.erased, fake_borrow_deref_ty); let fake_borrow_temp = self.local_decls.push(LocalDecl::new(fake_borrow_ty, expr_span)); let projection = tcx.mk_place_elems(&base_place.projection[..idx]); @@ -696,7 +696,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info, fake_borrow_temp.into(), Rvalue::Ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, BorrowKind::Shallow, Place { local: base_place.local, projection }, ), diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 8631749a524be..f3c7119e13d2c 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -785,7 +785,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, source_info, Place::from(temp), - Rvalue::Ref(this.tcx.lifetimes.re_erased, borrow_kind, arg_place), + Rvalue::Ref(this.tcx.regions.erased, borrow_kind, arg_place), ); // See the comment in `expr_as_temp` and on the `rvalue_scopes` field for why diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 9b38ac1cc4ce7..a35520f57a5f2 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -296,7 +296,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { BorrowKind::Shared => unpack!(block = this.as_read_only_place(block, arg)), _ => unpack!(block = this.as_place(block, arg)), }; - let borrow = Rvalue::Ref(this.tcx.lifetimes.re_erased, borrow_kind, arg_place); + let borrow = Rvalue::Ref(this.tcx.regions.erased, borrow_kind, arg_place); this.cfg.push_assign(block, source_info, destination, borrow); block.unit() } diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 4926ff85de38d..c3fa7ab9601a9 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1751,7 +1751,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { projection: tcx.mk_place_elems(matched_place_ref.projection), }; let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty; - let fake_borrow_ty = tcx.mk_imm_ref(tcx.lifetimes.re_erased, fake_borrow_deref_ty); + let fake_borrow_ty = tcx.mk_imm_ref(tcx.regions.erased, fake_borrow_deref_ty); let mut fake_borrow_temp = LocalDecl::new(fake_borrow_ty, temp_span); fake_borrow_temp.internal = self.local_decls[matched_place.local].internal; fake_borrow_temp.local_info = ClearCrossCrate::Set(Box::new(LocalInfo::FakeBorrow)); @@ -1956,7 +1956,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { debug!("entering guard building context: {:?}", guard_frame); self.guard_context.push(guard_frame); - let re_erased = tcx.lifetimes.re_erased; + let re_erased = tcx.regions.erased; let scrutinee_source_info = self.source_info(scrutinee_span); for &(place, temp) in fake_borrows { let borrow = Rvalue::Ref(re_erased, BorrowKind::Shallow, place); @@ -2111,7 +2111,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Assign each of the bindings. Since we are binding for a // guard expression, this will never trigger moves out of the // candidate. - let re_erased = self.tcx.lifetimes.re_erased; + let re_erased = self.tcx.regions.erased; for binding in bindings { debug!("bind_matched_candidate_for_guard(binding={:?})", binding); let source_info = self.source_info(binding.span); @@ -2161,7 +2161,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { { debug!("bind_matched_candidate_for_arm_body(block={:?})", block); - let re_erased = self.tcx.lifetimes.re_erased; + let re_erased = self.tcx.regions.erased; // Assign each of the bindings. This may trigger moves out of the candidate. for binding in bindings { let source_info = self.source_info(binding.span); @@ -2249,7 +2249,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // This variable isn't mutated but has a name, so has to be // immutable to avoid the unused mut lint. mutability: Mutability::Not, - ty: tcx.mk_imm_ref(tcx.lifetimes.re_erased, var_ty), + ty: tcx.mk_imm_ref(tcx.regions.erased, var_ty), user_ty: None, source_info, internal: false, diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index 4536ecf17b813..45f585c9dc475 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -243,7 +243,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if !tcx.features().string_deref_patterns { bug!("matching on `String` went through without enabling string_deref_patterns"); } - let re_erased = tcx.lifetimes.re_erased; + let re_erased = tcx.regions.erased; let ref_string = self.temp(tcx.mk_imm_ref(re_erased, ty), test.span); let ref_str_ty = tcx.mk_imm_ref(re_erased, tcx.types.str_); let ref_str = self.temp(ref_str_ty, test.span); diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs index 070544446e348..7ad3680326027 100644 --- a/compiler/rustc_mir_build/src/thir/cx/mod.rs +++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs @@ -195,9 +195,7 @@ impl<'tcx> Cx<'tcx> { let ty = if fn_decl.c_variadic && index == fn_decl.inputs.len() { let va_list_did = self.tcx.require_lang_item(LangItem::VaList, Some(param.span)); - self.tcx - .type_of(va_list_did) - .subst(self.tcx, &[self.tcx.lifetimes.re_erased.into()]) + self.tcx.type_of(va_list_did).subst(self.tcx, &[self.tcx.regions.erased.into()]) } else { fn_sig.inputs()[index] }; diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index bd8ec82dffd17..2009b8544dbdf 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -616,7 +616,7 @@ where let ty = self.place_ty(self.place); let ref_ty = - tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }); + tcx.mk_ref(tcx.regions.erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }); let ref_place = self.new_temp(ref_ty); let unit_temp = Place::from(self.new_temp(tcx.mk_unit())); @@ -624,7 +624,7 @@ where statements: vec![self.assign( Place::from(ref_place), Rvalue::Ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, BorrowKind::Mut { allow_two_phase_borrow: false }, self.place, ), diff --git a/compiler/rustc_mir_transform/src/generator.rs b/compiler/rustc_mir_transform/src/generator.rs index 507e12d723894..968b5f0af1d3f 100644 --- a/compiler/rustc_mir_transform/src/generator.rs +++ b/compiler/rustc_mir_transform/src/generator.rs @@ -413,7 +413,7 @@ fn make_generator_state_argument_indirect<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Bo let gen_ty = body.local_decls.raw[1].ty; let ref_gen_ty = - tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty: gen_ty, mutbl: Mutability::Mut }); + tcx.mk_ref(tcx.regions.erased, ty::TypeAndMut { ty: gen_ty, mutbl: Mutability::Mut }); // Replace the by value generator argument body.local_decls.raw[1].ty = ref_gen_ty; diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 1525933aee3f4..234b26d8502bd 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -514,7 +514,7 @@ impl<'tcx> Inliner<'tcx> { let dest = if dest_needs_borrow(destination) { trace!("creating temp for return destination"); let dest = Rvalue::Ref( - self.tcx.lifetimes.re_erased, + self.tcx.regions.erased, BorrowKind::Mut { allow_two_phase_borrow: false }, destination, ); diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 4396a83e8b818..19d3e33959987 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -187,7 +187,7 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) // It's important that we do this first, before anything that depends on `dropee_ptr` // has been put into the body. let reborrow = Rvalue::Ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, BorrowKind::Mut { allow_two_phase_borrow: false }, tcx.mk_place_deref(dropee_ptr), ); @@ -482,13 +482,13 @@ impl<'tcx> CloneShimBuilder<'tcx> { let ref_loc = self.make_place( Mutability::Not, - tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Not }), + tcx.mk_ref(tcx.regions.erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Not }), ); // `let ref_loc: &ty = &src;` let statement = self.make_statement(StatementKind::Assign(Box::new(( ref_loc, - Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src), + Rvalue::Ref(tcx.regions.erased, BorrowKind::Shared, src), )))); // `let loc = Clone::clone(ref_loc);` @@ -701,7 +701,7 @@ fn build_call_shim<'tcx>( let ref_rcvr = local_decls.push( LocalDecl::new( tcx.mk_ref( - tcx.lifetimes.re_erased, + tcx.regions.erased, ty::TypeAndMut { ty: sig.inputs()[0], mutbl: hir::Mutability::Mut }, ), span, @@ -713,7 +713,7 @@ fn build_call_shim<'tcx>( source_info, kind: StatementKind::Assign(Box::new(( Place::from(ref_rcvr), - Rvalue::Ref(tcx.lifetimes.re_erased, borrow_kind, rcvr_place()), + Rvalue::Ref(tcx.regions.erased, borrow_kind, rcvr_place()), ))), }); Operand::Move(Place::from(ref_rcvr)) diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 5259b29993642..40e3bea5e71b7 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1360,7 +1360,7 @@ fn create_mono_items_for_default_impls<'tcx>( // we use the ReErased, which has no lifetime information associated with // it, to validate whether or not the impl is legal to instantiate at all. let only_region_params = |param: &ty::GenericParamDef, _: &_| match param.kind { - GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => tcx.regions.erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { unreachable!( "`own_requires_monomorphization` check means that \ diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 32222df25d496..2f0724df9f4b4 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -107,7 +107,7 @@ impl QueryContext for QueryCtxt<'_> { compute: impl FnOnce() -> R, ) -> R { // The `TyCtxt` stored in TLS has the same global interner lifetime - // as `self`, so we use `with_related_context` to relate the 'tcx lifetimes + // as `self`, so we use `with_related_context` to relate the 'tcx.regions // when accessing the `ImplicitCtxt`. tls::with_related_context(*self, move |current_icx| { if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) { diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs index 9fcaee3d5c169..ef40a93bc4b48 100644 --- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs +++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs @@ -740,9 +740,9 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio ty::Ref(region, ty0, ..) => { if options.contains(TransformTyOptions::GENERALIZE_POINTERS) { if ty.is_mutable_ptr() { - ty = tcx.mk_mut_ref(tcx.lifetimes.re_static, tcx.mk_unit()); + ty = tcx.mk_mut_ref(tcx.regions.re_static, tcx.mk_unit()); } else { - ty = tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.mk_unit()); + ty = tcx.mk_imm_ref(tcx.regions.re_static, tcx.mk_unit()); } } else { if ty.is_mutable_ptr() { diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 182d995c4eb06..9ce0276e1eef6 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -771,7 +771,7 @@ impl<'tcx> AutoTraitFinder<'tcx> { (None, Some(t_a)) => { selcx.infcx.register_region_obligation_with_cause( t_a, - selcx.infcx.tcx.lifetimes.re_static, + selcx.infcx.tcx.regions.re_static, &dummy_cause, ); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 060b025e6fce8..269939c4f24c3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1272,16 +1272,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { } // We map bounds to `&T` and `&mut T` let trait_pred_and_imm_ref = old_pred.map_bound(|trait_pred| { - ( - trait_pred, - self.tcx.mk_imm_ref(self.tcx.lifetimes.re_static, trait_pred.self_ty()), - ) + (trait_pred, self.tcx.mk_imm_ref(self.tcx.regions.re_static, trait_pred.self_ty())) }); let trait_pred_and_mut_ref = old_pred.map_bound(|trait_pred| { - ( - trait_pred, - self.tcx.mk_mut_ref(self.tcx.lifetimes.re_static, trait_pred.self_ty()), - ) + (trait_pred, self.tcx.mk_mut_ref(self.tcx.regions.re_static, trait_pred.self_ty())) }); let mk_result = |trait_pred_and_new_ty| { @@ -1440,7 +1434,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { object_ty: Ty<'tcx>, ) { let ty::Dynamic(predicates, _, ty::Dyn) = object_ty.kind() else { return; }; - let self_ref_ty = self.tcx.mk_imm_ref(self.tcx.lifetimes.re_erased, self_ty); + let self_ref_ty = self.tcx.mk_imm_ref(self.tcx.regions.erased, self_ty); for predicate in predicates.iter() { if !self.predicate_must_hold_modulo_regions( diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index b8ad1925e4eaa..7b3ee2f7fb6b7 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -549,7 +549,7 @@ fn virtual_call_violation_for_method<'tcx>( } } - let trait_object_ty = object_ty_for_trait(tcx, trait_def_id, tcx.lifetimes.re_static); + let trait_object_ty = object_ty_for_trait(tcx, trait_def_id, tcx.regions.re_static); // e.g., `Rc` let trait_object_receiver = diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 88b88d060d5d5..f53e7d7898e49 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -242,7 +242,7 @@ fn vtable_entries<'tcx>( // The method may have some early-bound lifetimes; add regions for those. let substs = trait_ref.map_bound(|trait_ref| { InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind { - GenericParamDefKind::Region => tcx.lifetimes.re_erased.into(), + GenericParamDefKind::Region => tcx.regions.erased.into(), GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { trait_ref.substs[param.index as usize] diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index ce3b33de60a4c..779925ae6f56e 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -556,8 +556,8 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime tcx.lifetimes.re_static, - chalk_ir::LifetimeData::Erased => tcx.lifetimes.re_erased, + chalk_ir::LifetimeData::Static => tcx.regions.re_static, + chalk_ir::LifetimeData::Erased => tcx.regions.erased, chalk_ir::LifetimeData::Phantom(void, _) => match *void {}, } } From 45a3b93d93e5ee5bca7e4b7b676835ea78c0bb50 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 20 Apr 2023 17:40:49 +0000 Subject: [PATCH 8/8] clippy: use `tcx.regions` new name --- src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs | 2 +- .../clippy/clippy_lints/src/methods/unnecessary_to_owned.rs | 2 +- src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs index 151c7f1d5d254..dbfe3fad639ef 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs @@ -16,7 +16,7 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, arg: &Expr<'_>, m let receiver_ty = cx.typeck_results().expr_ty(self_arg); let receiver_ty_adjusted = cx.typeck_results().expr_ty_adjusted(self_arg); let ref_receiver_ty = cx.tcx.mk_ref( - cx.tcx.lifetimes.re_erased, + cx.tcx.regions.erased, ty::TypeAndMut { ty: receiver_ty, mutbl: Mutability::Not, diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index 59282eb22e4d3..ae2cce0230135 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -266,7 +266,7 @@ fn check_other_call_arg<'tcx>( Some((n_refs, receiver_ty)) } else if trait_predicate.def_id() != deref_trait_id { Some((1, cx.tcx.mk_ref( - cx.tcx.lifetimes.re_erased, + cx.tcx.regions.erased, ty::TypeAndMut { ty: receiver_ty, mutbl: Mutability::Not, diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 0bb1775aae9cf..aa718c435055b 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -176,7 +176,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { ( preds.iter().any(|t| cx.tcx.is_diagnostic_item(sym::Borrow, t.def_id())), !preds.is_empty() && { - let ty_empty_region = cx.tcx.mk_imm_ref(cx.tcx.lifetimes.re_erased, ty); + let ty_empty_region = cx.tcx.mk_imm_ref(cx.tcx.regions.erased, ty); preds.iter().all(|t| { let ty_params = t.trait_ref.substs.iter().skip(1).collect::>(); implements_trait(cx, ty_empty_region, t.def_id(), &ty_params)