diff options
| author | bors <bors@rust-lang.org> | 2022-04-04 13:00:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-04 13:00:25 +0000 |
| commit | d5139f44690e7765df801ca33a7f627d128ac9e2 (patch) | |
| tree | 35dd497f50c0bff9d8c82236552bebd701f1fed1 /src | |
| parent | 2ed6786404be276874fbcc7c3540f3237a87e0f3 (diff) | |
| parent | e2dfa23eac2586623bc12a9e43683b9a50874c0b (diff) | |
| download | rust-d5139f44690e7765df801ca33a7f627d128ac9e2.tar.gz rust-d5139f44690e7765df801ca33a7f627d128ac9e2.zip | |
Auto merge of #95119 - OliverMD:method_suggestions, r=davidtwco
Improve method name suggestions Attempts to improve method name suggestions when a matching method name is not found. The approach taken is use the Levenshtein distance and account for substrings having a high distance but can sometimes be very close to the intended method (eg. empty vs is_empty). resolves #94747
Diffstat (limited to 'src')
6 files changed, 12 insertions, 5 deletions
diff --git a/src/test/ui/associated-item/associated-item-enum.stderr b/src/test/ui/associated-item/associated-item-enum.stderr index cadf55454a7..d52b2b36c7b 100644 --- a/src/test/ui/associated-item/associated-item-enum.stderr +++ b/src/test/ui/associated-item/associated-item-enum.stderr @@ -17,7 +17,10 @@ LL | enum Enum { Variant } | --------- variant or associated item `mispellable_trait` not found here ... LL | Enum::mispellable_trait(); - | ^^^^^^^^^^^^^^^^^ variant or associated item not found in `Enum` + | ^^^^^^^^^^^^^^^^^ + | | + | variant or associated item not found in `Enum` + | help: there is an associated function with a similar name: `misspellable` error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope --> $DIR/associated-item-enum.rs:19:11 diff --git a/src/test/ui/derives/issue-91550.stderr b/src/test/ui/derives/issue-91550.stderr index bf4b7c7da0d..1b26d754984 100644 --- a/src/test/ui/derives/issue-91550.stderr +++ b/src/test/ui/derives/issue-91550.stderr @@ -8,7 +8,7 @@ LL | struct Value(u32); | doesn't satisfy `Value: Hash` ... LL | hs.insert(Value(0)); - | ^^^^^^ method cannot be called on `HashSet<Value>` due to unsatisfied trait bounds + | ^^^^^^ | = note: the following trait bounds were not satisfied: `Value: Eq` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr index 52ee1db5b15..943f7748696 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/option-as_deref_mut.stderr @@ -2,7 +2,7 @@ error[E0599]: the method `as_deref_mut` exists for enum `Option<{integer}>`, but --> $DIR/option-as_deref_mut.rs:2:33 | LL | let _result = &mut Some(42).as_deref_mut(); - | ^^^^^^^^^^^^ method cannot be called on `Option<{integer}>` due to unsatisfied trait bounds + | ^^^^^^^^^^^^ | = note: the following trait bounds were not satisfied: `{integer}: Deref` diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr index 018557881ef..aa771e4c04e 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr @@ -2,7 +2,7 @@ error[E0599]: the method `as_deref_mut` exists for enum `Result<{integer}, _>`, --> $DIR/result-as_deref_mut.rs:2:31 | LL | let _result = &mut Ok(42).as_deref_mut(); - | ^^^^^^^^^^^^ method cannot be called on `Result<{integer}, _>` due to unsatisfied trait bounds + | ^^^^^^^^^^^^ | = note: the following trait bounds were not satisfied: `{integer}: Deref` diff --git a/src/test/ui/rust-2018/trait-import-suggestions.stderr b/src/test/ui/rust-2018/trait-import-suggestions.stderr index eb4e43aaec3..6454b6045e4 100644 --- a/src/test/ui/rust-2018/trait-import-suggestions.stderr +++ b/src/test/ui/rust-2018/trait-import-suggestions.stderr @@ -45,6 +45,10 @@ help: the following trait is implemented but not in scope; perhaps add a `use` f | LL | use std::str::FromStr; | +help: there is an associated function with a similar name + | +LL | let y = u32::from_str_radix("33"); + | ~~~~~~~~~~~~~~ error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/suggest-methods.stderr b/src/test/ui/suggestions/suggest-methods.stderr index 535841e535b..9079e8f2ce7 100644 --- a/src/test/ui/suggestions/suggest-methods.stderr +++ b/src/test/ui/suggestions/suggest-methods.stderr @@ -23,7 +23,7 @@ error[E0599]: no method named `count_o` found for type `u32` in the current scop --> $DIR/suggest-methods.rs:28:19 | LL | let _ = 63u32.count_o(); - | ^^^^^^^ method not found in `u32` + | ^^^^^^^ help: there is an associated function with a similar name: `count_ones` error: aborting due to 4 previous errors |
