Rollup merge of #57795 - estebank:did-you-mean, r=zackmdavis
Use structured suggestion in stead of notes
This commit is contained in:
commit
da182a0fe7
12 changed files with 44 additions and 41 deletions
|
@ -304,7 +304,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
);
|
);
|
||||||
if let Some(suggestion) = suggestion {
|
if let Some(suggestion) = suggestion {
|
||||||
// enum variant
|
// enum variant
|
||||||
err.help(&format!("did you mean `{}`?", suggestion));
|
err.span_suggestion_with_applicability(
|
||||||
|
item_name.span,
|
||||||
|
"did you mean",
|
||||||
|
suggestion.to_string(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
@ -440,7 +445,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(lev_candidate) = lev_candidate {
|
if let Some(lev_candidate) = lev_candidate {
|
||||||
err.help(&format!("did you mean `{}`?", lev_candidate.ident));
|
err.span_suggestion_with_applicability(
|
||||||
|
span,
|
||||||
|
"did you mean",
|
||||||
|
lev_candidate.ident.to_string(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7349,9 +7349,16 @@ impl<'a> Parser<'a> {
|
||||||
// CONST ITEM
|
// CONST ITEM
|
||||||
if self.eat_keyword(keywords::Mut) {
|
if self.eat_keyword(keywords::Mut) {
|
||||||
let prev_span = self.prev_span;
|
let prev_span = self.prev_span;
|
||||||
self.diagnostic().struct_span_err(prev_span, "const globals cannot be mutable")
|
let mut err = self.diagnostic()
|
||||||
.help("did you mean to declare a static?")
|
.struct_span_err(prev_span, "const globals cannot be mutable");
|
||||||
.emit();
|
err.span_label(prev_span, "cannot be mutable");
|
||||||
|
err.span_suggestion_with_applicability(
|
||||||
|
const_span,
|
||||||
|
"you might want to declare a static instead",
|
||||||
|
"static".to_owned(),
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
);
|
||||||
|
err.emit();
|
||||||
}
|
}
|
||||||
let (ident, item_, extra_attrs) = self.parse_item_const(None)?;
|
let (ident, item_, extra_attrs) = self.parse_item_const(None)?;
|
||||||
let prev_span = self.prev_span;
|
let prev_span = self.prev_span;
|
||||||
|
|
|
@ -2,12 +2,11 @@ error[E0599]: no method named `test_mut` found for type `std::vec::Vec<{integer}
|
||||||
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
|
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
|
||||||
|
|
|
|
||||||
LL | a.test_mut(); //~ ERROR no method named `test_mut` found
|
LL | a.test_mut(); //~ ERROR no method named `test_mut` found
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ help: did you mean: `get_mut`
|
||||||
|
|
|
|
||||||
= help: items from traits can only be used if the trait is implemented and in scope
|
= help: items from traits can only be used if the trait is implemented and in scope
|
||||||
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
|
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
|
||||||
candidate #1: `MyIter`
|
candidate #1: `MyIter`
|
||||||
= help: did you mean `get_mut`?
|
|
||||||
|
|
||||||
error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` in the current scope
|
error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` in the current scope
|
||||||
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
|
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
|
||||||
|
|
|
@ -2,9 +2,7 @@ error[E0599]: no method named `b` found for type `&Self` in the current scope
|
||||||
--> $DIR/issue-3563.rs:3:17
|
--> $DIR/issue-3563.rs:3:17
|
||||||
|
|
|
|
||||||
LL | || self.b()
|
LL | || self.b()
|
||||||
| ^
|
| ^ help: did you mean: `a`
|
||||||
|
|
|
||||||
= help: did you mean `a`?
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -51,20 +51,18 @@ error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the
|
||||||
|
|
|
|
||||||
LL | let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type
|
LL | let xe3 = XE::Empty3; //~ ERROR no variant named `Empty3` found for type
|
||||||
| ----^^^^^^
|
| ----^^^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | help: did you mean: `XEmpty3`
|
||||||
| variant not found in `empty_struct::XE`
|
| variant not found in `empty_struct::XE`
|
||||||
|
|
|
||||||
= help: did you mean `XEmpty3`?
|
|
||||||
|
|
||||||
error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope
|
error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope
|
||||||
--> $DIR/empty-struct-braces-expr.rs:23:19
|
--> $DIR/empty-struct-braces-expr.rs:23:19
|
||||||
|
|
|
|
||||||
LL | let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type
|
LL | let xe3 = XE::Empty3(); //~ ERROR no variant named `Empty3` found for type
|
||||||
| ----^^^^^^
|
| ----^^^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | help: did you mean: `XEmpty3`
|
||||||
| variant not found in `empty_struct::XE`
|
| variant not found in `empty_struct::XE`
|
||||||
|
|
|
||||||
= help: did you mean `XEmpty3`?
|
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@ LL | pub enum SomeEnum {
|
||||||
| ----------------- variant `A` not found here
|
| ----------------- variant `A` not found here
|
||||||
LL | B = SomeEnum::A,
|
LL | B = SomeEnum::A,
|
||||||
| ----------^
|
| ----------^
|
||||||
| |
|
| | |
|
||||||
|
| | help: did you mean: `B`
|
||||||
| variant not found in `SomeEnum`
|
| variant not found in `SomeEnum`
|
||||||
|
|
|
||||||
= help: did you mean `B`?
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,7 @@ LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8);
|
||||||
| --------^^^^^
|
| --------^^^^^
|
||||||
| |
|
| |
|
||||||
| function or associated item not found in `dyn std::ops::BitXor<_>`
|
| function or associated item not found in `dyn std::ops::BitXor<_>`
|
||||||
|
|
| help: did you mean: `bitxor`
|
||||||
= help: did you mean `bitxor`?
|
|
||||||
|
|
||||||
error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified
|
error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified
|
||||||
--> $DIR/issue-28344.rs:8:13
|
--> $DIR/issue-28344.rs:8:13
|
||||||
|
@ -27,8 +26,7 @@ LL | let g = BitXor::bitor;
|
||||||
| --------^^^^^
|
| --------^^^^^
|
||||||
| |
|
| |
|
||||||
| function or associated item not found in `dyn std::ops::BitXor<_>`
|
| function or associated item not found in `dyn std::ops::BitXor<_>`
|
||||||
|
|
| help: did you mean: `bitxor`
|
||||||
= help: did you mean `bitxor`?
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ LL | enum Foo {
|
||||||
| -------- variant `Baz` not found here
|
| -------- variant `Baz` not found here
|
||||||
...
|
...
|
||||||
LL | Foo::Baz(..) => (),
|
LL | Foo::Baz(..) => (),
|
||||||
| -----^^^---- variant not found in `Foo`
|
| -----^^^----
|
||||||
|
|
| | |
|
||||||
= help: did you mean `Bar`?
|
| | help: did you mean: `Bar`
|
||||||
|
| variant not found in `Foo`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,10 @@ error[E0599]: no method named `deref_err` found for type `std::result::Result<_,
|
||||||
--> $DIR/result-deref-err.rs:4:28
|
--> $DIR/result-deref-err.rs:4:28
|
||||||
|
|
|
|
||||||
LL | let _result = &Err(41).deref_err();
|
LL | let _result = &Err(41).deref_err();
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ help: did you mean: `deref_ok`
|
||||||
|
|
|
|
||||||
= note: the method `deref_err` exists but the following trait bounds were not satisfied:
|
= note: the method `deref_err` exists but the following trait bounds were not satisfied:
|
||||||
`{integer} : std::ops::Deref`
|
`{integer} : std::ops::Deref`
|
||||||
= help: did you mean `deref_ok`?
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const
|
const
|
||||||
mut //~ ERROR: const globals cannot be mutable
|
mut //~ ERROR: const globals cannot be mutable
|
||||||
//~^ HELP did you mean to declare a static?
|
//~^^ HELP you might want to declare a static instead
|
||||||
FOO: usize = 3;
|
FOO: usize = 3;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
error: const globals cannot be mutable
|
error: const globals cannot be mutable
|
||||||
--> $DIR/issue-17718-const-mut.rs:2:1
|
--> $DIR/issue-17718-const-mut.rs:2:1
|
||||||
|
|
|
|
||||||
|
LL | const
|
||||||
|
| ----- help: you might want to declare a static instead: `static`
|
||||||
LL | mut //~ ERROR: const globals cannot be mutable
|
LL | mut //~ ERROR: const globals cannot be mutable
|
||||||
| ^^^
|
| ^^^ cannot be mutable
|
||||||
|
|
|
||||||
= help: did you mean to declare a static?
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -5,25 +5,19 @@ LL | struct Foo;
|
||||||
| ----------- method `bat` not found for this
|
| ----------- method `bat` not found for this
|
||||||
...
|
...
|
||||||
LL | f.bat(1.0); //~ ERROR no method named
|
LL | f.bat(1.0); //~ ERROR no method named
|
||||||
| ^^^
|
| ^^^ help: did you mean: `bar`
|
||||||
|
|
|
||||||
= help: did you mean `bar`?
|
|
||||||
|
|
||||||
error[E0599]: no method named `is_emtpy` found for type `std::string::String` in the current scope
|
error[E0599]: no method named `is_emtpy` found for type `std::string::String` in the current scope
|
||||||
--> $DIR/suggest-methods.rs:21:15
|
--> $DIR/suggest-methods.rs:21:15
|
||||||
|
|
|
|
||||||
LL | let _ = s.is_emtpy(); //~ ERROR no method named
|
LL | let _ = s.is_emtpy(); //~ ERROR no method named
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ help: did you mean: `is_empty`
|
||||||
|
|
|
||||||
= help: did you mean `is_empty`?
|
|
||||||
|
|
||||||
error[E0599]: no method named `count_eos` found for type `u32` in the current scope
|
error[E0599]: no method named `count_eos` found for type `u32` in the current scope
|
||||||
--> $DIR/suggest-methods.rs:25:19
|
--> $DIR/suggest-methods.rs:25:19
|
||||||
|
|
|
|
||||||
LL | let _ = 63u32.count_eos(); //~ ERROR no method named
|
LL | let _ = 63u32.count_eos(); //~ ERROR no method named
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^ help: did you mean: `count_zeros`
|
||||||
|
|
|
||||||
= help: did you mean `count_zeros`?
|
|
||||||
|
|
||||||
error[E0599]: no method named `count_o` found for type `u32` in the current scope
|
error[E0599]: no method named `count_o` found for type `u32` in the current scope
|
||||||
--> $DIR/suggest-methods.rs:28:19
|
--> $DIR/suggest-methods.rs:28:19
|
||||||
|
|
Loading…
Reference in a new issue