diff --git a/src/expressions/operator-expr.md b/src/expressions/operator-expr.md index 3d7319d7e..ef9bc0eb5 100644 --- a/src/expressions/operator-expr.md +++ b/src/expressions/operator-expr.md @@ -388,7 +388,8 @@ reference types and `mut` or `const` in pointer types. \* or `T` and `V` are unsized types with compatible metadata: * both slice metadata (`*[u16]` -> `*[u8]`, `*str` -> `*(u8, [u32])`). * both the same trait object metadata, modulo dropping auto traits (`*dyn Debug` -> `*(u16, dyn Debug)`, `*dyn Debug + Send` -> `*dyn Debug`). - * **Note**: *adding* auto traits is not allowed (`*dyn Debug` -> `*dyn Debug + Send` is invalid). + * **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). * **Note**: generics (including lifetimes) must match (`*dyn T<'a, A>` -> `*dyn T<'b, B>` requires `'a = 'b` and `A = B`). \*\* only when `m₁` is `mut` or `m₂` is `const`. Casting `mut` reference to diff --git a/src/type-coercions.md b/src/type-coercions.md index 002f78934..b84fc9321 100644 --- a/src/type-coercions.md +++ b/src/type-coercions.md @@ -177,6 +177,8 @@ an implementation of `Unsize` for `T` will be provided: * `dyn T` to `dyn U` when `U` is one of `T`'s [supertraits]. * This allows dropping auto traits, i.e. `dyn T + Auto` to `dyn U` is allowed. + * 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. * `Foo<..., T, ...>` to `Foo<..., U, ...>`, when: * `Foo` is a struct.