diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 735a1b17d7e..202df8dcc12 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1375,7 +1375,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // We found a method with the same number of arguments as the method // call expression the user wrote. - err.span_suggestion( + err.span_suggestion_verbose( span, format!("there is {an} method with a similar name"), similar_candidate.name, @@ -1402,7 +1402,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { // We have fn call expression and the argument count match the associated // function we found. - err.span_suggestion( + err.span_suggestion_verbose( span, format!( "there is {an} {} with a similar name", @@ -1423,7 +1423,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } else if let Mode::Path = mode { // We have an associated item syntax and we found something that isn't an fn. - err.span_suggestion( + err.span_suggestion_verbose( span, format!( "there is {an} {} with a similar name", diff --git a/tests/ui/associated-item/associated-item-enum.stderr b/tests/ui/associated-item/associated-item-enum.stderr index 9e9f5c0daad..a966468e3dd 100644 --- a/tests/ui/associated-item/associated-item-enum.stderr +++ b/tests/ui/associated-item/associated-item-enum.stderr @@ -5,10 +5,12 @@ LL | enum Enum { Variant } | --------- variant or associated item `mispellable` not found for this enum ... LL | Enum::mispellable(); - | ^^^^^^^^^^^ - | | - | variant or associated item not found in `Enum` - | help: there is an associated function with a similar name: `misspellable` + | ^^^^^^^^^^^ variant or associated item not found in `Enum` + | +help: there is an associated function with a similar name + | +LL | Enum::misspellable(); + | ~~~~~~~~~~~~ error[E0599]: no variant or associated item named `mispellable_trait` found for enum `Enum` in the current scope --> $DIR/associated-item-enum.rs:18:11 @@ -17,10 +19,12 @@ LL | enum Enum { Variant } | --------- variant or associated item `mispellable_trait` not found for this enum ... LL | Enum::mispellable_trait(); - | ^^^^^^^^^^^^^^^^^ - | | - | variant or associated item not found in `Enum` - | help: there is an associated function with a similar name: `misspellable_trait` + | ^^^^^^^^^^^^^^^^^ variant or associated item not found in `Enum` + | +help: there is an associated function with a similar name + | +LL | Enum::misspellable_trait(); + | ~~~~~~~~~~~~~~~~~~ error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope --> $DIR/associated-item-enum.rs:19:11 @@ -29,10 +33,12 @@ LL | enum Enum { Variant } | --------- variant or associated item `MISPELLABLE` not found for this enum ... LL | Enum::MISPELLABLE; - | ^^^^^^^^^^^ - | | - | variant or associated item not found in `Enum` - | help: there is an associated constant with a similar name: `MISSPELLABLE` + | ^^^^^^^^^^^ variant or associated item not found in `Enum` + | +help: there is an associated constant with a similar name + | +LL | Enum::MISSPELLABLE; + | ~~~~~~~~~~~~ error: aborting due to 3 previous errors diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr index 93c31fd5a34..60dc0e396ba 100644 --- a/tests/ui/attributes/rustc_confusables.stderr +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -31,7 +31,12 @@ error[E0599]: no method named `inser` found for struct `rustc_confusables_across --> $DIR/rustc_confusables.rs:12:7 | LL | x.inser(); - | ^^^^^ help: there is a method with a similar name: `insert` + | ^^^^^ + | +help: there is a method with a similar name + | +LL | x.insert(); + | ~~~~~~ error[E0599]: no method named `foo` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope --> $DIR/rustc_confusables.rs:15:7 diff --git a/tests/ui/block-result/issue-3563.stderr b/tests/ui/block-result/issue-3563.stderr index c473a84413e..3381ae5f657 100644 --- a/tests/ui/block-result/issue-3563.stderr +++ b/tests/ui/block-result/issue-3563.stderr @@ -2,7 +2,12 @@ error[E0599]: no method named `b` found for reference `&Self` in the current sco --> $DIR/issue-3563.rs:3:17 | LL | || self.b() - | ^ help: there is a method with a similar name: `a` + | ^ + | +help: there is a method with a similar name + | +LL | || self.a() + | ~ error: aborting due to 1 previous error diff --git a/tests/ui/methods/issues/issue-105732.stderr b/tests/ui/methods/issues/issue-105732.stderr index 19ccd2de685..906bd6c8636 100644 --- a/tests/ui/methods/issues/issue-105732.stderr +++ b/tests/ui/methods/issues/issue-105732.stderr @@ -10,7 +10,12 @@ error[E0599]: no method named `g` found for reference `&Self` in the current sco --> $DIR/issue-105732.rs:10:14 | LL | self.g(); - | ^ help: there is a method with a similar name: `f` + | ^ + | +help: there is a method with a similar name + | +LL | self.f(); + | ~ error: aborting due to 2 previous errors diff --git a/tests/ui/methods/method-not-found-but-doc-alias.stderr b/tests/ui/methods/method-not-found-but-doc-alias.stderr index 9746c404013..d8c2ea00137 100644 --- a/tests/ui/methods/method-not-found-but-doc-alias.stderr +++ b/tests/ui/methods/method-not-found-but-doc-alias.stderr @@ -5,7 +5,12 @@ LL | struct Foo; | ---------- method `quux` not found for this struct ... LL | Foo.quux(); - | ^^^^ help: there is a method with a similar name: `bar` + | ^^^^ + | +help: there is a method with a similar name + | +LL | Foo.bar(); + | ~~~ error: aborting due to 1 previous error diff --git a/tests/ui/object-pointer-types.stderr b/tests/ui/object-pointer-types.stderr index fe21bf3aede..e581d2d40bd 100644 --- a/tests/ui/object-pointer-types.stderr +++ b/tests/ui/object-pointer-types.stderr @@ -5,7 +5,12 @@ LL | fn owned(self: Box); | --------- the method might not be found because of this arbitrary self type ... LL | x.owned(); - | ^^^^^ help: there is a method with a similar name: `to_owned` + | ^^^^^ + | +help: there is a method with a similar name + | +LL | x.to_owned(); + | ~~~~~~~~ error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope --> $DIR/object-pointer-types.rs:17:7 diff --git a/tests/ui/parser/emoji-identifiers.stderr b/tests/ui/parser/emoji-identifiers.stderr index 1fc561d32c6..cd306696dde 100644 --- a/tests/ui/parser/emoji-identifiers.stderr +++ b/tests/ui/parser/emoji-identifiers.stderr @@ -71,16 +71,17 @@ LL | struct ๐Ÿ‘€; | --------- function or associated item `full_ofโœจ` not found for this struct ... LL | ๐Ÿ‘€::full_ofโœจ() - | ^^^^^^^^^ - | | - | function or associated item not found in `๐Ÿ‘€` - | help: there is an associated function with a similar name: `full_of_โœจ` + | ^^^^^^^^^ function or associated item not found in `๐Ÿ‘€` | note: if you're trying to build a new `๐Ÿ‘€`, consider using `๐Ÿ‘€::full_of_โœจ` which returns `๐Ÿ‘€` --> $DIR/emoji-identifiers.rs:4:5 | LL | fn full_of_โœจ() -> ๐Ÿ‘€ { | ^^^^^^^^^^^^^^^^^^^^^ +help: there is an associated function with a similar name + | +LL | ๐Ÿ‘€::full_of_โœจ() + | ~~~~~~~~~~ error[E0425]: cannot find function `i_like_to_๐Ÿ˜„_a_lot` in this scope --> $DIR/emoji-identifiers.rs:13:13 diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr index 89b69e14099..b0061217500 100644 --- a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr +++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr @@ -14,10 +14,12 @@ LL | struct Struct; | ------------- function or associated item `fob` not found for this struct ... LL | Struct::fob(); - | ^^^ - | | - | function or associated item not found in `Struct` - | help: there is an associated function with a similar name: `foo` + | ^^^ function or associated item not found in `Struct` + | +help: there is an associated function with a similar name + | +LL | Struct::foo(); + | ~~~ error[E0433]: failed to resolve: use of undeclared type `Struc` --> $DIR/typo-suggestion-mistyped-in-path.rs:27:5 diff --git a/tests/ui/rust-2018/trait-import-suggestions.stderr b/tests/ui/rust-2018/trait-import-suggestions.stderr index a9d625df9ba..36cce0aab51 100644 --- a/tests/ui/rust-2018/trait-import-suggestions.stderr +++ b/tests/ui/rust-2018/trait-import-suggestions.stderr @@ -40,7 +40,12 @@ error[E0599]: no method named `baz` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:29:7 | LL | x.baz(); - | ^^^ help: there is a method with a similar name: `bar` + | ^^^ + | +help: there is a method with a similar name + | +LL | x.bar(); + | ~~~ error[E0599]: no function or associated item named `from_str` found for type `u32` in the current scope --> $DIR/trait-import-suggestions.rs:30:18 diff --git a/tests/ui/self/arbitrary_self_type_mut_difference.stderr b/tests/ui/self/arbitrary_self_type_mut_difference.stderr index a56d58694aa..2a7192a83f5 100644 --- a/tests/ui/self/arbitrary_self_type_mut_difference.stderr +++ b/tests/ui/self/arbitrary_self_type_mut_difference.stderr @@ -2,25 +2,33 @@ error[E0599]: no method named `x` found for struct `Pin<&S>` in the current scop --> $DIR/arbitrary_self_type_mut_difference.rs:11:18 | LL | Pin::new(&S).x(); - | ^ help: there is a method with a similar name: `y` + | ^ | note: method is available for `Pin<&mut S>` --> $DIR/arbitrary_self_type_mut_difference.rs:6:5 | LL | fn x(self: Pin<&mut Self>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | Pin::new(&S).y(); + | ~ error[E0599]: no method named `y` found for struct `Pin<&mut S>` in the current scope --> $DIR/arbitrary_self_type_mut_difference.rs:12:22 | LL | Pin::new(&mut S).y(); - | ^ help: there is a method with a similar name: `x` + | ^ | note: method is available for `Pin<&S>` --> $DIR/arbitrary_self_type_mut_difference.rs:7:5 | LL | fn y(self: Pin<&Self>) {} | ^^^^^^^^^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | Pin::new(&mut S).x(); + | ~ error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-109291.stderr b/tests/ui/suggestions/issue-109291.stderr index c787be4de7c..7a2821a069b 100644 --- a/tests/ui/suggestions/issue-109291.stderr +++ b/tests/ui/suggestions/issue-109291.stderr @@ -2,10 +2,7 @@ error[E0599]: no function or associated item named `forced_capture` found for st --> $DIR/issue-109291.rs:2:65 | LL | println!("Custom backtrace: {}", std::backtrace::Backtrace::forced_capture()); - | ^^^^^^^^^^^^^^ - | | - | function or associated item not found in `Backtrace` - | help: there is an associated function with a similar name: `force_capture` + | ^^^^^^^^^^^^^^ function or associated item not found in `Backtrace` | note: if you're trying to build a new `Backtrace` consider using one of the following associated functions: Backtrace::capture @@ -13,6 +10,10 @@ note: if you're trying to build a new `Backtrace` consider using one of the foll Backtrace::disabled Backtrace::create --> $SRC_DIR/std/src/backtrace.rs:LL:COL +help: there is an associated function with a similar name + | +LL | println!("Custom backtrace: {}", std::backtrace::Backtrace::force_capture()); + | ~~~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/suggest-methods.stderr b/tests/ui/suggestions/suggest-methods.stderr index 293009f289b..5115a072426 100644 --- a/tests/ui/suggestions/suggest-methods.stderr +++ b/tests/ui/suggestions/suggest-methods.stderr @@ -17,19 +17,34 @@ error[E0599]: no method named `is_emtpy` found for struct `String` in the curren --> $DIR/suggest-methods.rs:22:15 | LL | let _ = s.is_emtpy(); - | ^^^^^^^^ help: there is a method with a similar name: `is_empty` + | ^^^^^^^^ + | +help: there is a method with a similar name + | +LL | let _ = s.is_empty(); + | ~~~~~~~~ error[E0599]: no method named `count_eos` found for type `u32` in the current scope --> $DIR/suggest-methods.rs:27:19 | LL | let _ = 63u32.count_eos(); - | ^^^^^^^^^ help: there is a method with a similar name: `count_zeros` + | ^^^^^^^^^ + | +help: there is a method with a similar name + | +LL | let _ = 63u32.count_zeros(); + | ~~~~~~~~~~~ error[E0599]: no method named `count_o` found for type `u32` in the current scope --> $DIR/suggest-methods.rs:30:19 | LL | let _ = 63u32.count_o(); - | ^^^^^^^ help: there is a method with a similar name: `count_ones` + | ^^^^^^^ + | +help: there is a method with a similar name + | +LL | let _ = 63u32.count_ones(); + | ~~~~~~~~~~ error: aborting due to 4 previous errors diff --git a/tests/ui/traits/trait-upcasting/subtrait-method.stderr b/tests/ui/traits/trait-upcasting/subtrait-method.stderr index 918159e845b..f3eb86c7681 100644 --- a/tests/ui/traits/trait-upcasting/subtrait-method.stderr +++ b/tests/ui/traits/trait-upcasting/subtrait-method.stderr @@ -2,7 +2,7 @@ error[E0599]: no method named `c` found for reference `&dyn Bar` in the current --> $DIR/subtrait-method.rs:55:9 | LL | bar.c(); - | ^ help: there is a method with a similar name: `a` + | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it @@ -10,12 +10,16 @@ note: `Baz` defines an item `c`, perhaps you need to implement it | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | bar.a(); + | ~ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope --> $DIR/subtrait-method.rs:59:9 | LL | foo.b(); - | ^ help: there is a method with a similar name: `a` + | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it @@ -23,12 +27,16 @@ note: `Bar` defines an item `b`, perhaps you need to implement it | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | foo.a(); + | ~ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope --> $DIR/subtrait-method.rs:61:9 | LL | foo.c(); - | ^ help: there is a method with a similar name: `a` + | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it @@ -36,12 +44,16 @@ note: `Baz` defines an item `c`, perhaps you need to implement it | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | foo.a(); + | ~ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope --> $DIR/subtrait-method.rs:65:9 | LL | foo.b(); - | ^ help: there is a method with a similar name: `a` + | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it @@ -49,12 +61,16 @@ note: `Bar` defines an item `b`, perhaps you need to implement it | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | foo.a(); + | ~ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope --> $DIR/subtrait-method.rs:67:9 | LL | foo.c(); - | ^ help: there is a method with a similar name: `a` + | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it @@ -62,6 +78,10 @@ note: `Baz` defines an item `c`, perhaps you need to implement it | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ +help: there is a method with a similar name + | +LL | foo.a(); + | ~ error: aborting due to 5 previous errors