Open
Description
Suppose I learned
- That
[f32; 2]::deserialize(deserializer)
doesn't work, and I need to do<[f32; 2]>::deserialize(deserializer)
instead (thank you syntax: recovery for incorrect associated item paths like[T; N]::clone
#46788), and - That I can do
Default::default()
, instead ofConcreteType::default()
If I combine those two things together and try
let x: u32 = <Default>::default();
Then I get this spew of errors:
error[E0277]: the trait bound `std::default::Default: std::default::Default` is not satisfied
--> src/main.rs:2:18
|
2 | let x: u32 = <Default>::default();
| ^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `std::default::Default`
|
= note: required by `std::default::Default::default`
error[E0038]: the trait `std::default::Default` cannot be made into an object
--> src/main.rs:2:19
|
2 | let x: u32 = <Default>::default();
| ^^^^^^^ the trait `std::default::Default` cannot be made into an object
|
= note: the trait cannot require that `Self : Sized`
error[E0308]: mismatched types
--> src/main.rs:2:18
|
2 | let x: u32 = <Default>::default();
| ^^^^^^^^^^^^^^^^^^^^ expected u32, found trait std::default::Default
|
= note: expected type `u32`
found type `std::default::Default`
error[E0038]: the trait `std::default::Default` cannot be made into an object
--> src/main.rs:2:18
|
2 | let x: u32 = <Default>::default();
| ^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` cannot be made into an object
|
= note: the trait cannot require that `Self : Sized`
error: aborting due to 4 previous errors
Some errors occurred: E0038, E0277, E0308.
For more information about an error, try `rustc --explain E0038`.
I don't know what I'm concretely asking for here (please retitle better), so here are some thoughts:
- The second error is the valuable one here
- "found trait std::default::Default" should perhaps be "found trait object std::default::Default"?
- Maybe this all will just work in Rust 2021 when
<Default>
can meanDefault
, notdyn Default>
...
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Compiler frontend (errors, parsing and HIR)Area: Trait systemCategory: A feature request, i.e: not implemented / a PR.Diagnostics: Too much output caused by a single piece of incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.Working group: Diagnostics