dedup for duplicate suggestions
This commit is contained in:
parent
c9808f8702
commit
199098b71b
@ -622,17 +622,18 @@ pub fn multipart_suggestion_verbose(
|
|||||||
pub fn multipart_suggestion_with_style(
|
pub fn multipart_suggestion_with_style(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: impl Into<SubdiagnosticMessage>,
|
msg: impl Into<SubdiagnosticMessage>,
|
||||||
suggestion: Vec<(Span, String)>,
|
mut suggestion: Vec<(Span, String)>,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
style: SuggestionStyle,
|
style: SuggestionStyle,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
let mut parts = suggestion
|
suggestion.sort_unstable();
|
||||||
|
suggestion.dedup();
|
||||||
|
|
||||||
|
let parts = suggestion
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(span, snippet)| SubstitutionPart { snippet, span })
|
.map(|(span, snippet)| SubstitutionPart { snippet, span })
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
parts.sort_unstable_by_key(|part| part.span);
|
|
||||||
|
|
||||||
assert!(!parts.is_empty());
|
assert!(!parts.is_empty());
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
parts.iter().find(|part| part.span.is_empty() && part.snippet.is_empty()),
|
parts.iter().find(|part| part.span.is_empty() && part.snippet.is_empty()),
|
||||||
|
10
tests/ui/macros/issue-118048.rs
Normal file
10
tests/ui/macros/issue-118048.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
macro_rules! foo {
|
||||||
|
($ty:ty) => {
|
||||||
|
fn foo(_: $ty, _: $ty) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foo!(_);
|
||||||
|
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
|
||||||
|
|
||||||
|
fn main() {}
|
21
tests/ui/macros/issue-118048.stderr
Normal file
21
tests/ui/macros/issue-118048.stderr
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
|
||||||
|
--> $DIR/issue-118048.rs:7:6
|
||||||
|
|
|
||||||
|
LL | foo!(_);
|
||||||
|
| ^
|
||||||
|
| |
|
||||||
|
| not allowed in type signatures
|
||||||
|
| not allowed in type signatures
|
||||||
|
|
|
||||||
|
help: use type parameters instead
|
||||||
|
|
|
||||||
|
LL ~ fn foo<T>(_: $ty, _: $ty) {}
|
||||||
|
LL | }
|
||||||
|
LL | }
|
||||||
|
LL |
|
||||||
|
LL ~ foo!(T);
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0121`.
|
Loading…
Reference in New Issue
Block a user