Skip to content

Commit

Permalink
Unrolled build for rust-lang#118057
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#118057 - bvanjoi:fix-118048, r=cjgillot

dedup for duplicate suggestions

Fixes rust-lang#118048

An easy fix.
  • Loading branch information
rust-timer committed Dec 9, 2023
2 parents 1dfb228 + 199098b commit afc5928
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,18 @@ impl Diagnostic {
pub fn multipart_suggestion_with_style(
&mut self,
msg: impl Into<SubdiagnosticMessage>,
suggestion: Vec<(Span, String)>,
mut suggestion: Vec<(Span, String)>,
applicability: Applicability,
style: SuggestionStyle,
) -> &mut Self {
let mut parts = suggestion
suggestion.sort_unstable();
suggestion.dedup();

let parts = suggestion
.into_iter()
.map(|(span, snippet)| SubstitutionPart { snippet, span })
.collect::<Vec<_>>();

parts.sort_unstable_by_key(|part| part.span);

assert!(!parts.is_empty());
debug_assert_eq!(
parts.iter().find(|part| part.span.is_empty() && part.snippet.is_empty()),
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/macros/issue-118048.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions tests/ui/macros/issue-118048.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit afc5928

Please sign in to comment.