about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/errors.rs
diff options
context:
space:
mode:
authorAlexander Zhang <alex@alexyzhang.dev>2023-06-22 16:37:52 -0700
committerAlexander Zhang <alex@alexyzhang.dev>2023-06-22 16:37:52 -0700
commit48167bd4bddec03d1969e2cc2c1155cb5667d6ad (patch)
tree06f51fc27999860622967985fde940b5dd46ddbd /compiler/rustc_interface/src/errors.rs
parent04075b32021932e3e8f6ab55d519b3b3494b6ef9 (diff)
downloadrust-48167bd4bddec03d1969e2cc2c1155cb5667d6ad.tar.gz
rust-48167bd4bddec03d1969e2cc2c1155cb5667d6ad.zip
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();
  |             +++++++++++++++++++        +
```
Diffstat (limited to 'compiler/rustc_interface/src/errors.rs')
0 files changed, 0 insertions, 0 deletions