Skip to content

Commit

Permalink
Tweak duplicate attribute diagnostic (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-fairy committed Jul 29, 2018
1 parent 059ca8d commit ff5c0e7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions maud_macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ impl Parser {
}
if let Some(id) = ids.first() {
attr_map.insert("id".to_owned(), vec![ast::span_tokens(id.clone())]);
};
}

for attr in &attrs {
let span = ast::span_tokens(attr.name.clone());
Expand All @@ -581,14 +581,13 @@ impl Parser {
for (name, spans) in attr_map {
if spans.len() > 1 {
let mut spans = spans.into_iter();
if let Some(first_span) = spans.next() {
spans
.fold(
first_span.error(format!("duplicate attribute `{}` used here", name)),
|acc, span| acc.span_error(span, format!("duplicate attribute `{}` used here", name))
)
.emit();
}
let first_span = spans.next().expect("spans should be non-empty");
spans
.fold(
first_span.error(format!("duplicate attribute `{}`", name)),
|acc, span| acc.span_note(span, format!("`{}` is duplicated here", name)),
)
.emit();
}
}

Expand Down

0 comments on commit ff5c0e7

Please sign in to comment.