|
1 |
| -error[E0277]: the trait bound `(): std::error::Error` is not satisfied |
2 |
| - --> $DIR/coerce-issue-49593-box-never.rs:18:5 |
| 1 | +error[E0277]: the size for values of type `dyn std::error::Error` cannot be known at compilation time |
| 2 | + --> $DIR/coerce-issue-49593-box-never.rs:26:27 |
3 | 3 | |
|
4 | 4 | LL | Box::<_ /* ! */>::new(x)
|
5 |
| - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` |
| 5 | + | --------------------- ^ doesn't have a size known at compile-time |
| 6 | + | | |
| 7 | + | required by a bound introduced by this call |
6 | 8 | |
|
7 |
| - = note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>` |
| 9 | + = help: the trait `Sized` is not implemented for `dyn std::error::Error` |
| 10 | +note: required by a bound in `Box::<T>::new` |
| 11 | + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL |
8 | 12 |
|
9 |
| -error[E0277]: the trait bound `(): std::error::Error` is not satisfied |
10 |
| - --> $DIR/coerce-issue-49593-box-never.rs:24:5 |
| 13 | +error[E0277]: the size for values of type `(dyn std::error::Error + 'static)` cannot be known at compilation time |
| 14 | + --> $DIR/coerce-issue-49593-box-never.rs:32:19 |
11 | 15 | |
|
12 | 16 | LL | raw_ptr_box::<_ /* ! */>(x)
|
13 |
| - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()` |
| 17 | + | ^ doesn't have a size known at compile-time |
14 | 18 | |
|
15 |
| - = note: required for the cast from `*mut ()` to `*mut (dyn std::error::Error + 'static)` |
| 19 | + = help: the trait `Sized` is not implemented for `(dyn std::error::Error + 'static)` |
| 20 | +note: required by an implicit `Sized` bound in `raw_ptr_box` |
| 21 | + --> $DIR/coerce-issue-49593-box-never.rs:19:16 |
| 22 | + | |
| 23 | +LL | fn raw_ptr_box<T>(t: T) -> *mut T { |
| 24 | + | ^ required by the implicit `Sized` requirement on this type parameter in `raw_ptr_box` |
| 25 | +help: consider relaxing the implicit `Sized` restriction |
| 26 | + | |
| 27 | +LL | fn raw_ptr_box<T: ?Sized>(t: T) -> *mut T { |
| 28 | + | ++++++++ |
| 29 | + |
| 30 | +error[E0277]: the size for values of type `(dyn std::error::Error + 'static)` cannot be known at compilation time |
| 31 | + --> $DIR/coerce-issue-49593-box-never.rs:32:30 |
| 32 | + | |
| 33 | +LL | raw_ptr_box::<_ /* ! */>(x) |
| 34 | + | ^ doesn't have a size known at compile-time |
| 35 | + | |
| 36 | + = help: the trait `Sized` is not implemented for `(dyn std::error::Error + 'static)` |
| 37 | + = note: all function arguments must have a statically known size |
| 38 | + = help: unsized fn params are gated as an unstable feature |
| 39 | + |
| 40 | +error[E0277]: the size for values of type `dyn Xyz` cannot be known at compilation time |
| 41 | + --> $DIR/coerce-issue-49593-box-never.rs:57:70 |
| 42 | + | |
| 43 | +LL | = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap()); |
| 44 | + | -------- ^^^^^^^^^^ doesn't have a size known at compile-time |
| 45 | + | | |
| 46 | + | required by a bound introduced by this call |
| 47 | + | |
| 48 | + = help: the trait `Sized` is not implemented for `dyn Xyz` |
| 49 | +note: required by a bound in `Box::<T>::new` |
| 50 | + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL |
| 51 | +help: consider removing this method call, as the receiver has type `Option<_>` and `Option<_>: Sized` trivially holds |
| 52 | + | |
| 53 | +LL - = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap()); |
| 54 | +LL + = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x); |
| 55 | + | |
| 56 | + |
| 57 | +error[E0277]: the size for values of type `dyn Xyz` cannot be known at compilation time |
| 58 | + --> $DIR/coerce-issue-49593-box-never.rs:57:72 |
| 59 | + | |
| 60 | +LL | = /* Box<$0> is coerced to Box<Xyz> here */ Box::new(x.unwrap()); |
| 61 | + | ^^^^^^ doesn't have a size known at compile-time |
| 62 | + | |
| 63 | + = help: the trait `Sized` is not implemented for `dyn Xyz` |
| 64 | +note: required by a bound in `Option::<T>::unwrap` |
| 65 | + --> $SRC_DIR/core/src/option.rs:LL:COL |
| 66 | + |
| 67 | +error[E0277]: the size for values of type `dyn Xyz` cannot be known at compilation time |
| 68 | + --> $DIR/coerce-issue-49593-box-never.rs:50:35 |
| 69 | + | |
| 70 | +LL | let mut x /* : Option<S> */ = None; |
| 71 | + | ^^^^ doesn't have a size known at compile-time |
| 72 | + | |
| 73 | + = help: the trait `Sized` is not implemented for `dyn Xyz` |
| 74 | +note: required by a bound in `None` |
| 75 | + --> $SRC_DIR/core/src/option.rs:LL:COL |
| 76 | + |
| 77 | +error[E0308]: mismatched types |
| 78 | + --> $DIR/coerce-issue-49593-box-never.rs:62:13 |
| 79 | + | |
| 80 | +LL | let mut x /* : Option<S> */ = None; |
| 81 | + | ---- expected due to this value |
| 82 | +... |
| 83 | +LL | x = Some(S); |
| 84 | + | ^^^^^^^ expected `Option<dyn Xyz>`, found `Option<S>` |
| 85 | + | |
| 86 | + = note: expected enum `Option<dyn Xyz>` |
| 87 | + found enum `Option<S>` |
| 88 | + = help: `S` implements `Xyz` so you could box the found value and coerce it to the trait object `Box<dyn Xyz>`, you will have to change the expected type as well |
| 89 | + |
| 90 | +error[E0277]: the size for values of type `dyn Xyz` cannot be known at compilation time |
| 91 | + --> $DIR/coerce-issue-49593-box-never.rs:69:5 |
| 92 | + | |
| 93 | +LL | mem::swap(&mut x, &mut y); |
| 94 | + | ^^^^^^^^^ doesn't have a size known at compile-time |
| 95 | + | |
| 96 | + = help: the trait `Sized` is not implemented for `dyn Xyz` |
| 97 | +note: required by an implicit `Sized` bound in `Option` |
| 98 | + --> $SRC_DIR/core/src/option.rs:LL:COL |
| 99 | + |
| 100 | +error[E0308]: mismatched types |
| 101 | + --> $DIR/coerce-issue-49593-box-never.rs:69:23 |
| 102 | + | |
| 103 | +LL | mem::swap(&mut x, &mut y); |
| 104 | + | --------- ^^^^^^ expected `&mut Option<dyn Xyz>`, found `&mut Option<S>` |
| 105 | + | | |
| 106 | + | arguments to this function are incorrect |
| 107 | + | |
| 108 | + = note: expected mutable reference `&mut Option<dyn Xyz>` |
| 109 | + found mutable reference `&mut Option<S>` |
| 110 | + = help: `S` implements `Xyz` so you could box the found value and coerce it to the trait object `Box<dyn Xyz>`, you will have to change the expected type as well |
| 111 | +note: function defined here |
| 112 | + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL |
16 | 113 |
|
17 |
| -error: aborting due to 2 previous errors |
| 114 | +error: aborting due to 9 previous errors |
18 | 115 |
|
19 |
| -For more information about this error, try `rustc --explain E0277`. |
| 116 | +Some errors have detailed explanations: E0277, E0308. |
| 117 | +For more information about an error, try `rustc --explain E0277`. |
0 commit comments