Skip to content

Commit 91958e0

Browse files
committed
Auto merge of #116117 - cjgillot:drop-tracking-mir-noscope, r=compiler-errors
Remove dead diagnostic code for generators This code has become unreachable with #107421.
2 parents 37390d6 + 26cb34c commit 91958e0

40 files changed

+84
-173
lines changed

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
354354
})
355355
}
356356

357-
ty::BoundRegionKind::BrAnon(..) => None,
357+
ty::BoundRegionKind::BrAnon => None,
358358
},
359359

360360
ty::ReLateBound(..)

compiler/rustc_borrowck/src/renumber.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::mir::visit::{MutVisitor, TyContext};
77
use rustc_middle::mir::{Body, ConstOperand, Location, Promoted};
88
use rustc_middle::ty::GenericArgsRef;
99
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
10-
use rustc_span::{Span, Symbol};
10+
use rustc_span::Symbol;
1111

1212
/// Replaces all free regions appearing in the MIR with fresh
1313
/// inference variables, returning the number of variables created.
@@ -28,21 +28,15 @@ pub fn renumber_mir<'tcx>(
2828
renumberer.visit_body(body);
2929
}
3030

31-
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
32-
pub(crate) enum BoundRegionInfo {
33-
Name(Symbol),
34-
Span(Span),
35-
}
36-
3731
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
3832
pub(crate) enum RegionCtxt {
3933
Location(Location),
4034
TyContext(TyContext),
4135
Free(Symbol),
42-
Bound(BoundRegionInfo),
43-
LateBound(BoundRegionInfo),
36+
Bound(Symbol),
37+
LateBound(Symbol),
4438
Existential(Option<Symbol>),
45-
Placeholder(BoundRegionInfo),
39+
Placeholder(Symbol),
4640
Unknown,
4741
}
4842

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,14 +1367,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13671367
}
13681368
};
13691369
let (sig, map) = tcx.replace_late_bound_regions(sig, |br| {
1370-
use crate::renumber::{BoundRegionInfo, RegionCtxt};
1370+
use crate::renumber::RegionCtxt;
13711371

13721372
let region_ctxt_fn = || {
13731373
let reg_info = match br.kind {
1374-
ty::BoundRegionKind::BrAnon(Some(span)) => BoundRegionInfo::Span(span),
1375-
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(sym::anon),
1376-
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
1377-
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
1374+
ty::BoundRegionKind::BrAnon => sym::anon,
1375+
ty::BoundRegionKind::BrNamed(_, name) => name,
1376+
ty::BoundRegionKind::BrEnv => sym::env,
13781377
};
13791378

13801379
RegionCtxt::LateBound(reg_info)

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::{Span, Symbol};
1111

1212
use crate::constraints::OutlivesConstraint;
1313
use crate::diagnostics::UniverseInfo;
14-
use crate::renumber::{BoundRegionInfo, RegionCtxt};
14+
use crate::renumber::RegionCtxt;
1515
use crate::type_check::{InstantiateOpaqueType, Locations, TypeChecker};
1616

1717
impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
@@ -126,10 +126,9 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
126126
.placeholder_region(self.type_checker.infcx, placeholder);
127127

128128
let reg_info = match placeholder.bound.kind {
129-
ty::BoundRegionKind::BrAnon(Some(span)) => BoundRegionInfo::Span(span),
130-
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(sym::anon),
131-
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),
132-
ty::BoundRegionKind::BrEnv => BoundRegionInfo::Name(sym::env),
129+
ty::BoundRegionKind::BrAnon => sym::anon,
130+
ty::BoundRegionKind::BrNamed(_, name) => name,
131+
ty::BoundRegionKind::BrEnv => sym::env,
133132
};
134133

135134
if cfg!(debug_assertions) {

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_span::symbol::{kw, sym};
2828
use rustc_span::Symbol;
2929
use std::iter;
3030

31-
use crate::renumber::{BoundRegionInfo, RegionCtxt};
31+
use crate::renumber::RegionCtxt;
3232
use crate::BorrowckInferCtxt;
3333

3434
#[derive(Debug)]
@@ -446,9 +446,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
446446
if !indices.indices.contains_key(&r) {
447447
let region_vid = {
448448
let name = r.get_name_or_anon();
449-
self.infcx.next_nll_region_var(FR, || {
450-
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
451-
})
449+
self.infcx.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
452450
};
453451

454452
debug!(?region_vid);
@@ -480,9 +478,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
480478
if !indices.indices.contains_key(&r) {
481479
let region_vid = {
482480
let name = r.get_name_or_anon();
483-
self.infcx.next_nll_region_var(FR, || {
484-
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
485-
})
481+
self.infcx.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
486482
};
487483

488484
debug!(?region_vid);
@@ -796,7 +792,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
796792
_ => sym::anon,
797793
};
798794

799-
self.next_nll_region_var(origin, || RegionCtxt::Bound(BoundRegionInfo::Name(name)))
795+
self.next_nll_region_var(origin, || RegionCtxt::Bound(name))
800796
};
801797

802798
indices.insert_late_bound_region(liberated_region, region_vid.as_var());
@@ -826,9 +822,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
826822
if !indices.indices.contains_key(&r) {
827823
let region_vid = {
828824
let name = r.get_name_or_anon();
829-
self.next_nll_region_var(FR, || {
830-
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
831-
})
825+
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
832826
};
833827

834828
debug!(?region_vid);
@@ -848,9 +842,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
848842
if !indices.indices.contains_key(&r) {
849843
let region_vid = {
850844
let name = r.get_name_or_anon();
851-
self.next_nll_region_var(FR, || {
852-
RegionCtxt::LateBound(BoundRegionInfo::Name(name))
853-
})
845+
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
854846
};
855847

856848
indices.insert_late_bound_region(r, region_vid.as_var());

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,15 +2781,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
27812781
) {
27822782
for br in referenced_regions.difference(&constrained_regions) {
27832783
let br_name = match *br {
2784-
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon(..) | ty::BrEnv => {
2784+
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon | ty::BrEnv => {
27852785
"an anonymous lifetime".to_string()
27862786
}
27872787
ty::BrNamed(_, name) => format!("lifetime `{name}`"),
27882788
};
27892789

27902790
let mut err = generate_err(&br_name);
27912791

2792-
if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon(..) = *br {
2792+
if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon = *br {
27932793
// The only way for an anonymous lifetime to wind up
27942794
// in the return type but **also** be unconstrained is
27952795
// if it only appears in "associated types" in the

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
137137
let name_str = intrinsic_name.as_str();
138138

139139
let bound_vars = tcx.mk_bound_variable_kinds(&[
140-
ty::BoundVariableKind::Region(ty::BrAnon(None)),
140+
ty::BoundVariableKind::Region(ty::BrAnon),
141141
ty::BoundVariableKind::Region(ty::BrEnv),
142142
]);
143143
let mk_va_list_ty = |mutbl| {
144144
tcx.lang_items().va_list().map(|did| {
145145
let region = ty::Region::new_late_bound(
146146
tcx,
147147
ty::INNERMOST,
148-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) },
148+
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
149149
);
150150
let env_region = ty::Region::new_late_bound(
151151
tcx,
@@ -405,7 +405,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
405405
);
406406
let discriminant_def_id = assoc_items[0];
407407

408-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) };
408+
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
409409
(
410410
1,
411411
vec![Ty::new_imm_ref(
@@ -463,7 +463,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
463463
}
464464

465465
sym::raw_eq => {
466-
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) };
466+
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
467467
let param_ty = Ty::new_imm_ref(
468468
tcx,
469469
ty::Region::new_late_bound(tcx, ty::INNERMOST, br),

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,22 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
204204
&[ty::GenericArg::from(ty::Region::new_late_bound(
205205
tcx,
206206
ty::INNERMOST,
207-
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon(None) },
207+
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon },
208208
))],
209209
);
210210
let panic_info_ref_ty = Ty::new_imm_ref(
211211
tcx,
212212
ty::Region::new_late_bound(
213213
tcx,
214214
ty::INNERMOST,
215-
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon(None) },
215+
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
216216
),
217217
panic_info_ty,
218218
);
219219

220220
let bounds = tcx.mk_bound_variable_kinds(&[
221-
ty::BoundVariableKind::Region(ty::BrAnon(None)),
222-
ty::BoundVariableKind::Region(ty::BrAnon(None)),
221+
ty::BoundVariableKind::Region(ty::BrAnon),
222+
ty::BoundVariableKind::Region(ty::BrAnon),
223223
]);
224224
let expected_sig = ty::Binder::bind_with_vars(
225225
tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.unsafety, Abi::Rust),

compiler/rustc_infer/src/errors/note_and_explain.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ impl<'a> DescriptionCtx<'a> {
5656
(Some(span), "as_defined", name.to_string())
5757
}
5858
}
59-
ty::BrAnon(span) => {
60-
let span = match span {
61-
Some(_) => span,
62-
None => Some(tcx.def_span(scope)),
63-
};
59+
ty::BrAnon => {
60+
let span = Some(tcx.def_span(scope));
6461
(span, "defined_here", String::new())
6562
}
6663
_ => {

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
775775
r: ty::Region<'tcx>,
776776
) -> ty::Region<'tcx> {
777777
let var = self.canonical_var(info, r.into());
778-
let br = ty::BoundRegion { var, kind: ty::BrAnon(None) };
778+
let br = ty::BoundRegion { var, kind: ty::BrAnon };
779779
ty::Region::new_late_bound(self.interner(), self.binder_index, br)
780780
}
781781

0 commit comments

Comments
 (0)