Skip to content

Commit 2e88dcb

Browse files
Add some more tests
1 parent e6bf16c commit 2e88dcb

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: lifetimes cannot use keyword names
2+
--> $DIR/gen-lt.rs:11:11
3+
|
4+
LL | fn gen_lt<'gen>() {}
5+
| ^^^^
6+
7+
error: aborting due to 1 previous error
8+

tests/ui/lifetimes/raw/gen-lt.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ revisions: e2021 e2024
2+
3+
//@[e2021] edition:2021
4+
//@[e2024] edition:2024
5+
//@[e2024] compile-flags: -Zunstable-options
6+
7+
//@[e2021] check-pass
8+
9+
fn raw_gen_lt<'r#gen>() {}
10+
11+
fn gen_lt<'gen>() {}
12+
//[e2024]~^ ERROR lifetimes cannot use keyword names
13+
14+
fn main() {}

tests/ui/lifetimes/raw/macro-lt.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
//@ edition: 2021
3+
4+
macro_rules! lifetime {
5+
($lt:lifetime) => {
6+
fn hello<$lt>() {}
7+
}
8+
}
9+
10+
lifetime!('r#struct);
11+
12+
fn main() {}

tests/ui/lifetimes/raw/prim-lt.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ check-pass
2+
//@ edition: 2021
3+
4+
// Checks a primitive name can be defined as a lifetime.
5+
6+
fn foo<'r#i32>() {}
7+
8+
fn main() {}

tests/ui/lifetimes/raw/simple.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ check-pass
2+
//@ edition: 2021
3+
4+
fn foo<'r#struct>() {}
5+
6+
fn hr<T>() where for<'r#struct> T: Into<&'r#struct ()> {}
7+
8+
trait Foo<'r#struct> {}
9+
10+
trait Bar<'r#struct> {
11+
fn method(&'r#struct self) {}
12+
fn method2(self: &'r#struct Self) {}
13+
}
14+
15+
fn labeled() {
16+
'r#struct: loop {
17+
break 'r#struct;
18+
}
19+
}
20+
21+
fn main() {}

tests/ui/lifetimes/raw/static-lt.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ check-pass
2+
//@ edition: 2021
3+
4+
// Makes sure that `'r#static` is `'static`
5+
6+
const FOO: &'r#static str = "hello, world";
7+
8+
fn main() {}

0 commit comments

Comments
 (0)