Check user type annotations for range patterns.
This commit builds on the fix from #58161 (which fixed miscompilation caused by the introduction of `AscribeUserType` patterns for associated constants) to start checking these patterns are well-formed for ranges (previous fix just ignored them so that miscompilation wouldn't occur).
This commit is contained in:
parent
2e08bb1dd2
commit
ee82d09b6c
7 changed files with 176 additions and 85 deletions
30
src/test/ui/nll/issue-58299.rs
Normal file
30
src/test/ui/nll/issue-58299.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#![allow(dead_code)]
|
||||
#![feature(nll)]
|
||||
|
||||
struct A<'a>(&'a ());
|
||||
|
||||
trait Y {
|
||||
const X: i32;
|
||||
}
|
||||
|
||||
impl Y for A<'static> {
|
||||
const X: i32 = 10;
|
||||
}
|
||||
|
||||
fn foo<'a>(x: i32) {
|
||||
match x {
|
||||
// This uses <A<'a> as Y>::X, but `A<'a>` does not implement `Y`.
|
||||
A::<'a>::X..=A::<'static>::X => (), //~ ERROR lifetime may not live long enough
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn bar<'a>(x: i32) {
|
||||
match x {
|
||||
// This uses <A<'a> as Y>::X, but `A<'a>` does not implement `Y`.
|
||||
A::<'static>::X..=A::<'a>::X => (), //~ ERROR lifetime may not live long enough
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
20
src/test/ui/nll/issue-58299.stderr
Normal file
20
src/test/ui/nll/issue-58299.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-58299.rs:17:9
|
||||
|
|
||||
LL | fn foo<'a>(x: i32) {
|
||||
| -- lifetime `'a` defined here
|
||||
...
|
||||
LL | A::<'a>::X..=A::<'static>::X => (), //~ ERROR lifetime may not live long enough
|
||||
| ^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-58299.rs:25:27
|
||||
|
|
||||
LL | fn bar<'a>(x: i32) {
|
||||
| -- lifetime `'a` defined here
|
||||
...
|
||||
LL | A::<'static>::X..=A::<'a>::X => (), //~ ERROR lifetime may not live long enough
|
||||
| ^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue