Closed
Description
The following code:
struct Foo {
val: MissingType
}
fn make_it() {
Foo { val: Default::default() };
}
produces the following errors:
error[E0412]: cannot find type `MissingType` in this scope
--> src/lib.rs:2:10
|
2 | val: MissingType
| ^^^^^^^^^^^ not found in this scope
error[E0283]: type annotations needed
--> src/lib.rs:6:16
|
6 | Foo { val: Default::default() };
| ^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot satisfy `_: std::default::Default`
= note: required by `std::default::Default::default`
We should suppress the 'type annotations needed' message, since it will likely be resolved by fixing the type of val
.
Activity
kpreid commentedon May 11, 2022
I was just reviewing issues discussing “type annotations needed” and I think this might be very similar or duplicate to #68507 (where the field type is
Option<MissingType>
and the value isNone
, instead of involving a trait).estebank commentedon Dec 28, 2022
Current output:
The fully-qualified path suggestion isn't great. It's likely that val is of
[type error]
, and we should hide the E0790 when that is the case.Rollup merge of rust-lang#106302 - compiler-errors:terr-coerce-w-infe…
Auto merge of rust-lang#106302 - compiler-errors:terr-coerce-w-infer,…