Skip to content

Commit 62b4c91

Browse files
committed
Update auto traits in the unstable book
Add a `?DynSized` unbound to the auto trait in the example, and explain why it is necessary
1 parent a36e2fe commit 62b4c91

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/doc/unstable-book/src/language-features/optin-builtin-traits.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@ has explictly opted out via a negative impl.
1919
impl !Type for Trait
2020
```
2121

22+
[#46108] added the `DynSized` trait, which is an implicit bound for all traits. Auto traits may not
23+
have bounds, so you must explicitly remove this bound with `?DynSized`. [#44917] adds a `Move` trait
24+
which is also implicit, so when that lands, you will have to add `?Move` as well.
25+
26+
[#46108]: https://github.com/rust-lang/rust/pull/46108
27+
[#44917]: https://github.com/rust-lang/rust/pull/44917
28+
29+
2230
Example:
2331

2432
```rust
25-
#![feature(optin_builtin_traits)]
33+
#![feature(optin_builtin_traits, dynsized)]
34+
35+
use std::marker::DynSized;
2636

27-
auto trait Valid {}
37+
auto trait Valid: ?DynSized {}
2838

2939
struct True;
3040
struct False;
@@ -38,7 +48,6 @@ fn must_be_valid<T: Valid>(_t: T) { }
3848
fn main() {
3949
// works
4050
must_be_valid( MaybeValid(True) );
41-
4251
// compiler error - trait bound not satisfied
4352
// must_be_valid( MaybeValid(False) );
4453
}

0 commit comments

Comments
 (0)