@@ -61,7 +61,29 @@ LL | x as _
6161 = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
6262
6363error: lifetime may not live long enough
64- --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:25:5
64+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5
65+ |
66+ LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> {
67+ | -- lifetime `'a` defined here
68+ LL | x as _
69+ | ^^^^^^ cast requires that `'a` must outlive `'static`
70+ |
71+ help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound
72+ |
73+ LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> + 'a {
74+ | ++++
75+
76+ error[E0308]: mismatched types
77+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5
78+ |
79+ LL | x as _
80+ | ^^^^^^ one type is more general than the other
81+ |
82+ = note: expected trait object `dyn for<'b> Trait<'b>`
83+ found trait object `dyn Trait<'_>`
84+
85+ error: lifetime may not live long enough
86+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31:5
6587 |
6688LL | fn change_assoc_0<'a, 'b>(
6789 | -- -- lifetime `'b` defined here
@@ -77,7 +99,7 @@ LL | x as _
7799 = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
78100
79101error: lifetime may not live long enough
80- --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:25 :5
102+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31 :5
81103 |
82104LL | fn change_assoc_0<'a, 'b>(
83105 | -- -- lifetime `'b` defined here
@@ -97,7 +119,7 @@ help: `'b` and `'a` must be the same: replace one with the other
97119 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
98120
99121error: lifetime may not live long enough
100- --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32 :5
122+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38 :5
101123 |
102124LL | fn change_assoc_1<'a, 'b>(
103125 | -- -- lifetime `'b` defined here
@@ -113,7 +135,7 @@ LL | x as _
113135 = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
114136
115137error: lifetime may not live long enough
116- --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32 :5
138+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38 :5
117139 |
118140LL | fn change_assoc_1<'a, 'b>(
119141 | -- -- lifetime `'b` defined here
@@ -133,12 +155,13 @@ help: `'b` and `'a` must be the same: replace one with the other
133155 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
134156
135157error: lifetime may not live long enough
136- --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39 :20
158+ --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:45 :20
137159 |
138160LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) {
139161 | -- lifetime `'a` defined here
140162LL | require_static(ptr as _)
141163 | ^^^^^^^^ cast requires that `'a` must outlive `'static`
142164
143- error: aborting due to 9 previous errors
165+ error: aborting due to 11 previous errors
144166
167+ For more information about this error, try `rustc --explain E0308`.
0 commit comments