File tree 2 files changed +55
-0
lines changed
src/test/ui/traits/trait-upcasting
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
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
+
Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments