You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Both the same trait object metadata, modulo dropping auto traits (`*dyn Debug` -> `*(u16, dyn Debug)`, `*dyn Debug + Send` -> `*dyn Debug`).
479
+
***Note**: Adding auto traits is only allowed if the principal trait has the auto trait as a super trait (given `trait T: Send {}`, `*dyn T` -> `*dyn T + Send` is valid, but `*dyn Debug` -> `*dyn Debug + Send` is not).
480
+
***Note**: Generics (including lifetimes) must match (`*dyn T<'a, A>` -> `*dyn T<'b, B>` requires `'a = 'b` and `A = B`).
476
481
477
482
\*\* only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference to
Copy file name to clipboardExpand all lines: src/type-coercions.md
+7-1
Original file line number
Diff line number
Diff line change
@@ -191,7 +191,7 @@ r[coerce.unsize]
191
191
192
192
r[coerce.unsize.intro]
193
193
The following coercions are called `unsized coercions`, since they
194
-
relate to converting sized types to unsized types, and are permitted in a few
194
+
relate to converting types to unsized types, and are permitted in a few
195
195
cases where other coercions are not, as described above. They can still happen
196
196
anywhere else a coercion can occur.
197
197
@@ -207,6 +207,11 @@ r[coerce.unsize.slice]
207
207
r[coerce.unsize.trait-object]
208
208
*`T` to `dyn U`, when `T` implements `U + Sized`, and `U` is [dyn compatible].
209
209
210
+
r[coerce.unsize.trait-upcast]
211
+
*`dyn T` to `dyn U`, when `U` is one of `T`'s [supertraits].
212
+
* This allows dropping auto traits, i.e. `dyn T + Auto` to `dyn U` is allowed.
213
+
* This allows adding auto traits if the principal trait has the auto trait as a super trait, i.e. given `trait T: U + Send {}`, `dyn T` to `dyn T + Send` or to `dyn U + Send` coercions are allowed.
0 commit comments