about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-07-11 17:01:38 +0200
committerGitHub <noreply@github.com>2024-07-11 17:01:38 +0200
commit73c500b3a759b7fcb70633e091d7a152f797c3cd (patch)
tree77f87ba5530d7fd84043a68761b0d82b4f24adeb /compiler/rustc_codegen_gcc/src
parent380c78741e8cf990b0a7156f063e808409d1619f (diff)
parent12ae282987762a71cf146efa3fb6c6fcf4956475 (diff)
downloadrust-73c500b3a759b7fcb70633e091d7a152f797c3cd.tar.gz
rust-73c500b3a759b7fcb70633e091d7a152f797c3cd.zip
Rollup merge of #127591 - compiler-errors:label-after-primary, r=lcnr
Make sure that labels are defined after the primary span in diagnostics

Putting a `#[label]` before a `#[primary_span]` results in that label being overwritten, due to the semantics of `Diagnostic::span` and the fact that labels are stored in the `MultiSpan` of the diagnostic.

This isn't possible to fix in general, since a lot of code actually *relies* in this overwriting behavior (e.g. `rustc_on_unimplemented`). However, it's useful to enforce this for derive-diagnostics, since this is certainly never what you intend to do in a derived diagnostic, where all the fields are meaningful parts of the diagnostic being rendered.

This only matters for `#[label]`, since those are the ones stored in the `MultiSpan` of the error.

We could also make this "just work" by sorting the attrs or processing the primary span attr first, however I think it's kinda pointless to do.

There was 1 case where this mattered, but we literally didn't have a test exercising that diagnostic 🙃
Diffstat (limited to 'compiler/rustc_codegen_gcc/src')
0 files changed, 0 insertions, 0 deletions