Skip to content

Commit d458f85

Browse files
ty::BrK -> ty::BoundRegionKind::K
1 parent 883f870 commit d458f85

File tree

37 files changed

+164
-139
lines changed

37 files changed

+164
-139
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
189189
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
190190
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
191191
if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref()
192-
&& let ty::BoundRegionKind::BrEnv = late_param.bound_region
192+
&& let ty::BoundRegionKind::ClosureEnv = late_param.bound_region
193193
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
194194
{
195195
return args.as_closure().kind() == ty::ClosureKind::FnMut;

Diff for: compiler/rustc_borrowck/src/diagnostics/region_name.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
301301
}
302302

303303
ty::ReLateParam(late_param) => match late_param.bound_region {
304-
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
304+
ty::BoundRegionKind::Named(region_def_id, name) => {
305305
// Get the span to point to, even if we don't use the name.
306306
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
307307
debug!(
@@ -332,7 +332,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
332332
}
333333
}
334334

335-
ty::BoundRegionKind::BrEnv => {
335+
ty::BoundRegionKind::ClosureEnv => {
336336
let def_ty = self.regioncx.universal_regions().defining_ty;
337337

338338
let closure_kind = match def_ty {
@@ -369,7 +369,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
369369
})
370370
}
371371

372-
ty::BoundRegionKind::BrAnon => None,
372+
ty::BoundRegionKind::Anon => None,
373373
},
374374

375375
ty::ReBound(..)

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13751375

13761376
let region_ctxt_fn = || {
13771377
let reg_info = match br.kind {
1378-
ty::BoundRegionKind::BrAnon => sym::anon,
1379-
ty::BoundRegionKind::BrNamed(_, name) => name,
1380-
ty::BoundRegionKind::BrEnv => sym::env,
1378+
ty::BoundRegionKind::Anon => sym::anon,
1379+
ty::BoundRegionKind::Named(_, name) => name,
1380+
ty::BoundRegionKind::ClosureEnv => sym::env,
13811381
};
13821382

13831383
RegionCtxt::LateBound(reg_info)

Diff for: compiler/rustc_borrowck/src/type_check/relate_tys.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
271271
.placeholder_region(self.type_checker.infcx, placeholder);
272272

273273
let reg_info = match placeholder.bound.kind {
274-
ty::BoundRegionKind::BrAnon => sym::anon,
275-
ty::BoundRegionKind::BrNamed(_, name) => name,
276-
ty::BoundRegionKind::BrEnv => sym::env,
274+
ty::BoundRegionKind::Anon => sym::anon,
275+
ty::BoundRegionKind::Named(_, name) => name,
276+
ty::BoundRegionKind::ClosureEnv => sym::env,
277277
};
278278

279279
if cfg!(debug_assertions) {

Diff for: compiler/rustc_borrowck/src/universal_regions.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -696,14 +696,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
696696
let closure_sig = args.as_closure().sig();
697697
let inputs_and_output = closure_sig.inputs_and_output();
698698
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
699-
inputs_and_output
700-
.bound_vars()
701-
.iter()
702-
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
699+
inputs_and_output.bound_vars().iter().chain(iter::once(
700+
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
701+
)),
703702
);
704703
let br = ty::BoundRegion {
705704
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
706-
kind: ty::BrEnv,
705+
kind: ty::BoundRegionKind::ClosureEnv,
707706
};
708707
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
709708
let closure_ty = tcx.closure_env_ty(
@@ -751,15 +750,13 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
751750
DefiningTy::CoroutineClosure(def_id, args) => {
752751
assert_eq!(self.mir_def.to_def_id(), def_id);
753752
let closure_sig = args.as_coroutine_closure().coroutine_closure_sig();
754-
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
755-
closure_sig
756-
.bound_vars()
757-
.iter()
758-
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
759-
);
753+
let bound_vars =
754+
tcx.mk_bound_variable_kinds_from_iter(closure_sig.bound_vars().iter().chain(
755+
iter::once(ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv)),
756+
));
760757
let br = ty::BoundRegion {
761758
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
762-
kind: ty::BrEnv,
759+
kind: ty::BoundRegionKind::ClosureEnv,
763760
};
764761
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
765762
let closure_kind = args.as_coroutine_closure().kind();

Diff for: compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ fn param_env_with_gat_bounds<'tcx>(
22442244
.into()
22452245
}
22462246
GenericParamDefKind::Lifetime => {
2247-
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
2247+
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
22482248
let bound_var = ty::BoundVariableKind::Region(kind);
22492249
bound_vars.push(bound_var);
22502250
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {

Diff for: compiler/rustc_hir_analysis/src/check/intrinsic.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,19 @@ pub fn check_intrinsic_type(
178178
let name_str = intrinsic_name.as_str();
179179

180180
let bound_vars = tcx.mk_bound_variable_kinds(&[
181-
ty::BoundVariableKind::Region(ty::BrAnon),
182-
ty::BoundVariableKind::Region(ty::BrAnon),
183-
ty::BoundVariableKind::Region(ty::BrEnv),
181+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
182+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
183+
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
184184
]);
185185
let mk_va_list_ty = |mutbl| {
186186
tcx.lang_items().va_list().map(|did| {
187187
let region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
188188
var: ty::BoundVar::ZERO,
189-
kind: ty::BrAnon,
189+
kind: ty::BoundRegionKind::Anon,
190190
});
191191
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
192192
var: ty::BoundVar::from_u32(2),
193-
kind: ty::BrEnv,
193+
kind: ty::BoundRegionKind::ClosureEnv,
194194
});
195195
let va_list_ty = tcx.type_of(did).instantiate(tcx, &[region.into()]);
196196
(Ty::new_ref(tcx, env_region, va_list_ty, mutbl), va_list_ty)
@@ -509,7 +509,8 @@ pub fn check_intrinsic_type(
509509
);
510510
let discriminant_def_id = assoc_items[0];
511511

512-
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
512+
let br =
513+
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
513514
(
514515
1,
515516
0,
@@ -573,10 +574,14 @@ pub fn check_intrinsic_type(
573574
}
574575

575576
sym::raw_eq => {
576-
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
577+
let br =
578+
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
577579
let param_ty_lhs =
578580
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
579-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };
581+
let br = ty::BoundRegion {
582+
var: ty::BoundVar::from_u32(1),
583+
kind: ty::BoundRegionKind::Anon,
584+
};
580585
let param_ty_rhs =
581586
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
582587
(1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool)

Diff for: compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ fn get_new_lifetime_name<'tcx>(
634634
.collect_referenced_late_bound_regions(poly_trait_ref)
635635
.into_iter()
636636
.filter_map(|lt| {
637-
if let ty::BoundRegionKind::BrNamed(_, name) = lt {
637+
if let ty::BoundRegionKind::Named(_, name) = lt {
638638
Some(name.as_str().to_string())
639639
} else {
640640
None

Diff for: compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn late_arg_as_bound_arg<'tcx>(
322322
let name = tcx.item_name(def_id);
323323
match param.kind {
324324
GenericParamKind::Lifetime { .. } => {
325-
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
325+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
326326
}
327327
GenericParamKind::Type { .. } => {
328328
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name))
@@ -337,7 +337,7 @@ fn late_arg_as_bound_arg<'tcx>(
337337
fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVariableKind {
338338
match param.kind {
339339
ty::GenericParamDefKind::Lifetime => {
340-
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(param.def_id, param.name))
340+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(param.def_id, param.name))
341341
}
342342
ty::GenericParamDefKind::Type { .. } => {
343343
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id, param.name))

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
644644
ty::GenericParamDefKind::Lifetime => {
645645
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
646646
var: ty::BoundVar::from_usize(num_bound_vars),
647-
kind: ty::BoundRegionKind::BrNamed(param.def_id, param.name),
647+
kind: ty::BoundRegionKind::Named(param.def_id, param.name),
648648
})
649649
.into()
650650
}
@@ -830,8 +830,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'_, 't
830830
}
831831
ty::ReBound(db, br) if db >= self.depth => {
832832
self.vars.insert(match br.kind {
833-
ty::BrNamed(def_id, name) => (def_id, name),
834-
ty::BrAnon | ty::BrEnv => {
833+
ty::BoundRegionKind::Named(def_id, name) => (def_id, name),
834+
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => {
835835
let guar = self
836836
.cx
837837
.dcx()

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
314314
let name = lifetime_name(def_id);
315315
let br = ty::BoundRegion {
316316
var: ty::BoundVar::from_u32(index),
317-
kind: ty::BrNamed(def_id.to_def_id(), name),
317+
kind: ty::BoundRegionKind::Named(def_id.to_def_id(), name),
318318
};
319319
ty::Region::new_bound(tcx, debruijn, br)
320320
}
@@ -332,7 +332,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
332332
ty::Region::new_late_param(
333333
tcx,
334334
scope.to_def_id(),
335-
ty::BrNamed(id.to_def_id(), name),
335+
ty::BoundRegionKind::Named(id.to_def_id(), name),
336336
)
337337

338338
// (*) -- not late-bound, won't change
@@ -2449,15 +2449,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24492449
) {
24502450
for br in referenced_regions.difference(&constrained_regions) {
24512451
let br_name = match *br {
2452-
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon | ty::BrEnv => {
2453-
"an anonymous lifetime".to_string()
2454-
}
2455-
ty::BrNamed(_, name) => format!("lifetime `{name}`"),
2452+
ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
2453+
| ty::BoundRegionKind::Anon
2454+
| ty::BoundRegionKind::ClosureEnv => "an anonymous lifetime".to_string(),
2455+
ty::BoundRegionKind::Named(_, name) => format!("lifetime `{name}`"),
24562456
};
24572457

24582458
let mut err = generate_err(&br_name);
24592459

2460-
if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon = *br {
2460+
if let ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
2461+
| ty::BoundRegionKind::Anon = *br
2462+
{
24612463
// The only way for an anonymous lifetime to wind up
24622464
// in the return type but **also** be unconstrained is
24632465
// if it only appears in "associated types" in the

Diff for: compiler/rustc_hir_typeck/src/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,21 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
194194
let panic_info_ty = tcx.type_of(panic_info_did).instantiate(tcx, &[ty::GenericArg::from(
195195
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
196196
var: ty::BoundVar::from_u32(1),
197-
kind: ty::BrAnon,
197+
kind: ty::BoundRegionKind::Anon,
198198
}),
199199
)]);
200200
let panic_info_ref_ty = Ty::new_imm_ref(
201201
tcx,
202202
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
203203
var: ty::BoundVar::ZERO,
204-
kind: ty::BrAnon,
204+
kind: ty::BoundRegionKind::Anon,
205205
}),
206206
panic_info_ty,
207207
);
208208

209209
let bounds = tcx.mk_bound_variable_kinds(&[
210-
ty::BoundVariableKind::Region(ty::BrAnon),
211-
ty::BoundVariableKind::Region(ty::BrAnon),
210+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
211+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
212212
]);
213213
let expected_sig = ty::Binder::bind_with_vars(
214214
tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, ExternAbi::Rust),

Diff for: compiler/rustc_hir_typeck/src/upvar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
381381
let closure_env_region: ty::Region<'_> =
382382
ty::Region::new_bound(self.tcx, ty::INNERMOST, ty::BoundRegion {
383383
var: ty::BoundVar::ZERO,
384-
kind: ty::BoundRegionKind::BrEnv,
384+
kind: ty::BoundRegionKind::ClosureEnv,
385385
});
386386

387387
let num_args = args
@@ -441,7 +441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
441441
rustc_abi::ExternAbi::Rust,
442442
),
443443
self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region(
444-
ty::BoundRegionKind::BrEnv,
444+
ty::BoundRegionKind::ClosureEnv,
445445
)]),
446446
),
447447
);

Diff for: compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
753753
r: ty::Region<'tcx>,
754754
) -> ty::Region<'tcx> {
755755
let var = self.canonical_var(info, r.into());
756-
let br = ty::BoundRegion { var, kind: ty::BrAnon };
756+
let br = ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon };
757757
ty::Region::new_bound(self.cx(), self.binder_index, br)
758758
}
759759

Diff for: compiler/rustc_lint/src/impl_trait_overcaptures.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn check_fn(tcx: TyCtxt<'_>, parent_def_id: LocalDefId) {
154154
}
155155

156156
for bound_var in sig.bound_vars() {
157-
let ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, name)) = bound_var
157+
let ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) = bound_var
158158
else {
159159
span_bug!(tcx.def_span(parent_def_id), "unexpected non-lifetime binder on fn sig");
160160
};
@@ -215,7 +215,7 @@ where
215215
for arg in t.bound_vars() {
216216
let arg: ty::BoundVariableKind = arg;
217217
match arg {
218-
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, ..))
218+
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, ..))
219219
| ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, _)) => {
220220
added.push(def_id);
221221
let unique = self.in_scope_parameters.insert(def_id, ParamKind::Late);
@@ -318,7 +318,7 @@ where
318318
ParamKind::Free(def_id, name) => ty::Region::new_late_param(
319319
self.tcx,
320320
self.parent_def_id.to_def_id(),
321-
ty::BoundRegionKind::BrNamed(def_id, name),
321+
ty::BoundRegionKind::Named(def_id, name),
322322
),
323323
// Totally ignore late bound args from binders.
324324
ParamKind::Late => return true,
@@ -489,11 +489,11 @@ fn extract_def_id_from_arg<'tcx>(
489489
ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
490490
ty::ReBound(
491491
_,
492-
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
492+
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
493493
)
494494
| ty::ReLateParam(ty::LateParamRegion {
495495
scope: _,
496-
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
496+
bound_region: ty::BoundRegionKind::Named(def_id, ..),
497497
}) => def_id,
498498
_ => unreachable!(),
499499
},
@@ -558,11 +558,11 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for FunctionalVariances<'tcx> {
558558
ty::ReEarlyParam(ebr) => self.generics.region_param(ebr, self.tcx).def_id,
559559
ty::ReBound(
560560
_,
561-
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
561+
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
562562
)
563563
| ty::ReLateParam(ty::LateParamRegion {
564564
scope: _,
565-
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
565+
bound_region: ty::BoundRegionKind::Named(def_id, ..),
566566
}) => def_id,
567567
_ => {
568568
return Ok(a);

Diff for: compiler/rustc_middle/src/mir/query.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
317317
pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self {
318318
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
319319
ty::ReVar(vid) => {
320-
let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon };
320+
let br = ty::BoundRegion {
321+
var: ty::BoundVar::new(vid.index()),
322+
kind: ty::BoundRegionKind::Anon,
323+
};
321324
ty::Region::new_bound(tcx, depth, br)
322325
}
323326
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),

0 commit comments

Comments
 (0)