Skip to content

Commit 3872263

Browse files
committed
dedup for duplicate suggestions
1 parent 46ecc10 commit 3872263

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,12 @@ impl Diagnostic {
622622
pub fn multipart_suggestion_with_style(
623623
&mut self,
624624
msg: impl Into<SubdiagnosticMessage>,
625-
suggestion: Vec<(Span, String)>,
625+
mut suggestion: Vec<(Span, String)>,
626626
applicability: Applicability,
627627
style: SuggestionStyle,
628628
) -> &mut Self {
629+
suggestion.dedup();
630+
629631
let mut parts = suggestion
630632
.into_iter()
631633
.map(|(span, snippet)| SubstitutionPart { snippet, span })

tests/ui/macros/issue-118048.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
macro_rules! foo {
2+
($ty:ty) => {
3+
fn foo(_: $ty, _: $ty) {}
4+
}
5+
}
6+
7+
foo!(_);
8+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
9+
10+
fn main() {}

tests/ui/macros/issue-118048.stderr

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
2+
--> $DIR/issue-118048.rs:7:6
3+
|
4+
LL | foo!(_);
5+
| ^
6+
| |
7+
| not allowed in type signatures
8+
| not allowed in type signatures
9+
|
10+
help: use type parameters instead
11+
|
12+
LL ~ fn foo<T>(_: $ty, _: $ty) {}
13+
LL | }
14+
LL | }
15+
LL |
16+
LL ~ foo!(T);
17+
|
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)