forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check user type annotations for range patterns.
This commit builds on the fix from rust-lang#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).
- Loading branch information
Showing
7 changed files
with
176 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|