Use the proper term when using non-existing variant
When using a non-existing variant, function or associated item, refer to
the proper term, instead of defaulting to "associated item" in
diagnostics.
Fix#28972.
```
error[E0599]: no variant named `Quux` found for type `Foo` in the current scope
--> file.rs:7:9
|
7 | Foo::Quux(..) =>(),
| ^^^^^^^^^^^^^
```
Prior to this PR, when we aborted because a "critical pass" failed, we
displayed the number of errors from that critical pass. While that's the
number of errors that caused compilation to abort in *that place*,
that's not what people really want to know. Instead, always report the
total number of errors, and don't bother to track the number of errors
from the last pass that failed.
This changes the compiler driver API to handle errors more smoothly,
and therefore is a compiler-api-[breaking-change].
Fixes#42793.
When the trait's span is available, it is already being used, add a
`note` for the cases where the span isn't available:
```
error[E0053]: method `fmt` has an incompatible type for trait
--> $DIR/trait_type.rs:17:4
|
17 | fn fmt(&self, x: &str) -> () { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected type `fn(&MyType, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
found type `fn(&MyType, &str)`
error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2
--> $DIR/trait_type.rs:21:11
|
21 | fn fmt(&self) -> () { }
| ^^^^^ expected 2 parameters, found 1
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in the impl
--> $DIR/trait_type.rs:25:4
|
25 | fn fmt() -> () { }
| ^^^^^^^^^^^^^^^^^^ expected `&self` in impl
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
error[E0046]: not all trait items implemented, missing: `fmt`
--> $DIR/trait_type.rs:28:1
|
28 | impl std::fmt::Display for MyType4 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
```
When trying to do a binary operation with missing implementation, for
example `1 + Some(2)`, provide an explicit help message:
```
note: no implementation for `{integer} + std::option::Option<{integer}>`
```
Use `rustc_on_unimplemented` for the suggestions. Move cfail test to ui.