rust/compiler/rustc_trait_selection/src
Alexander Zhang 48167bd4bd Avoid guessing unknown trait impl in suggestions
When a trait is used without specifying the implementation (e.g. calling
a non-member associated function without fully-qualified syntax) and
there are multiple implementations available, use a placeholder comment
for the implementation type in the suggestion instead of picking a
random implementation.

Example:

```
fn main() {
    let _ = Default::default();
}
```

Previous output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = <FileTimes as Default>::default();
  |             +++++++++++++        +
```

New output:

```
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
 --> test.rs:2:13
  |
2 |     let _ = Default::default();
  |             ^^^^^^^^^^^^^^^^ cannot call associated function of trait
  |
help: use a fully-qualified path to a specific available implementation (273 found)
  |
2 |     let _ = </* self type */ as Default>::default();
  |             +++++++++++++++++++        +
```
2023-06-22 16:37:52 -07:00
..
solve Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr 2023-06-21 07:37:01 +02:00
traits Avoid guessing unknown trait impl in suggestions 2023-06-22 16:37:52 -07:00
errors.rs IAT: Introduce AliasKind::Inherent 2023-05-04 16:59:10 +02:00
infer.rs Fallible<_> -> Result<_, NoSolution> 2023-05-25 17:29:22 +00:00
lib.rs remove hash_drain_filter feature uses 2023-06-14 09:28:56 +02:00