Use structured suggestion in stead of notes

This commit is contained in:
Esteban Küber 2019-01-20 19:37:38 -08:00
parent e73069767f
commit 45a95b512c
12 changed files with 44 additions and 41 deletions

View file

@ -304,7 +304,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
);
if let Some(suggestion) = suggestion {
// 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
}
@ -440,7 +445,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
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();
}

View file

@ -7271,9 +7271,16 @@ impl<'a> Parser<'a> {
// CONST ITEM
if self.eat_keyword(keywords::Mut) {
let prev_span = self.prev_span;
self.diagnostic().struct_span_err(prev_span, "const globals cannot be mutable")
.help("did you mean to declare a static?")
.emit();
let mut err = self.diagnostic()
.struct_span_err(prev_span, "const globals cannot be mutable");
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 prev_span = self.prev_span;

View file

@ -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
|
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
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
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
--> $DIR/auto-ref-slice-plus-ref.rs:8:7

View file

@ -2,9 +2,7 @@ error[E0599]: no method named `b` found for type `&Self` in the current scope
--> $DIR/issue-3563.rs:3:17
|
LL | || self.b()
| ^
|
= help: did you mean `a`?
| ^ help: did you mean: `a`
error: aborting due to previous error

View file

@ -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
| ----^^^^^^
| |
| | |
| | help: did you mean: `XEmpty3`
| 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
--> $DIR/empty-struct-braces-expr.rs:23:19
|
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`
|
= help: did you mean `XEmpty3`?
error: aborting due to 8 previous errors

View file

@ -5,10 +5,9 @@ LL | pub enum SomeEnum {
| ----------------- variant `A` not found here
LL | B = SomeEnum::A,
| ----------^
| |
| | |
| | help: did you mean: `B`
| variant not found in `SomeEnum`
|
= help: did you mean `B`?
error: aborting due to previous error

View file

@ -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<_>`
|
= 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
--> $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<_>`
|
= help: did you mean `bitxor`?
| help: did you mean: `bitxor`
error: aborting due to 4 previous errors

View file

@ -5,9 +5,10 @@ LL | enum Foo {
| -------- variant `Baz` not found here
...
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

View file

@ -2,11 +2,10 @@ error[E0599]: no method named `deref_err` found for type `std::result::Result<_,
--> $DIR/result-deref-err.rs:4:28
|
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:
`{integer} : std::ops::Deref`
= help: did you mean `deref_ok`?
error: aborting due to previous error

View file

@ -1,6 +1,6 @@
const
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;
fn main() {

View file

@ -1,10 +1,10 @@
error: const globals cannot be mutable
--> $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
| ^^^
|
= help: did you mean to declare a static?
| ^^^ cannot be mutable
error: aborting due to previous error

View file

@ -5,25 +5,19 @@ LL | struct Foo;
| ----------- method `bat` not found for this
...
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
--> $DIR/suggest-methods.rs:21:15
|
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
--> $DIR/suggest-methods.rs:25:19
|
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
--> $DIR/suggest-methods.rs:28:19