Skip to content

Commit 42237cc

Browse files
committed
bless trait upcasting tests under polonius
The diagnostics are different from the NLL ones but the same errors are emitted.
1 parent bfadfbb commit 42237cc

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/type-checking-test-3.rs:13:13
3+
|
4+
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
5+
| -- lifetime `'a` defined here
6+
LL | let _ = x as &dyn Bar<'a>; // Error
7+
| ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
8+
|
9+
= help: consider replacing `'a` with `'static`
10+
11+
error: lifetime may not live long enough
12+
--> $DIR/type-checking-test-3.rs:18:13
13+
|
14+
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
15+
| -- lifetime `'a` defined here
16+
LL | let _ = x as &dyn Bar<'static>; // Error
17+
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
18+
|
19+
= help: consider replacing `'a` with `'static`
20+
21+
error: aborting due to 2 previous errors
22+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/type-checking-test-4.rs:17:13
3+
|
4+
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
5+
| -- lifetime `'a` defined here
6+
LL | let _ = x as &dyn Bar<'static, 'a>; // Error
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
8+
|
9+
= help: consider replacing `'a` with `'static`
10+
11+
error: lifetime may not live long enough
12+
--> $DIR/type-checking-test-4.rs:22:13
13+
|
14+
LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) {
15+
| -- lifetime `'a` defined here
16+
LL | let _ = x as &dyn Bar<'a, 'static>; // Error
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
18+
|
19+
= help: consider replacing `'a` with `'static`
20+
21+
error: lifetime may not live long enough
22+
--> $DIR/type-checking-test-4.rs:29:5
23+
|
24+
LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> {
25+
| -- lifetime `'a` defined here
26+
...
27+
LL | y.get_b() // ERROR
28+
| ^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
29+
|
30+
= help: consider replacing `'a` with `'static`
31+
32+
error: aborting due to 3 previous errors
33+

0 commit comments

Comments
 (0)