Always sort suggestions before emitting them
This commit is contained in:
parent
ef212e7fb3
commit
881a50c0b7
10 changed files with 39 additions and 35 deletions
|
@ -465,10 +465,14 @@ impl Diagnostic {
|
||||||
suggestions: impl Iterator<Item = String>,
|
suggestions: impl Iterator<Item = String>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
self.suggestions.push(CodeSuggestion {
|
let mut suggestions: Vec<_> = suggestions.collect();
|
||||||
substitutions: suggestions
|
suggestions.sort();
|
||||||
|
let substitutions = suggestions
|
||||||
|
.into_iter()
|
||||||
.map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] })
|
.map(|snippet| Substitution { parts: vec![SubstitutionPart { snippet, span: sp }] })
|
||||||
.collect(),
|
.collect();
|
||||||
|
self.suggestions.push(CodeSuggestion {
|
||||||
|
substitutions,
|
||||||
msg: msg.to_owned(),
|
msg: msg.to_owned(),
|
||||||
style: SuggestionStyle::ShowCode,
|
style: SuggestionStyle::ShowCode,
|
||||||
applicability,
|
applicability,
|
||||||
|
|
|
@ -6,12 +6,12 @@ LL | #[deprecated = b"test"]
|
||||||
|
|
|
|
||||||
help: the following are the possible correct uses
|
help: the following are the possible correct uses
|
||||||
|
|
|
|
||||||
LL | #[deprecated]
|
|
||||||
| ~~~~~~~~~~~~~
|
|
||||||
LL | #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")]
|
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | #[deprecated = "reason"]
|
LL | #[deprecated = "reason"]
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")]
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | #[deprecated]
|
||||||
|
| ~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ LL | this_function_expects_a_double_option(n);
|
||||||
found type `usize`
|
found type `usize`
|
||||||
help: try using a variant of the expected enum
|
help: try using a variant of the expected enum
|
||||||
|
|
|
|
||||||
LL | this_function_expects_a_double_option(DoubleOption::FirstSome(n));
|
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n));
|
LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n));
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | this_function_expects_a_double_option(DoubleOption::FirstSome(n));
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/issue-42764.rs:27:33
|
--> $DIR/issue-42764.rs:27:33
|
||||||
|
|
|
@ -24,10 +24,10 @@ LL | #[macro_use = "2700"] struct S;
|
||||||
|
|
|
|
||||||
help: the following are the possible correct uses
|
help: the following are the possible correct uses
|
||||||
|
|
|
|
||||||
LL | #[macro_use] struct S;
|
|
||||||
| ~~~~~~~~~~~~
|
|
||||||
LL | #[macro_use(name1, name2, ...)] struct S;
|
LL | #[macro_use(name1, name2, ...)] struct S;
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | #[macro_use] struct S;
|
||||||
|
| ~~~~~~~~~~~~
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@ help: the following traits are implemented but not in scope; perhaps add a `use`
|
||||||
|
|
|
|
||||||
LL | use foo::Bar;
|
LL | use foo::Bar;
|
||||||
|
|
|
|
||||||
|
LL | use no_method_suggested_traits::Reexported;
|
||||||
|
|
|
||||||
LL | use no_method_suggested_traits::foo::PubPub;
|
LL | use no_method_suggested_traits::foo::PubPub;
|
||||||
|
|
|
|
||||||
LL | use no_method_suggested_traits::qux::PrivPub;
|
LL | use no_method_suggested_traits::qux::PrivPub;
|
||||||
|
|
|
|
||||||
LL | use no_method_suggested_traits::Reexported;
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0599]: no method named `method` found for struct `Rc<&mut Box<&u32>>` in the current scope
|
error[E0599]: no method named `method` found for struct `Rc<&mut Box<&u32>>` in the current scope
|
||||||
--> $DIR/no-method-suggested-traits.rs:26:44
|
--> $DIR/no-method-suggested-traits.rs:26:44
|
||||||
|
@ -27,12 +27,12 @@ help: the following traits are implemented but not in scope; perhaps add a `use`
|
||||||
|
|
|
|
||||||
LL | use foo::Bar;
|
LL | use foo::Bar;
|
||||||
|
|
|
|
||||||
|
LL | use no_method_suggested_traits::Reexported;
|
||||||
|
|
|
||||||
LL | use no_method_suggested_traits::foo::PubPub;
|
LL | use no_method_suggested_traits::foo::PubPub;
|
||||||
|
|
|
|
||||||
LL | use no_method_suggested_traits::qux::PrivPub;
|
LL | use no_method_suggested_traits::qux::PrivPub;
|
||||||
|
|
|
|
||||||
LL | use no_method_suggested_traits::Reexported;
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0599]: no method named `method` found for type `char` in the current scope
|
error[E0599]: no method named `method` found for type `char` in the current scope
|
||||||
--> $DIR/no-method-suggested-traits.rs:30:9
|
--> $DIR/no-method-suggested-traits.rs:30:9
|
||||||
|
|
|
@ -120,10 +120,10 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
help: try to construct one of the enum's variants
|
help: try to construct one of the enum's variants
|
||||||
|
|
|
|
||||||
LL | let x = A::TupleWithFields(3);
|
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | let x = A::Tuple(3);
|
LL | let x = A::Tuple(3);
|
||||||
| ~~~~~~~~
|
| ~~~~~~~~
|
||||||
|
LL | let x = A::TupleWithFields(3);
|
||||||
|
| ~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error[E0532]: expected tuple struct or tuple variant, found enum `A`
|
error[E0532]: expected tuple struct or tuple variant, found enum `A`
|
||||||
--> $DIR/issue-73427.rs:42:12
|
--> $DIR/issue-73427.rs:42:12
|
||||||
|
@ -145,10 +145,10 @@ LL | | }
|
||||||
| |_^
|
| |_^
|
||||||
help: try to match against one of the enum's variants
|
help: try to match against one of the enum's variants
|
||||||
|
|
|
|
||||||
LL | if let A::TupleWithFields(3) = x { }
|
|
||||||
| ~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | if let A::Tuple(3) = x { }
|
LL | if let A::Tuple(3) = x { }
|
||||||
| ~~~~~~~~
|
| ~~~~~~~~
|
||||||
|
LL | if let A::TupleWithFields(3) = x { }
|
||||||
|
| ~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ LL | #[rustc_on_unimplemented]
|
||||||
|
|
|
|
||||||
help: the following are the possible correct uses
|
help: the following are the possible correct uses
|
||||||
|
|
|
|
||||||
LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]
|
|
||||||
|
|
|
||||||
LL | #[rustc_on_unimplemented = "message"]
|
LL | #[rustc_on_unimplemented = "message"]
|
||||||
|
|
|
|
||||||
|
LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")]
|
||||||
|
|
|
||||||
|
|
||||||
error[E0230]: there is no parameter `C` on trait `BadAnnotation2`
|
error[E0230]: there is no parameter `C` on trait `BadAnnotation2`
|
||||||
--> $DIR/bad-annotation.rs:22:1
|
--> $DIR/bad-annotation.rs:22:1
|
||||||
|
|
|
@ -6,10 +6,10 @@ LL | let _x = NonZeroU32::new(5).unwrap();
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these items
|
||||||
|
|
|
|
||||||
LL | use std::num::NonZeroU32;
|
|
||||||
|
|
|
||||||
LL | use core::num::NonZeroU32;
|
LL | use core::num::NonZeroU32;
|
||||||
|
|
|
|
||||||
|
LL | use std::num::NonZeroU32;
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@ LL | opts.get(<String as AsRef<OsStr>>::as_ref(opt));
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
LL | opts.get(<String as AsRef<Path>>::as_ref(opt));
|
LL | opts.get(<String as AsRef<Path>>::as_ref(opt));
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
LL | opts.get(<String as AsRef<str>>::as_ref(opt));
|
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | opts.get(<String as AsRef<[u8]>>::as_ref(opt));
|
LL | opts.get(<String as AsRef<[u8]>>::as_ref(opt));
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | opts.get(<String as AsRef<str>>::as_ref(opt));
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error[E0283]: type annotations needed
|
error[E0283]: type annotations needed
|
||||||
--> $DIR/issue-77982.rs:13:44
|
--> $DIR/issue-77982.rs:13:44
|
||||||
|
|
|
@ -50,10 +50,10 @@ LL | let _ = a == b && c == 5 && a == b;
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL | let _ = a == b && c == 5;
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
LL | let _ = !(a != b || c != 5);
|
LL | let _ = !(a != b || c != 5);
|
||||||
| ~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | let _ = a == b && c == 5;
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: this boolean expression can be simplified
|
error: this boolean expression can be simplified
|
||||||
--> $DIR/nonminimal_bool.rs:28:13
|
--> $DIR/nonminimal_bool.rs:28:13
|
||||||
|
@ -63,10 +63,10 @@ LL | let _ = a == b || c == 5 || a == b;
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL | let _ = a == b || c == 5;
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
LL | let _ = !(a != b && c != 5);
|
LL | let _ = !(a != b && c != 5);
|
||||||
| ~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | let _ = a == b || c == 5;
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: this boolean expression can be simplified
|
error: this boolean expression can be simplified
|
||||||
--> $DIR/nonminimal_bool.rs:29:13
|
--> $DIR/nonminimal_bool.rs:29:13
|
||||||
|
@ -76,10 +76,10 @@ LL | let _ = a == b && c == 5 && b == a;
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL | let _ = a == b && c == 5;
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
LL | let _ = !(a != b || c != 5);
|
LL | let _ = !(a != b || c != 5);
|
||||||
| ~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | let _ = a == b && c == 5;
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: this boolean expression can be simplified
|
error: this boolean expression can be simplified
|
||||||
--> $DIR/nonminimal_bool.rs:30:13
|
--> $DIR/nonminimal_bool.rs:30:13
|
||||||
|
@ -89,10 +89,10 @@ LL | let _ = a != b || !(a != b || c == d);
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL | let _ = a != b || c != d;
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
LL | let _ = !(a == b && c == d);
|
LL | let _ = !(a == b && c == d);
|
||||||
| ~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | let _ = a != b || c != d;
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: this boolean expression can be simplified
|
error: this boolean expression can be simplified
|
||||||
--> $DIR/nonminimal_bool.rs:31:13
|
--> $DIR/nonminimal_bool.rs:31:13
|
||||||
|
@ -102,10 +102,10 @@ LL | let _ = a != b && !(a != b && c == d);
|
||||||
|
|
|
|
||||||
help: try
|
help: try
|
||||||
|
|
|
|
||||||
LL | let _ = a != b && c != d;
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
LL | let _ = !(a == b || c == d);
|
LL | let _ = !(a == b || c == d);
|
||||||
| ~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | let _ = a != b && c != d;
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 12 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue