]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/bad-sized.stderr
Rollup merge of #87354 - Wind-River:2021_master, r=kennytm
[rust.git] / src / test / ui / traits / bad-sized.stderr
1 error[E0225]: only auto traits can be used as additional traits in a trait object
2   --> $DIR/bad-sized.rs:4:28
3    |
4 LL |     let x: Vec<dyn Trait + Sized> = Vec::new();
5    |                    -----   ^^^^^ additional non-auto trait
6    |                    |
7    |                    first non-auto trait
8    |
9    = help: consider creating a new trait with all of these as super-traits and using that trait here instead: `trait NewTrait: Trait + Sized {}`
10    = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>
11
12 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
13   --> $DIR/bad-sized.rs:4:12
14    |
15 LL |     let x: Vec<dyn Trait + Sized> = Vec::new();
16    |            ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
17    | 
18   ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
19    |
20 LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
21    |                - required by this bound in `Vec`
22    |
23    = help: the trait `Sized` is not implemented for `dyn Trait`
24
25 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
26   --> $DIR/bad-sized.rs:4:37
27    |
28 LL |     let x: Vec<dyn Trait + Sized> = Vec::new();
29    |                                     ^^^^^^^^ doesn't have a size known at compile-time
30    |
31    = help: the trait `Sized` is not implemented for `dyn Trait`
32 note: required by `Vec::<T>::new`
33   --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
34    |
35 LL |     pub const fn new() -> Self {
36    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
37
38 error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
39   --> $DIR/bad-sized.rs:4:37
40    |
41 LL |     let x: Vec<dyn Trait + Sized> = Vec::new();
42    |                                     ^^^ doesn't have a size known at compile-time
43    | 
44   ::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
45    |
46 LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
47    |                - required by this bound in `Vec`
48    |
49    = help: the trait `Sized` is not implemented for `dyn Trait`
50
51 error: aborting due to 4 previous errors
52
53 Some errors have detailed explanations: E0225, E0277.
54 For more information about an error, try `rustc --explain E0225`.