about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/errors.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-06-23 13:18:16 +0200
committerGitHub <noreply@github.com>2023-06-23 13:18:16 +0200
commitc5fd53774fde96b74b31c280972142c04e3a3445 (patch)
tree583ef1002164999982cf99c256bace32b8722e41 /compiler/rustc_mir_transform/src/errors.rs
parent8d6b02fb3b832d9e96efe5a9f4845570039f8805 (diff)
parent48167bd4bddec03d1969e2cc2c1155cb5667d6ad (diff)
downloadrust-c5fd53774fde96b74b31c280972142c04e3a3445.tar.gz
rust-c5fd53774fde96b74b31c280972142c04e3a3445.zip
Rollup merge of #112948 - bkrl:trait-impl-suggestion, r=compiler-errors
Avoid guessing unknown trait implementation 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();
  |             +++++++++++++++++++        +
```

Fixes #112897
Diffstat (limited to 'compiler/rustc_mir_transform/src/errors.rs')
0 files changed, 0 insertions, 0 deletions