Closed
Description
Breaking off from #47184 -- we need to respect user type annotations in patterns. Here are some examples:
Compiles without NLL (playground):
trait Foo<'a> {
const C: &'a u32;
}
impl<'a, T> Foo<'a> for T {
const C: &'a u32 = &22;
}
fn foo() {
let a = 22;
match &a {
<() as Foo<'static>>::C => { }
&_ => { }
}
}
fn main() {
}
Errors without NLL (playground):
use std::cell::Cell;
trait Foo<'a> {
const C: Option<Cell<&'a u32>>;
}
impl<'a, T> Foo<'a> for T {
const C: Option<Cell<&'a u32>> = None;
}
fn foo() {
let a = 22;
let b = Some(Cell::new(&a));
match b {
<() as Foo<'static>>::C => { }
_ => { }
}
}
fn main() {
}