Skip to content

Commit 6dc3650

Browse files
authored
Rollup merge of rust-lang#111573 - compiler-errors:erase-re-error, r=WaffleLapkin
Erase `ReError` properly Fixes rust-lang#111341 Since we check whether a type has free regions before erasing (to short circuit unnecesary folding), we need to consider `ReError` as a free region, or else we'll skip it when erasing a type that only mentions `ReError`. cc `@nnethercote`
2 parents 426dbcd + bd31d9e commit 6dc3650

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

compiler/rustc_middle/src/ty/sty.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,9 @@ impl<'tcx> Region<'tcx> {
17081708
ty::ReErased => {
17091709
flags = flags | TypeFlags::HAS_RE_ERASED;
17101710
}
1711-
ty::ReError(_) => {}
1711+
ty::ReError(_) => {
1712+
flags = flags | TypeFlags::HAS_FREE_REGIONS;
1713+
}
17121714
}
17131715

17141716
debug!("type_flags({:?}) = {:?}", self, flags);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// compile-flags: -Zdrop-tracking-mir
2+
// edition:2021
3+
4+
use std::future::Future;
5+
6+
trait Client {
7+
type Connecting<'a>: Future + Send
8+
where
9+
Self: 'a;
10+
11+
fn connect(&'_ self) -> Self::Connecting<'a>;
12+
//~^ ERROR use of undeclared lifetime name `'a`
13+
}
14+
15+
fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send
16+
where
17+
C: Client + Send + Sync,
18+
{
19+
async move { c.connect().await }
20+
//~^ ERROR `C` does not live long enough
21+
}
22+
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/erase-error-in-mir-drop-tracking.rs:11:46
3+
|
4+
LL | fn connect(&'_ self) -> Self::Connecting<'a>;
5+
| ^^ undeclared lifetime
6+
|
7+
help: consider introducing lifetime `'a` here
8+
|
9+
LL | fn connect<'a>(&'_ self) -> Self::Connecting<'a>;
10+
| ++++
11+
help: consider introducing lifetime `'a` here
12+
|
13+
LL | trait Client<'a> {
14+
| ++++
15+
16+
error: `C` does not live long enough
17+
--> $DIR/erase-error-in-mir-drop-tracking.rs:19:5
18+
|
19+
LL | async move { c.connect().await }
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21+
22+
error: aborting due to 2 previous errors
23+
24+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)