fix ICE in check_unique

This commit is contained in:
Ali MJ Al-Nasrawy 2024-03-21 03:04:49 +00:00
parent 73476d4990
commit 92f40b8059
3 changed files with 39 additions and 2 deletions

View File

@ -69,9 +69,18 @@ fn check_unique(
continue;
}
// Ignore non-universal regions because they result in an error eventually.
// FIXME(aliemjay): This logic will be rewritten in a later commit.
let Some(r1) = self.universal_name(r1) else {
continue;
};
let Some(r2) = self.universal_name(r2) else {
continue;
};
infcx.dcx().emit_err(LifetimeMismatchOpaqueParam {
arg: self.universal_name(r1).unwrap().into(),
prev: self.universal_name(r2).unwrap().into(),
arg: r1.into(),
prev: r2.into(),
span: a_ty.span,
prev_span: b_ty.span,
});

View File

@ -0,0 +1,16 @@
//! This test checks that when checking for opaque types that
//! only differ in lifetimes, we handle the case of non-generic
//! regions correctly.
#![feature(type_alias_impl_trait)]
type Opq<'a> = impl Sized;
// Two defining uses: Opq<'{empty}> and Opq<'a>.
// This used to ICE.
// issue: #122782
fn build<'a>() -> Opq<'a> {
let _: Opq<'_> = ();
//~^ ERROR expected generic lifetime parameter, found `'_`
}
fn main() {}

View File

@ -0,0 +1,12 @@
error[E0792]: expected generic lifetime parameter, found `'_`
--> $DIR/param_mismatch4.rs:12:12
|
LL | type Opq<'a> = impl Sized;
| -- this generic parameter must be used with a generic lifetime parameter
...
LL | let _: Opq<'_> = ();
| ^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0792`.