rust/tests/ui/impl-trait/unsized_coercion3.next.stderr

39 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-05-31 04:51:10 -05:00
error[E0271]: type mismatch resolving `impl Trait + ?Sized <: dyn Send`
--> $DIR/unsized_coercion3.rs:13:17
|
LL | let x = hello();
| ^^^^^^^ types differ
error[E0308]: mismatched types
--> $DIR/unsized_coercion3.rs:18:14
2024-05-31 04:51:10 -05:00
|
LL | fn hello() -> Box<impl Trait + ?Sized> {
| ------------------- the expected opaque type
...
LL | Box::new(1u32)
| -------- ^^^^ types differ
| |
| arguments to this function are incorrect
|
= note: expected opaque type `impl Trait + ?Sized`
found type `u32`
note: associated function defined here
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
--> $DIR/unsized_coercion3.rs:18:14
2024-05-31 04:51:10 -05:00
|
LL | Box::new(1u32)
| -------- ^^^^ doesn't have a size known at compile-time
| |
| required by a bound introduced by this call
|
= help: the trait `Sized` is not implemented for `impl Trait + ?Sized`
note: required by a bound in `Box::<T>::new`
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0271, E0277, E0308.
For more information about an error, try `rustc --explain E0271`.