Skip to content

Commit 72fd85c

Browse files
authored
Rollup merge of rust-lang#125054 - nnethercote:fix-124973, r=compiler-errors
Handle `ReVar` in `note_and_explain_region` PR rust-lang#124918 made this path abort. The added test, from fuzzing, identified that it is reachable. r? `@lcnr`
2 parents 96134e1 + 5f4424b commit 72fd85c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ pub(super) fn note_and_explain_region<'tcx>(
173173

174174
ty::ReError(_) => return,
175175

176-
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => {
176+
// FIXME(#125431): `ReVar` shouldn't reach here.
177+
ty::ReVar(_) => (format!("lifetime `{region}`"), alt_span),
178+
179+
ty::ReBound(..) | ty::ReErased => {
177180
bug!("unexpected region for note_and_explain_region: {:?}", region);
178181
}
179182
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ edition:2018
2+
3+
#![feature(c_variadic)]
4+
5+
async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
6+
//~^ ERROR hidden type for `impl Future<Output = ()>` captures lifetime that does not appear in bounds
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0700]: hidden type for `impl Future<Output = ()>` captures lifetime that does not appear in bounds
2+
--> $DIR/note-and-explain-ReVar-124973.rs:5:73
3+
|
4+
LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
5+
| ----------------------------------------------------------------------- ^^
6+
| |
7+
| opaque type defined here
8+
|
9+
= note: hidden type `{async fn body of multiple_named_lifetimes<'a, 'b>()}` captures lifetime `'_`
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0700`.

0 commit comments

Comments
 (0)