Skip to content

allow ReError in CanonicalUserTypeAnnotation #109165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`.