Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf72e47

Browse files
Make sure that labels are defined after the primary span in diagnostics
1 parentd819876 commitdf72e47

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ impl DiagnosticDeriveVariantBuilder {
269269
let field_binding =&binding_info.binding;
270270

271271
let inner_ty =FieldInnerTy::from_type(&field.ty);
272+
letmut seen_label =false;
272273

273274
field
274275
.attrs
@@ -280,6 +281,14 @@ impl DiagnosticDeriveVariantBuilder {
280281
}
281282

282283
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+
283292
let needs_clone =
284293
name =="primary_span" &&matches!(inner_ty,FieldInnerTy::Vec(_));
285294
let(binding, needs_destructure) =if needs_clone{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp