diff options
| author | bors <bors@rust-lang.org> | 2025-01-22 14:46:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-01-22 14:46:41 +0000 |
| commit | dee7d0e730a3a3ed98c89dd33c4ac16edc82de8a (patch) | |
| tree | 3d6e80304bba9a0899e5ecb00f8a378c72514c68 /compiler/rustc_parse/src/validate_attr.rs | |
| parent | b2728d5426bab1d8c39709768c7e22b7f66dde5d (diff) | |
| parent | 2de21ad7d4a14894463816ac5dedc337ae3a2941 (diff) | |
| download | rust-dee7d0e730a3a3ed98c89dd33c4ac16edc82de8a.tar.gz rust-dee7d0e730a3a3ed98c89dd33c4ac16edc82de8a.zip | |
Auto merge of #134478 - compiler-errors:attr-span, r=oli-obk
Properly record metavar spans for other expansions other than TT This properly records metavar spans for nonterminals other than tokentree. This means that we operations like `span.to(other_span)` work correctly for macros. As you can see, other diagnostics involving metavars have improved as a result. Fixes #132908 Alternative to #133270 cc `@ehuss` cc `@petrochenkov`
Diffstat (limited to 'compiler/rustc_parse/src/validate_attr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/validate_attr.rs | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 8b6b37c0f8f..86f673c100c 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -11,7 +11,7 @@ use rustc_session::errors::report_lit_error; use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::builtin::{ILL_FORMED_ATTRIBUTE_INPUT, UNSAFE_ATTR_OUTSIDE_UNSAFE}; use rustc_session::parse::ParseSess; -use rustc_span::{BytePos, Span, Symbol, sym}; +use rustc_span::{Span, Symbol, sym}; use crate::{errors, parse_in}; @@ -164,11 +164,7 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr: // wrapping it in `unsafe(...)`. Otherwise, we suggest putting the // `unsafe(`, `)` right after and right before the opening and closing // square bracket respectively. - let diag_span = if attr_item.span().can_be_used_for_suggestions() { - attr_item.span() - } else { - attr.span.with_lo(attr.span.lo() + BytePos(2)).with_hi(attr.span.hi() - BytePos(1)) - }; + let diag_span = attr_item.span(); if attr.span.at_least_rust_2024() { psess.dcx().emit_err(errors::UnsafeAttrOutsideUnsafe { |
