diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 49e999a3caa..807b5576976 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -189,7 +189,7 @@ pub(super) fn to_error_region_vid(&self, r: RegionVid) -> Option { /// Returns `true` if a closure is inferred to be an `FnMut` closure. fn is_closure_fn_mut(&self, fr: RegionVid) -> bool { if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref() - && let ty::BoundRegionKind::BrEnv = late_param.bound_region + && let ty::BoundRegionKind::ClosureEnv = late_param.bound_region && let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty { return args.as_closure().kind() == ty::ClosureKind::FnMut; diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 6ca7251295d..fffd5899966 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -301,7 +301,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option { } ty::ReLateParam(late_param) => match late_param.bound_region { - ty::BoundRegionKind::BrNamed(region_def_id, name) => { + ty::BoundRegionKind::Named(region_def_id, name) => { // Get the span to point to, even if we don't use the name. let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP); debug!( @@ -332,7 +332,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option { } } - ty::BoundRegionKind::BrEnv => { + ty::BoundRegionKind::ClosureEnv => { let def_ty = self.regioncx.universal_regions().defining_ty; let closure_kind = match def_ty { @@ -369,7 +369,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option { }) } - ty::BoundRegionKind::BrAnon => None, + ty::BoundRegionKind::Anon => None, }, ty::ReBound(..) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index dffdfb8ac1d..98180eca08b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1375,9 +1375,9 @@ fn check_terminator( let region_ctxt_fn = || { let reg_info = match br.kind { - ty::BoundRegionKind::BrAnon => sym::anon, - ty::BoundRegionKind::BrNamed(_, name) => name, - ty::BoundRegionKind::BrEnv => sym::env, + ty::BoundRegionKind::Anon => sym::anon, + ty::BoundRegionKind::Named(_, name) => name, + ty::BoundRegionKind::ClosureEnv => sym::env, }; RegionCtxt::LateBound(reg_info) diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index cfc14d146bd..545b2b38af5 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -271,9 +271,9 @@ fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty: .placeholder_region(self.type_checker.infcx, placeholder); let reg_info = match placeholder.bound.kind { - ty::BoundRegionKind::BrAnon => sym::anon, - ty::BoundRegionKind::BrNamed(_, name) => name, - ty::BoundRegionKind::BrEnv => sym::env, + ty::BoundRegionKind::Anon => sym::anon, + ty::BoundRegionKind::Named(_, name) => name, + ty::BoundRegionKind::ClosureEnv => sym::env, }; if cfg!(debug_assertions) { diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index fa44ffcd17d..b63144f560f 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -696,14 +696,13 @@ fn compute_inputs_and_output( let closure_sig = args.as_closure().sig(); let inputs_and_output = closure_sig.inputs_and_output(); let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - inputs_and_output - .bound_vars() - .iter() - .chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), + inputs_and_output.bound_vars().iter().chain(iter::once( + ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), + )), ); let br = ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }; let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); let closure_ty = tcx.closure_env_ty( @@ -751,15 +750,13 @@ fn compute_inputs_and_output( DefiningTy::CoroutineClosure(def_id, args) => { assert_eq!(self.mir_def.to_def_id(), def_id); let closure_sig = args.as_coroutine_closure().coroutine_closure_sig(); - let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - closure_sig - .bound_vars() - .iter() - .chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), - ); + let bound_vars = + tcx.mk_bound_variable_kinds_from_iter(closure_sig.bound_vars().iter().chain( + iter::once(ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv)), + )); let br = ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }; let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); let closure_kind = args.as_coroutine_closure().kind(); 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 c62028616e1..77c324183c3 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -2244,7 +2244,7 @@ fn param_env_with_gat_bounds<'tcx>( .into() } GenericParamDefKind::Lifetime => { - let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); + let kind = ty::BoundRegionKind::Named(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 680e12b02fc..1513ea7c9e8 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -178,19 +178,19 @@ pub fn check_intrinsic_type( let name_str = intrinsic_name.as_str(); let bound_vars = tcx.mk_bound_variable_kinds(&[ - ty::BoundVariableKind::Region(ty::BrAnon), - ty::BoundVariableKind::Region(ty::BrAnon), - ty::BoundVariableKind::Region(ty::BrEnv), + ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon), + ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon), + ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), ]); let mk_va_list_ty = |mutbl| { tcx.lang_items().va_list().map(|did| { let region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::ZERO, - kind: ty::BrAnon, + kind: ty::BoundRegionKind::Anon, }); let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::from_u32(2), - kind: ty::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }); let va_list_ty = tcx.type_of(did).instantiate(tcx, &[region.into()]); (Ty::new_ref(tcx, env_region, va_list_ty, mutbl), va_list_ty) @@ -509,7 +509,8 @@ pub fn check_intrinsic_type( ); let discriminant_def_id = assoc_items[0]; - let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon }; + let br = + ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon }; ( 1, 0, @@ -573,10 +574,14 @@ pub fn check_intrinsic_type( } sym::raw_eq => { - let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon }; + let br = + ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon }; let param_ty_lhs = Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0)); - let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon }; + let br = ty::BoundRegion { + var: ty::BoundVar::from_u32(1), + kind: ty::BoundRegionKind::Anon, + }; let param_ty_rhs = Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0)); (1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool) diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index e89c7fc9cb7..63a0e7d31c3 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -634,7 +634,7 @@ fn get_new_lifetime_name<'tcx>( .collect_referenced_late_bound_regions(poly_trait_ref) .into_iter() .filter_map(|lt| { - if let ty::BoundRegionKind::BrNamed(_, name) = lt { + if let ty::BoundRegionKind::Named(_, name) = lt { Some(name.as_str().to_string()) } else { None 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 dc3ef9952f0..cc55f57c46c 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -322,7 +322,7 @@ fn late_arg_as_bound_arg<'tcx>( let name = tcx.item_name(def_id); match param.kind { GenericParamKind::Lifetime { .. } => { - ty::BoundVariableKind::Region(ty::BrNamed(def_id, name)) + ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) } GenericParamKind::Type { .. } => { ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name)) @@ -337,7 +337,7 @@ fn late_arg_as_bound_arg<'tcx>( fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVariableKind { match param.kind { ty::GenericParamDefKind::Lifetime => { - ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(param.def_id, param.name)) + ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(param.def_id, param.name)) } ty::GenericParamDefKind::Type { .. } => { ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id, param.name)) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index 85ba88333f9..1cade402c54 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -644,7 +644,7 @@ fn lower_return_type_notation_ty( ty::GenericParamDefKind::Lifetime => { ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::from_usize(num_bound_vars), - kind: ty::BoundRegionKind::BrNamed(param.def_id, param.name), + kind: ty::BoundRegionKind::Named(param.def_id, param.name), }) .into() } @@ -830,8 +830,8 @@ fn visit_region(&mut self, re: ty::Region<'tcx>) -> Self::Result { } ty::ReBound(db, br) if db >= self.depth => { self.vars.insert(match br.kind { - ty::BrNamed(def_id, name) => (def_id, name), - ty::BrAnon | ty::BrEnv => { + ty::BoundRegionKind::Named(def_id, name) => (def_id, name), + ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => { let guar = self .cx .dcx() diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index d6534dbc694..ed39708981b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -314,7 +314,7 @@ pub fn lower_resolved_lifetime(&self, resolved: rbv::ResolvedArg) -> ty::Region< let name = lifetime_name(def_id); let br = ty::BoundRegion { var: ty::BoundVar::from_u32(index), - kind: ty::BrNamed(def_id.to_def_id(), name), + kind: ty::BoundRegionKind::Named(def_id.to_def_id(), name), }; ty::Region::new_bound(tcx, debruijn, br) } @@ -332,7 +332,7 @@ pub fn lower_resolved_lifetime(&self, resolved: rbv::ResolvedArg) -> ty::Region< ty::Region::new_late_param( tcx, scope.to_def_id(), - ty::BrNamed(id.to_def_id(), name), + ty::BoundRegionKind::Named(id.to_def_id(), name), ) // (*) -- not late-bound, won't change @@ -2449,15 +2449,17 @@ fn validate_late_bound_regions<'cx>( ) { for br in referenced_regions.difference(&constrained_regions) { let br_name = match *br { - ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon | ty::BrEnv => { - "an anonymous lifetime".to_string() - } - ty::BrNamed(_, name) => format!("lifetime `{name}`"), + ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime) + | ty::BoundRegionKind::Anon + | ty::BoundRegionKind::ClosureEnv => "an anonymous lifetime".to_string(), + ty::BoundRegionKind::Named(_, name) => format!("lifetime `{name}`"), }; let mut err = generate_err(&br_name); - if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon = *br { + if let ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime) + | ty::BoundRegionKind::Anon = *br + { // The only way for an anonymous lifetime to wind up // in the return type but **also** be unconstrained is // if it only appears in "associated types" in the diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index a49deaa2678..2026fd9a614 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -194,21 +194,21 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_> let panic_info_ty = tcx.type_of(panic_info_did).instantiate(tcx, &[ty::GenericArg::from( ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::from_u32(1), - kind: ty::BrAnon, + kind: ty::BoundRegionKind::Anon, }), )]); let panic_info_ref_ty = Ty::new_imm_ref( tcx, ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::ZERO, - kind: ty::BrAnon, + kind: ty::BoundRegionKind::Anon, }), panic_info_ty, ); let bounds = tcx.mk_bound_variable_kinds(&[ - ty::BoundVariableKind::Region(ty::BrAnon), - ty::BoundVariableKind::Region(ty::BrAnon), + ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon), + ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon), ]); let expected_sig = ty::Binder::bind_with_vars( tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, ExternAbi::Rust), diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 2d5e8fdd720..175fca327f3 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -381,7 +381,7 @@ fn analyze_closure( let closure_env_region: ty::Region<'_> = ty::Region::new_bound(self.tcx, ty::INNERMOST, ty::BoundRegion { var: ty::BoundVar::ZERO, - kind: ty::BoundRegionKind::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }); let num_args = args @@ -441,7 +441,7 @@ fn analyze_closure( rustc_abi::ExternAbi::Rust, ), self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region( - ty::BoundRegionKind::BrEnv, + ty::BoundRegionKind::ClosureEnv, )]), ), ); diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index c9d8ebecef0..f87c43a0ecd 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -753,7 +753,7 @@ fn canonical_var_for_region( r: ty::Region<'tcx>, ) -> ty::Region<'tcx> { let var = self.canonical_var(info, r.into()); - let br = ty::BoundRegion { var, kind: ty::BrAnon }; + let br = ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }; ty::Region::new_bound(self.cx(), self.binder_index, br) } diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 026826021c8..002ab027982 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -154,7 +154,7 @@ fn check_fn(tcx: TyCtxt<'_>, parent_def_id: LocalDefId) { } for bound_var in sig.bound_vars() { - let ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, name)) = bound_var + let ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) = bound_var else { span_bug!(tcx.def_span(parent_def_id), "unexpected non-lifetime binder on fn sig"); }; @@ -215,7 +215,7 @@ fn visit_binder>>(&mut self, t: &ty::Binder<'tcx, for arg in t.bound_vars() { let arg: ty::BoundVariableKind = arg; match arg { - ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, ..)) + ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, ..)) | ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, _)) => { added.push(def_id); let unique = self.in_scope_parameters.insert(def_id, ParamKind::Late); @@ -318,7 +318,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) { ParamKind::Free(def_id, name) => ty::Region::new_late_param( self.tcx, self.parent_def_id.to_def_id(), - ty::BoundRegionKind::BrNamed(def_id, name), + ty::BoundRegionKind::Named(def_id, name), ), // Totally ignore late bound args from binders. ParamKind::Late => return true, @@ -489,11 +489,11 @@ fn extract_def_id_from_arg<'tcx>( ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id, ty::ReBound( _, - ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. }, + ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. }, ) | ty::ReLateParam(ty::LateParamRegion { scope: _, - bound_region: ty::BoundRegionKind::BrNamed(def_id, ..), + bound_region: ty::BoundRegionKind::Named(def_id, ..), }) => def_id, _ => unreachable!(), }, @@ -558,11 +558,11 @@ fn regions( ty::ReEarlyParam(ebr) => self.generics.region_param(ebr, self.tcx).def_id, ty::ReBound( _, - ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. }, + ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. }, ) | ty::ReLateParam(ty::LateParamRegion { scope: _, - bound_region: ty::BoundRegionKind::BrNamed(def_id, ..), + bound_region: ty::BoundRegionKind::Named(def_id, ..), }) => def_id, _ => { return Ok(a); diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index c34bdf041af..86abeb50382 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -317,7 +317,10 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> { pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self { let inner = tcx.fold_regions(ty, |r, depth| match r.kind() { ty::ReVar(vid) => { - let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon }; + let br = ty::BoundRegion { + var: ty::BoundVar::new(vid.index()), + kind: ty::BoundRegionKind::Anon, + }; ty::Region::new_bound(tcx, depth, br) } _ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"), diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 59c7b51ae68..c55733da7b3 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1059,7 +1059,7 @@ fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> { .map(|v| { mk(ty::ReBound(ty::DebruijnIndex::from(i), ty::BoundRegion { var: ty::BoundVar::from(v), - kind: ty::BrAnon, + kind: ty::BoundRegionKind::Anon, })) }) .collect() @@ -1982,7 +1982,10 @@ pub fn is_suitable_region( region = self.map_opaque_lifetime_to_parent_lifetime(def_id); continue; } - break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into()))); + break ( + scope, + ty::BoundRegionKind::Named(def_id.into(), self.item_name(def_id.into())), + ); }; let is_impl_item = match self.hir_node_by_def_id(suitable_region_binding_scope) { @@ -3091,7 +3094,7 @@ pub fn map_opaque_lifetime_to_parent_lifetime( return ty::Region::new_late_param( self, new_parent.to_def_id(), - ty::BoundRegionKind::BrNamed( + ty::BoundRegionKind::Named( lbv.to_def_id(), self.item_name(lbv.to_def_id()), ), diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index b5a77b3c942..7adbd556141 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -399,7 +399,7 @@ fn replace_region(&mut self, br: ty::BoundRegion) -> ty::Region<'tcx> { let index = entry.index(); let var = ty::BoundVar::from_usize(index); let kind = entry - .or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon)) + .or_insert_with(|| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)) .expect_region(); let br = ty::BoundRegion { var, kind }; ty::Region::new_bound(self.tcx, ty::INNERMOST, br) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index ce02d0f308e..6d9ba3d60e3 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -84,7 +84,6 @@ RegionOutlivesPredicate, SubtypePredicate, ToPolyTraitRef, TraitPredicate, TraitRef, TypeOutlivesPredicate, }; -pub use self::region::BoundRegionKind::*; pub use self::region::{ BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, Region, RegionKind, RegionVid, }; @@ -895,7 +894,7 @@ fn with_updated_universe(self, ui: UniverseIndex) -> Self { } fn new(ui: UniverseIndex, var: BoundVar) -> Self { - Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::BrAnon } } + Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::Anon } } } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index d8725cb6ba0..039c988f5c9 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2483,7 +2483,7 @@ pub fn pretty_print_region(&mut self, region: ty::Region<'tcx>) -> Result<(), fm | ty::RePlaceholder(ty::Placeholder { bound: ty::BoundRegion { kind: br, .. }, .. }) => { - if let ty::BrNamed(_, name) = br + if let ty::BoundRegionKind::Named(_, name) = br && br.is_named() { p!(write("{}", name)); @@ -2569,7 +2569,7 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { // If this is an anonymous placeholder, don't rename. Otherwise, in some // async fns, we get a `for<'r> Send` bound match kind { - ty::BrAnon | ty::BrEnv => r, + ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => r, _ => { // Index doesn't matter, since this is just for naming and these never get bound let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind }; @@ -2688,12 +2688,13 @@ fn name_by_region_index( binder_level_idx: ty::DebruijnIndex, br: ty::BoundRegion| { let (name, kind) = match br.kind { - ty::BrAnon | ty::BrEnv => { + ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => { let name = next_name(self); if let Some(lt_idx) = lifetime_idx { if lt_idx > binder_level_idx { - let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name); + let kind = + ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name); return ty::Region::new_bound( tcx, ty::INNERMOST, @@ -2702,14 +2703,14 @@ fn name_by_region_index( } } - (name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)) + (name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name)) } - ty::BrNamed(def_id, kw::UnderscoreLifetime | kw::Empty) => { + ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime | kw::Empty) => { let name = next_name(self); if let Some(lt_idx) = lifetime_idx { if lt_idx > binder_level_idx { - let kind = ty::BrNamed(def_id, name); + let kind = ty::BoundRegionKind::Named(def_id, name); return ty::Region::new_bound( tcx, ty::INNERMOST, @@ -2718,9 +2719,9 @@ fn name_by_region_index( } } - (name, ty::BrNamed(def_id, name)) + (name, ty::BoundRegionKind::Named(def_id, name)) } - ty::BrNamed(_, name) => { + ty::BoundRegionKind::Named(_, name) => { if let Some(lt_idx) = lifetime_idx { if lt_idx > binder_level_idx { let kind = br.kind; diff --git a/compiler/rustc_middle/src/ty/region.rs b/compiler/rustc_middle/src/ty/region.rs index be4772e888f..60c2c322d4f 100644 --- a/compiler/rustc_middle/src/ty/region.rs +++ b/compiler/rustc_middle/src/ty/region.rs @@ -56,7 +56,7 @@ pub fn new_bound( bound_region: ty::BoundRegion, ) -> Region<'tcx> { // Use a pre-interned one when possible. - if let ty::BoundRegion { var, kind: ty::BrAnon } = bound_region + if let ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon } = bound_region && let Some(inner) = tcx.lifetimes.re_late_bounds.get(debruijn.as_usize()) && let Some(re) = inner.get(var.as_usize()).copied() { @@ -147,7 +147,7 @@ fn new_bound( } fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self { - Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon }) + Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }) } fn new_static(tcx: TyCtxt<'tcx>) -> Self { @@ -311,7 +311,7 @@ pub fn opt_param_def_id(self, tcx: TyCtxt<'tcx>, binding_item: DefId) -> Option< Some(tcx.generics_of(binding_item).region_param(ebr, tcx).def_id) } ty::ReLateParam(ty::LateParamRegion { - bound_region: ty::BoundRegionKind::BrNamed(def_id, _), + bound_region: ty::BoundRegionKind::Named(def_id, _), .. }) => Some(def_id), _ => None, @@ -355,7 +355,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { /// Similar to a placeholder region as we create `LateParam` regions when entering a binder /// except they are always in the root universe and instead of using a boundvar to distinguish /// between others we use the `DefId` of the parameter. For this reason the `bound_region` field -/// should basically always be `BoundRegionKind::BrNamed` as otherwise there is no way of telling +/// should basically always be `BoundRegionKind::Named` as otherwise there is no way of telling /// different parameters apart. pub struct LateParamRegion { pub scope: DefId, @@ -366,17 +366,17 @@ pub struct LateParamRegion { #[derive(HashStable)] pub enum BoundRegionKind { /// An anonymous region parameter for a given fn (&T) - BrAnon, + Anon, /// Named region parameters for functions (a in &'a T) /// /// The `DefId` is needed to distinguish free regions in /// the event of shadowing. - BrNamed(DefId, Symbol), + Named(DefId, Symbol), /// Anonymous region for the implicit env pointer parameter /// to a closure - BrEnv, + ClosureEnv, } #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] @@ -399,9 +399,9 @@ fn assert_eq(self, var: ty::BoundVariableKind) { impl core::fmt::Debug for BoundRegion { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self.kind { - BoundRegionKind::BrAnon => write!(f, "{:?}", self.var), - BoundRegionKind::BrEnv => write!(f, "{:?}.Env", self.var), - BoundRegionKind::BrNamed(def, symbol) => { + BoundRegionKind::Anon => write!(f, "{:?}", self.var), + BoundRegionKind::ClosureEnv => write!(f, "{:?}.Env", self.var), + BoundRegionKind::Named(def, symbol) => { write!(f, "{:?}.Named({:?}, {:?})", self.var, def, symbol) } } @@ -411,9 +411,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { impl BoundRegionKind { pub fn is_named(&self) -> bool { match *self { - BoundRegionKind::BrNamed(_, name) => { - name != kw::UnderscoreLifetime && name != kw::Empty - } + BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty, _ => false, } } @@ -421,7 +419,7 @@ pub fn is_named(&self) -> bool { pub fn get_name(&self) -> Option { if self.is_named() { match *self { - BoundRegionKind::BrNamed(_, name) => return Some(name), + BoundRegionKind::Named(_, name) => return Some(name), _ => unreachable!(), } } @@ -431,7 +429,7 @@ pub fn get_name(&self) -> Option { pub fn get_id(&self) -> Option { match *self { - BoundRegionKind::BrNamed(id, _) => Some(id), + BoundRegionKind::Named(id, _) => Some(id), _ => None, } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 3268dabd165..e48fac6c7e8 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -62,15 +62,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { impl fmt::Debug for ty::BoundRegionKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { - ty::BrAnon => write!(f, "BrAnon"), - ty::BrNamed(did, name) => { + ty::BoundRegionKind::Anon => write!(f, "BrAnon"), + ty::BoundRegionKind::Named(did, name) => { if did.is_crate_root() { write!(f, "BrNamed({name})") } else { write!(f, "BrNamed({did:?}, {name})") } } - ty::BrEnv => write!(f, "BrEnv"), + ty::BoundRegionKind::ClosureEnv => write!(f, "BrEnv"), } } } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 83276808a28..d6fd2b6b287 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -735,8 +735,11 @@ pub fn bound_coroutine_hidden_types( let ty = self.fold_regions(decl.ty, |re, debruijn| { assert_eq!(re, self.lifetimes.re_erased); let var = ty::BoundVar::from_usize(vars.len()); - vars.push(ty::BoundVariableKind::Region(ty::BrAnon)); - ty::Region::new_bound(self, debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) + vars.push(ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)); + ty::Region::new_bound(self, debruijn, ty::BoundRegion { + var, + kind: ty::BoundRegionKind::Anon, + }) }); ty::EarlyBinder::bind(ty::Binder::bind_with_vars( ty, diff --git a/compiler/rustc_smir/src/rustc_internal/internal.rs b/compiler/rustc_smir/src/rustc_internal/internal.rs index 655553de864..dec2a77619b 100644 --- a/compiler/rustc_smir/src/rustc_internal/internal.rs +++ b/compiler/rustc_smir/src/rustc_internal/internal.rs @@ -335,12 +335,12 @@ fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T< ), }), BoundVariableKind::Region(kind) => rustc_ty::BoundVariableKind::Region(match kind { - BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::BrAnon, - BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::BrNamed( + BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::Anon, + BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::Named( def.0.internal(tables, tcx), Symbol::intern(symbol), ), - BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::BrEnv, + BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::ClosureEnv, }), BoundVariableKind::Const => rustc_ty::BoundVariableKind::Const, } diff --git a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs index 62c762dfb9b..a4f61313001 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/ty.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/ty.rs @@ -243,11 +243,11 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T { use stable_mir::ty::BoundRegionKind; match self { - ty::BoundRegionKind::BrAnon => BoundRegionKind::BrAnon, - ty::BoundRegionKind::BrNamed(def_id, symbol) => { + ty::BoundRegionKind::Anon => BoundRegionKind::BrAnon, + ty::BoundRegionKind::Named(def_id, symbol) => { BoundRegionKind::BrNamed(tables.br_named_def(*def_id), symbol.to_string()) } - ty::BoundRegionKind::BrEnv => BoundRegionKind::BrEnv, + ty::BoundRegionKind::ClosureEnv => BoundRegionKind::BrEnv, } } } diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 7c10e72ff23..05b4ff327a9 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -290,7 +290,7 @@ fn print_region(&mut self, region: ty::Region<'_>) -> Result<(), PrintError> { // Bound lifetimes use indices starting at 1, // see `BinderLevel` for more details. - ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => { + ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }) => { let binder = &self.binders[self.binders.len() - 1 - debruijn.index()]; let depth = binder.lifetime_depths.start + var.as_u32(); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs index 2ecd28f4868..cd621fd1a39 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs @@ -100,7 +100,10 @@ fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) -> Self::Result { // Find the index of the named region that was part of the // error. We will then search the function parameters for a bound // region at the right depth with the same index - (Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => { + ( + Some(rbv::ResolvedArg::EarlyBound(id)), + ty::BoundRegionKind::Named(def_id, _), + ) => { debug!("EarlyBound id={:?} def_id={:?}", id, def_id); if id.to_def_id() == def_id { return ControlFlow::Break(arg); @@ -112,7 +115,7 @@ fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) -> Self::Result { // region at the right depth with the same index ( Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)), - ty::BrNamed(def_id, _), + ty::BoundRegionKind::Named(def_id, _), ) => { debug!( "FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", @@ -191,14 +194,17 @@ fn nested_visit_map(&mut self) -> Map<'tcx> { fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) -> Self::Result { match (self.tcx.named_bound_var(lifetime.hir_id), self.bound_region) { // the lifetime of the TyPath! - (Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => { + (Some(rbv::ResolvedArg::EarlyBound(id)), ty::BoundRegionKind::Named(def_id, _)) => { debug!("EarlyBound id={:?} def_id={:?}", id, def_id); if id.to_def_id() == def_id { return ControlFlow::Break(()); } } - (Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)), ty::BrNamed(def_id, _)) => { + ( + Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)), + ty::BoundRegionKind::Named(def_id, _), + ) => { debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index,); debug!("id={:?}", id); debug!("def_id={:?}", def_id); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs index 7cf98183774..9fa5a8ac637 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs @@ -60,7 +60,7 @@ pub(super) fn try_report_named_anon_conflict(&self) -> Option> { let is_impl_item = region_info.is_impl_item; match br { - ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon => {} + ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime) | ty::BoundRegionKind::Anon => {} _ => { /* not an anonymous region */ debug!("try_report_named_anon_conflict: not an anonymous region"); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs index f2a7da707b8..7fcd3c847e3 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs @@ -29,16 +29,16 @@ pub(super) fn try_report_placeholder_relation(&self) -> Option> { )) => { let span = *span; let (sub_span, sub_symbol) = match sub_name { - ty::BrNamed(def_id, symbol) => { + ty::BoundRegionKind::Named(def_id, symbol) => { (Some(self.tcx().def_span(def_id)), Some(symbol)) } - ty::BrAnon | ty::BrEnv => (None, None), + ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None), }; let (sup_span, sup_symbol) = match sup_name { - ty::BrNamed(def_id, symbol) => { + ty::BoundRegionKind::Named(def_id, symbol) => { (Some(self.tcx().def_span(def_id)), Some(symbol)) } - ty::BrAnon | ty::BrEnv => (None, None), + ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None), }; let diag = match (sub_span, sup_span, sub_symbol, sup_symbol) { (Some(sub_span), Some(sup_span), Some(&sub_symbol), Some(&sup_symbol)) => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs index 90b354305ff..75054b22153 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/util.rs @@ -46,7 +46,7 @@ pub fn find_param_with_region<'tcx>( ty::ReLateParam(late_param) => (late_param.scope, late_param.bound_region), ty::ReEarlyParam(ebr) => { let region_def = tcx.generics_of(generic_param_scope).region_param(ebr, tcx).def_id; - (tcx.parent(region_def), ty::BoundRegionKind::BrNamed(region_def, ebr.name)) + (tcx.parent(region_def), ty::BoundRegionKind::Named(region_def, ebr.name)) } _ => return None, // not a free region }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 438639e72f9..9fd7dccc57c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -993,7 +993,7 @@ fn report_sub_sup_conflict( fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'_> { let br_string = |br: ty::BoundRegionKind| { let mut s = match br { - ty::BrNamed(_, name) => name.to_string(), + ty::BoundRegionKind::Named(_, name) => name.to_string(), _ => String::new(), }; if !s.is_empty() { @@ -1103,7 +1103,7 @@ fn msg_span_from_named_region<'tcx>( ("the anonymous lifetime defined here".to_string(), Some(ty.span)) } else { match fr.bound_region { - ty::BoundRegionKind::BrNamed(param_def_id, name) => { + ty::BoundRegionKind::Named(param_def_id, name) => { let span = tcx.def_span(param_def_id); let text = if name == kw::UnderscoreLifetime { "the anonymous lifetime as defined here".to_string() @@ -1112,7 +1112,7 @@ fn msg_span_from_named_region<'tcx>( }; (text, Some(span)) } - ty::BrAnon => ( + ty::BoundRegionKind::Anon => ( "the anonymous lifetime as defined here".to_string(), Some(tcx.def_span(generic_param_scope)), ), @@ -1125,11 +1125,11 @@ fn msg_span_from_named_region<'tcx>( } ty::ReStatic => ("the static lifetime".to_owned(), alt_span), ty::RePlaceholder(ty::PlaceholderRegion { - bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, name), .. }, + bound: ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, name), .. }, .. }) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))), ty::RePlaceholder(ty::PlaceholderRegion { - bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon, .. }, + bound: ty::BoundRegion { kind: ty::BoundRegionKind::Anon, .. }, .. }) => ("an anonymous lifetime".to_owned(), None), _ => bug!("{:?}", region), diff --git a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs index 67463b9884c..cc0a637a78e 100644 --- a/compiler/rustc_trait_selection/src/errors/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/errors/note_and_explain.rs @@ -48,7 +48,7 @@ fn new<'tcx>( } else { let scope = fr.scope.expect_local(); match fr.bound_region { - ty::BoundRegionKind::BrNamed(_, name) => { + ty::BoundRegionKind::Named(_, name) => { let span = if let Some(param) = tcx .hir() .get_generics(scope) @@ -64,7 +64,7 @@ fn new<'tcx>( (Some(span), "as_defined", name.to_string()) } } - ty::BrAnon => { + ty::BoundRegionKind::Anon => { let span = Some(tcx.def_span(scope)); (span, "defined_here", String::new()) } diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 3cd11d7c8e8..a98871b2d60 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -540,7 +540,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) { universe: self.universe, bound: ty::BoundRegion { var: self.next_var(), - kind: ty::BoundRegionKind::BrAnon, + kind: ty::BoundRegionKind::Anon, }, }), ) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index e7d3004aa20..afa5abeadb5 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -660,7 +660,7 @@ fn confirm_object_candidate( .into() } GenericParamDefKind::Lifetime => { - let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); + let kind = ty::BoundRegionKind::Named(param.def_id, param.name); let bound_var = ty::BoundVariableKind::Region(kind); bound_vars.push(bound_var); ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index ac9ac71f941..711480252ec 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -3183,7 +3183,7 @@ fn bind_coroutine_hidden_types_above<'tcx>( ty::ReErased => { let br = ty::BoundRegion { var: ty::BoundVar::from_u32(counter), - kind: ty::BrAnon, + kind: ty::BoundRegionKind::Anon, }; counter += 1; ty::Region::new_bound(tcx, current_depth, br) @@ -3196,9 +3196,11 @@ fn bind_coroutine_hidden_types_above<'tcx>( bty.instantiate(tcx, args) }) .collect(); - let bound_vars = - tcx.mk_bound_variable_kinds_from_iter(bound_vars.iter().chain( - (num_bound_variables..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon)), - )); + let bound_vars = tcx.mk_bound_variable_kinds_from_iter( + bound_vars.iter().chain( + (num_bound_variables..counter) + .map(|_| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)), + ), + ); ty::Binder::bind_with_vars(hidden_types, bound_vars) } diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 42b710687cf..0838978a891 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -76,12 +76,13 @@ fn fn_sig_for_fn_abi<'tcx>( ty::Closure(def_id, args) => { let sig = args.as_closure().sig(); - let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), - ); + let bound_vars = + tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once( + ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), + ))); let br = ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }; let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); let env_ty = tcx.closure_env_ty( @@ -105,12 +106,13 @@ fn fn_sig_for_fn_abi<'tcx>( ty::CoroutineClosure(def_id, args) => { let coroutine_ty = Ty::new_coroutine_closure(tcx, def_id, args); let sig = args.as_coroutine_closure().coroutine_closure_sig(); - let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))), - ); + let bound_vars = + tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once( + ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), + ))); let br = ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }; let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br); // When this `CoroutineClosure` comes from a `ConstructCoroutineInClosureShim`, @@ -161,11 +163,11 @@ fn fn_sig_for_fn_abi<'tcx>( let sig = args.as_coroutine().sig(); let bound_vars = tcx.mk_bound_variable_kinds_from_iter(iter::once( - ty::BoundVariableKind::Region(ty::BrEnv), + ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv), )); let br = ty::BoundRegion { var: ty::BoundVar::from_usize(bound_vars.len() - 1), - kind: ty::BoundRegionKind::BrEnv, + kind: ty::BoundRegionKind::ClosureEnv, }; let env_ty = Ty::new_mut_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), ty); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 00082b18a04..a133b4e5f5e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -304,7 +304,9 @@ pub(crate) fn clean_middle_region(region: ty::Region<'_>) -> Option { match *region { ty::ReStatic => Some(Lifetime::statik()), _ if !region.has_name() => None, - ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)), + ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => { + Some(Lifetime(name)) + } ty::ReEarlyParam(ref data) => Some(Lifetime(data.name)), ty::ReBound(..) | ty::ReLateParam(..) @@ -1896,7 +1898,9 @@ fn clean_trait_object_lifetime_bound<'tcx>( match *region { ty::ReStatic => Some(Lifetime::statik()), ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)), - ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => { + ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) + if name != kw::Empty => + { Some(Lifetime(name)) } ty::ReEarlyParam(_) @@ -2141,7 +2145,7 @@ pub(crate) fn clean_middle_ty<'tcx>( .iter() .flat_map(|pred| pred.bound_vars()) .filter_map(|var| match var { - ty::BoundVariableKind::Region(ty::BrNamed(def_id, name)) + ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) if name != kw::UnderscoreLifetime => { Some(GenericParamDef::lifetime(def_id, name)) @@ -3118,7 +3122,7 @@ fn clean_bound_vars(bound_vars: &ty::List) -> Vec { Some(GenericParamDef::lifetime(def_id, name))