Skip to content

Commit f3c6955

Browse files
authored
Rollup merge of #110276 - nnethercote:rm-BrAnon-Span, r=jackh726
Remove all but one of the spans in `BoundRegionKind::BrAnon` There are only three places where `BoundRegionKind::BrAnon` uses `Some(span)` instead of `None`. Two of them are easy to remove, which this PR does. r? ```@jackh726```
2 parents 69d7172 + f07c335 commit f3c6955

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ pub fn resolve_interior<'a, 'tcx>(
239239
// typeck had previously found constraints that would cause them to be related.
240240

241241
let mut counter = 0;
242-
let mut mk_bound_region = |span| {
243-
let kind = ty::BrAnon(span);
242+
let mut mk_bound_region = |kind| {
244243
let var = ty::BoundVar::from_u32(counter);
245244
counter += 1;
246245
ty::BoundRegion { var, kind }
@@ -252,24 +251,23 @@ pub fn resolve_interior<'a, 'tcx>(
252251
let origin = fcx.region_var_origin(vid);
253252
match origin {
254253
RegionVariableOrigin::EarlyBoundRegion(span, _) => {
255-
mk_bound_region(Some(span))
254+
mk_bound_region(ty::BrAnon(Some(span)))
256255
}
257-
_ => mk_bound_region(None),
256+
_ => mk_bound_region(ty::BrAnon(None)),
258257
}
259258
}
260-
// FIXME: these should use `BrNamed`
261259
ty::ReEarlyBound(region) => {
262-
mk_bound_region(Some(fcx.tcx.def_span(region.def_id)))
260+
mk_bound_region(ty::BrNamed(region.def_id, region.name))
263261
}
264262
ty::ReLateBound(_, ty::BoundRegion { kind, .. })
265263
| ty::ReFree(ty::FreeRegion { bound_region: kind, .. }) => match kind {
266-
ty::BoundRegionKind::BrAnon(span) => mk_bound_region(span),
267-
ty::BoundRegionKind::BrNamed(def_id, _) => {
268-
mk_bound_region(Some(fcx.tcx.def_span(def_id)))
264+
ty::BoundRegionKind::BrAnon(span) => mk_bound_region(ty::BrAnon(span)),
265+
ty::BoundRegionKind::BrNamed(def_id, sym) => {
266+
mk_bound_region(ty::BrNamed(def_id, sym))
269267
}
270-
ty::BoundRegionKind::BrEnv => mk_bound_region(None),
268+
ty::BoundRegionKind::BrEnv => mk_bound_region(ty::BrAnon(None)),
271269
},
272-
_ => mk_bound_region(None),
270+
_ => mk_bound_region(ty::BrAnon(None)),
273271
};
274272
let r = fcx.tcx.mk_re_late_bound(current_depth, br);
275273
r
@@ -293,10 +291,7 @@ pub fn resolve_interior<'a, 'tcx>(
293291
type_causes,
294292
FnMutDelegate {
295293
regions: &mut |br| {
296-
let kind = match br.kind {
297-
ty::BrAnon(span) => ty::BrAnon(span),
298-
_ => br.kind,
299-
};
294+
let kind = br.kind;
300295
let var = ty::BoundVar::from_usize(bound_vars.len());
301296
bound_vars.push(ty::BoundVariableKind::Region(kind));
302297
counter += 1;

tests/ui/generic-associated-types/bugs/issue-100013.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ LL | | async {}.await; // a yield point
2828
LL | | }
2929
| |_____^
3030
|
31-
note: the lifetime defined here...
31+
note: the lifetime `'b` defined here...
3232
--> $DIR/issue-100013.rs:21:14
3333
|
3434
LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send {
3535
| ^^
36-
note: ...must outlive the lifetime defined here
36+
note: ...must outlive the lifetime `'a` defined here
3737
--> $DIR/issue-100013.rs:21:10
3838
|
3939
LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send {
@@ -62,12 +62,12 @@ LL | | async {}.await; // a yield point
6262
LL | | }
6363
| |_____^
6464
|
65-
note: the lifetime defined here...
65+
note: the lifetime `'b` defined here...
6666
--> $DIR/issue-100013.rs:28:18
6767
|
6868
LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send {
6969
| ^^
70-
note: ...must outlive the lifetime defined here
70+
note: ...must outlive the lifetime `'a` defined here
7171
--> $DIR/issue-100013.rs:28:10
7272
|
7373
LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send {

0 commit comments

Comments
 (0)