1 Trait objects must include the `dyn` keyword.
3 Erroneous code example:
5 ```edition2021,compile_fail,E0782
7 fn test(arg: Box<Foo>) {} // error!
10 Trait objects are a way to call methods on types that are not known until
11 runtime but conform to some trait.
13 Trait objects should be formed with `Box<dyn Foo>`, but in the code above
16 This makes it harder to see that `arg` is a trait object and not a
17 simply a heap allocated type called `Foo`.
19 To fix this issue, add `dyn` before the trait name.
23 fn test(arg: Box<dyn Foo>) {} // ok!
26 This used to be allowed before edition 2021, but is now an error.