Skip to content

Commit

Permalink
Auto merge of #109165 - aliemjay:fix-ice-annotation, r=davidtwco
Browse files Browse the repository at this point in the history
allow ReError in CanonicalUserTypeAnnotation

Why not? we already allow `TyKind::Error`.

Fixes #109072.
  • Loading branch information
bors committed Mar 31, 2023
2 parents 5e1d329 + a42cbdb commit fadf164
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation {
r: ty::Region<'tcx>,
) -> ty::Region<'tcx> {
match *r {
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic => r,
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r,
ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r),
_ => {
ty::RePlaceholder(..) | ty::ReLateBound(..) => {
// We only expect region names that the user can type.
bug!("unexpected region in query response: `{:?}`", r)
}
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/nll/user-annotations/region-error-ice-109072.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test for #109072.
// Check that we don't ICE when canonicalizing user annotation.

trait Lt<'a> {
type T;
}

impl Lt<'missing> for () { //~ ERROR undeclared lifetime
type T = &'missing (); //~ ERROR undeclared lifetime
}

fn main() {
let _: <() as Lt<'_>>::T = &();
}
26 changes: 26 additions & 0 deletions tests/ui/nll/user-annotations/region-error-ice-109072.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error[E0261]: use of undeclared lifetime name `'missing`
--> $DIR/region-error-ice-109072.rs:8:9
|
LL | impl Lt<'missing> for () {
| - ^^^^^^^^ undeclared lifetime
| |
| help: consider introducing lifetime `'missing` here: `<'missing>`

error[E0261]: use of undeclared lifetime name `'missing`
--> $DIR/region-error-ice-109072.rs:9:15
|
LL | type T = &'missing ();
| ^^^^^^^^ undeclared lifetime
|
help: consider introducing lifetime `'missing` here
|
LL | type T<'missing> = &'missing ();
| ++++++++++
help: consider introducing lifetime `'missing` here
|
LL | impl<'missing> Lt<'missing> for () {
| ++++++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0261`.

0 comments on commit fadf164

Please sign in to comment.