Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obk
Port `#[target_feature]` to new attribute parsing infrastructure Ports `target_feature` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 r? ``@jdonszelmann``
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use rustc_attr_data_structures::{AttributeKind, find_attr};
|
||||
use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect};
|
||||
use rustc_errors::{Diag, MultiSpan, pluralize};
|
||||
use rustc_hir as hir;
|
||||
@@ -8,7 +9,7 @@ use rustc_middle::ty::fast_reject::DeepRejectCtxt;
|
||||
use rustc_middle::ty::print::{FmtPrinter, Printer};
|
||||
use rustc_middle::ty::{self, Ty, suggest_constraining_type_param};
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::{BytePos, Span, Symbol, sym};
|
||||
use rustc_span::{BytePos, Span, Symbol};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::error_reporting::TypeErrCtxt;
|
||||
@@ -535,8 +536,7 @@ impl<T> Trait<T> for X {
|
||||
}
|
||||
}
|
||||
TypeError::TargetFeatureCast(def_id) => {
|
||||
let target_spans =
|
||||
tcx.get_attrs(def_id, sym::target_feature).map(|attr| attr.span());
|
||||
let target_spans = find_attr!(tcx.get_all_attrs(def_id), AttributeKind::TargetFeature(.., span) => *span);
|
||||
diag.note(
|
||||
"functions with `#[target_feature]` can only be coerced to `unsafe` function pointers"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user