Use span from parsed attribute
This commit is contained in:
parent
956f47c32f
commit
7a368c8abb
3 changed files with 13 additions and 13 deletions
|
|
@ -279,7 +279,7 @@ fn process_builtin_attrs(
|
|||
AttributeKind::StdInternalSymbol(_) => {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL
|
||||
}
|
||||
AttributeKind::Linkage(linkage, _) => {
|
||||
AttributeKind::Linkage(linkage, span) => {
|
||||
let linkage = Some(*linkage);
|
||||
|
||||
if tcx.is_foreign_item(did) {
|
||||
|
|
@ -287,7 +287,7 @@ fn process_builtin_attrs(
|
|||
|
||||
if tcx.is_mutable_static(did.into()) {
|
||||
let mut diag = tcx.dcx().struct_span_err(
|
||||
attr.span(),
|
||||
*span,
|
||||
"extern mutable statics are not allowed with `#[linkage]`",
|
||||
);
|
||||
diag.note(
|
||||
|
|
|
|||
|
|
@ -1315,8 +1315,6 @@ impl AttributeExt for Attribute {
|
|||
// FIXME: should not be needed anymore when all attrs are parsed
|
||||
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
|
||||
Attribute::Parsed(AttributeKind::Deprecation { span, .. }) => *span,
|
||||
Attribute::Parsed(AttributeKind::AllowInternalUnsafe(span)) => *span,
|
||||
Attribute::Parsed(AttributeKind::Linkage(_, span)) => *span,
|
||||
a => panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -310,15 +310,17 @@ impl EarlyLintPass for UnsafeCode {
|
|||
}
|
||||
|
||||
ast::ItemKind::MacroDef(..) => {
|
||||
if let Some(attr) = AttributeParser::parse_limited(
|
||||
cx.builder.sess(),
|
||||
&it.attrs,
|
||||
sym::allow_internal_unsafe,
|
||||
it.span,
|
||||
DUMMY_NODE_ID,
|
||||
Some(cx.builder.features()),
|
||||
) {
|
||||
self.report_unsafe(cx, attr.span(), BuiltinUnsafe::AllowInternalUnsafe);
|
||||
if let Some(hir::Attribute::Parsed(AttributeKind::AllowInternalUnsafe(span))) =
|
||||
AttributeParser::parse_limited(
|
||||
cx.builder.sess(),
|
||||
&it.attrs,
|
||||
sym::allow_internal_unsafe,
|
||||
it.span,
|
||||
DUMMY_NODE_ID,
|
||||
Some(cx.builder.features()),
|
||||
)
|
||||
{
|
||||
self.report_unsafe(cx, span, BuiltinUnsafe::AllowInternalUnsafe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue