-error[E0308]: mismatched types
- --> $DIR/type-checking-test-3.rs:13:13
- |
-LL | let _ = x as &dyn Bar<'a>; // Error
- | ^ lifetime mismatch
- |
- = note: expected trait object `dyn Bar<'a>`
- found trait object `dyn Bar<'static>`
-note: the lifetime `'a` as defined here...
- --> $DIR/type-checking-test-3.rs:12:16
+error: lifetime may not live long enough
+ --> $DIR/type-checking-test-3.rs:12:13
|
LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) {
- | ^^
- = note: ...does not necessarily outlive the static lifetime
+ | -- lifetime `'a` defined here
+LL | let _ = x as &dyn Bar<'a>; // Error
+ | ^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
-error[E0308]: mismatched types
- --> $DIR/type-checking-test-3.rs:18:13
- |
-LL | let _ = x as &dyn Bar<'static>; // Error
- | ^ lifetime mismatch
- |
- = note: expected trait object `dyn Bar<'static>`
- found trait object `dyn Bar<'a>`
-note: the lifetime `'a` as defined here...
- --> $DIR/type-checking-test-3.rs:17:16
+error: lifetime may not live long enough
+ --> $DIR/type-checking-test-3.rs:17:13
|
LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) {
- | ^^
- = note: ...does not necessarily outlive the static lifetime
+ | -- lifetime `'a` defined here
+LL | let _ = x as &dyn Bar<'static>; // Error
+ | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0308`.