-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse lifetimes that start with a number and give specific error
- Loading branch information
Showing
3 changed files
with
50 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
struct S<'1> { s: &'1 usize } | ||
//~^ ERROR lifetimes can't start with a number | ||
//~| ERROR lifetimes can't start with a number | ||
fn main() { | ||
// verify that the parse error doesn't stop type checking | ||
let x: usize = ""; | ||
//~^ ERROR mismatched types | ||
} |
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,24 @@ | ||
error: lifetimes can't start with a number | ||
--> $DIR/numeric-lifetime.rs:1:10 | ||
| | ||
LL | struct S<'1> { s: &'1 usize } | ||
| ^^ | ||
|
||
error: lifetimes can't start with a number | ||
--> $DIR/numeric-lifetime.rs:1:20 | ||
| | ||
LL | struct S<'1> { s: &'1 usize } | ||
| ^^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/numeric-lifetime.rs:6:20 | ||
| | ||
LL | let x: usize = ""; | ||
| ^^ expected usize, found reference | ||
| | ||
= note: expected type `usize` | ||
found type `&'static str` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |