Skip to content

Commit 5b84228

Browse files
committed
Add ui test error-lifetime-name-issue-143150.rs
Signed-off-by: xizheyin <[email protected]>
1 parent bc4376f commit 5b84228

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ edition: 2021
2+
fn a(_: dyn Trait + 'r#fn) { //~ ERROR use of undeclared lifetime name `'fn` [E0261]
3+
4+
}
5+
6+
trait Trait {}
7+
8+
#[derive(Eq, PartialEq)]
9+
struct Test {
10+
a: &'r#fn str,
11+
//~^ ERROR use of undeclared lifetime name `'fn` [E0261]
12+
//~| ERROR use of undeclared lifetime name `'fn` [E0261]
13+
}
14+
15+
trait Trait1<T>
16+
where T: for<'a> Trait1<T> + 'r#fn { } //~ ERROR use of undeclared lifetime name `'fn` [E0261]
17+
18+
19+
20+
fn main() {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
error[E0261]: use of undeclared lifetime name `'fn`
2+
--> $DIR/error-lifetime-name-issue-143150.rs:2:21
3+
|
4+
LL | fn a(_: dyn Trait + 'r#fn) {
5+
| - ^^^^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'fn` here: `<'fn>`
8+
9+
error[E0261]: use of undeclared lifetime name `'fn`
10+
--> $DIR/error-lifetime-name-issue-143150.rs:10:9
11+
|
12+
LL | struct Test {
13+
| - help: consider introducing lifetime `'fn` here: `<'fn>`
14+
LL | a: &'r#fn str,
15+
| ^^^^^ undeclared lifetime
16+
17+
error[E0261]: use of undeclared lifetime name `'fn`
18+
--> $DIR/error-lifetime-name-issue-143150.rs:10:9
19+
|
20+
LL | #[derive(Eq, PartialEq)]
21+
| -- lifetime `'fn` is missing in item created through this procedural macro
22+
LL | struct Test {
23+
| - help: consider introducing lifetime `'fn` here: `<'fn>`
24+
LL | a: &'r#fn str,
25+
| ^^^^^ undeclared lifetime
26+
27+
error[E0261]: use of undeclared lifetime name `'fn`
28+
--> $DIR/error-lifetime-name-issue-143150.rs:16:32
29+
|
30+
LL | where T: for<'a> Trait1<T> + 'r#fn { }
31+
| ^^^^^ undeclared lifetime
32+
|
33+
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
34+
help: consider making the bound lifetime-generic with a new `'fn` lifetime
35+
|
36+
LL - where T: for<'a> Trait1<T> + 'r#fn { }
37+
LL + where for<'fn, 'a> T: Trait1<T> + 'r#fn { }
38+
|
39+
help: consider introducing lifetime `'fn` here
40+
|
41+
LL | trait Trait1<'fn, T>
42+
| ++++
43+
44+
error: aborting due to 4 previous errors
45+
46+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)