mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Make confusable suggestions verbose
This commit is contained in:
parent
385eea1d46
commit
e1e4da2b0a
@ -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",
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -5,7 +5,12 @@ LL | fn owned(self: Box<Self>);
|
||||
| --------- 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user