Add test raw-underscore-lifetime.rs

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin
2025-07-01 20:34:45 +08:00
parent bf5e6cc7a7
commit cecf9ead40
2 changed files with 25 additions and 0 deletions
@@ -0,0 +1,10 @@
// This test is to ensure that the raw underscore lifetime won't emit two duplicate errors.
// See issue #143152
//@ edition: 2021
fn f<'r#_>(){}
//~^ ERROR `_` cannot be a raw lifetime
//~| ERROR `'_` cannot be used here [E0637]
fn main() {}
@@ -0,0 +1,15 @@
error: `_` cannot be a raw lifetime
--> $DIR/raw-underscore-lifetime.rs:6:6
|
LL | fn f<'r#_>(){}
| ^^^^
error[E0637]: `'_` cannot be used here
--> $DIR/raw-underscore-lifetime.rs:6:6
|
LL | fn f<'r#_>(){}
| ^^^^ `'_` is a reserved lifetime name
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0637`.