We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d819876 commit df72e47Copy full SHA for df72e47
compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs
@@ -269,6 +269,7 @@ impl DiagnosticDeriveVariantBuilder {
269
let field_binding = &binding_info.binding;
270
271
let inner_ty = FieldInnerTy::from_type(&field.ty);
272
+ let mut seen_label = false;
273
274
field
275
.attrs
@@ -280,6 +281,14 @@ impl DiagnosticDeriveVariantBuilder {
280
281
}
282
283
let name = attr.path().segments.last().unwrap().ident.to_string();
284
+
285
+ if name == "primary_span" && seen_label {
286
+ span_err(attr.span().unwrap(), format!("`#[primary_span]` must be placed before labels, since it overwrites the span of the diagnostic")).emit();
287
+ }
288
+ if name == "label" {
289
+ seen_label = true;
290
291
292
let needs_clone =
293
name == "primary_span" && matches!(inner_ty, FieldInnerTy::Vec(_));
294
let (binding, needs_destructure) = if needs_clone {
0 commit comments