diff options
| author | Robin Schroer <git@sulami.xyz> | 2023-01-18 19:58:50 +0900 |
|---|---|---|
| committer | Robin Schroer <git@sulami.xyz> | 2023-01-23 10:07:10 +0900 |
| commit | f908f0be5a088a0e1748c7853a8acf75be6d1c18 (patch) | |
| tree | d13ae9355ba15f7eda05b95da729cb0b02476bef /tests/ui | |
| parent | 51d50ea96ecc9c681a0054e5eb8e5e1d4ab38906 (diff) | |
| download | rust-f908f0be5a088a0e1748c7853a8acf75be6d1c18.tar.gz rust-f908f0be5a088a0e1748c7853a8acf75be6d1c18.zip | |
Consider doc(alias) when providing typo suggestions
This means that
```rust
impl Foo {
#[doc(alias = "quux")]
fn bar(&self) {}
}
fn main() {
(Foo {}).quux();
}
```
will suggest `bar`. This currently uses the "there is a method with a
similar name" help text, because the point where we choose and emit a
suggestion is different from where we gather the suggestions. Changes
have mainly been made to the latter.
The selection code will now fall back to aliased candidates, but
generally only if there is no candidate that matches based on the
existing Levenshtein methodology.
Fixes #83968.
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/methods/method-not-found-but-doc-alias.rs | 11 | ||||
| -rw-r--r-- | tests/ui/methods/method-not-found-but-doc-alias.stderr | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/methods/method-not-found-but-doc-alias.rs b/tests/ui/methods/method-not-found-but-doc-alias.rs new file mode 100644 index 00000000000..9c6d1002923 --- /dev/null +++ b/tests/ui/methods/method-not-found-but-doc-alias.rs @@ -0,0 +1,11 @@ +struct Foo; + +impl Foo { + #[doc(alias = "quux")] + fn bar(&self) {} +} + +fn main() { + Foo.quux(); + //~^ ERROR no method named `quux` found for struct `Foo` in the current scope +} diff --git a/tests/ui/methods/method-not-found-but-doc-alias.stderr b/tests/ui/methods/method-not-found-but-doc-alias.stderr new file mode 100644 index 00000000000..5102a452f0c --- /dev/null +++ b/tests/ui/methods/method-not-found-but-doc-alias.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `quux` found for struct `Foo` in the current scope + --> $DIR/method-not-found-but-doc-alias.rs:9:9 + | +LL | struct Foo; + | ---------- method `quux` not found for this struct +... +LL | Foo.quux(); + | ^^^^ help: there is a method with a similar name: `bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. |
