Skip to content

Commit fadf164

Browse files
committed
Auto merge of #109165 - aliemjay:fix-ice-annotation, r=davidtwco
allow ReError in CanonicalUserTypeAnnotation Why not? we already allow `TyKind::Error`. Fixes #109072.
2 parents 5e1d329 + a42cbdb commit fadf164

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation {
230230
r: ty::Region<'tcx>,
231231
) -> ty::Region<'tcx> {
232232
match *r {
233-
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic => r,
233+
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r,
234234
ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r),
235-
_ => {
235+
ty::RePlaceholder(..) | ty::ReLateBound(..) => {
236236
// We only expect region names that the user can type.
237237
bug!("unexpected region in query response: `{:?}`", r)
238238
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for #109072.
2+
// Check that we don't ICE when canonicalizing user annotation.
3+
4+
trait Lt<'a> {
5+
type T;
6+
}
7+
8+
impl Lt<'missing> for () { //~ ERROR undeclared lifetime
9+
type T = &'missing (); //~ ERROR undeclared lifetime
10+
}
11+
12+
fn main() {
13+
let _: <() as Lt<'_>>::T = &();
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0261]: use of undeclared lifetime name `'missing`
2+
--> $DIR/region-error-ice-109072.rs:8:9
3+
|
4+
LL | impl Lt<'missing> for () {
5+
| - ^^^^^^^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'missing` here: `<'missing>`
8+
9+
error[E0261]: use of undeclared lifetime name `'missing`
10+
--> $DIR/region-error-ice-109072.rs:9:15
11+
|
12+
LL | type T = &'missing ();
13+
| ^^^^^^^^ undeclared lifetime
14+
|
15+
help: consider introducing lifetime `'missing` here
16+
|
17+
LL | type T<'missing> = &'missing ();
18+
| ++++++++++
19+
help: consider introducing lifetime `'missing` here
20+
|
21+
LL | impl<'missing> Lt<'missing> for () {
22+
| ++++++++++
23+
24+
error: aborting due to 2 previous errors
25+
26+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)