check link ordinal make sure target is foreign function
This commit is contained in:
parent
792bc5a010
commit
0d1b832667
5 changed files with 64 additions and 0 deletions
|
@ -146,6 +146,9 @@ impl CheckAttrVisitor<'_> {
|
|||
| sym::stable
|
||||
| sym::rustc_allowed_through_unstable_modules
|
||||
| sym::rustc_promotable => self.check_stability_promotable(&attr, span, target),
|
||||
sym::link_ordinal => {
|
||||
self.check_link_ordinal(&attr, span, target)
|
||||
},
|
||||
_ => true,
|
||||
};
|
||||
is_valid &= attr_is_valid;
|
||||
|
@ -1861,6 +1864,16 @@ impl CheckAttrVisitor<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_link_ordinal(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
|
||||
match target {
|
||||
Target::ForeignFn => true,
|
||||
_ => {
|
||||
self.tcx.sess.emit_err(errors::LinkOrdinal { attr_span: attr.span });
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_deprecated(&self, hir_id: HirId, attr: &Attribute, _span: Span, target: Target) {
|
||||
match target {
|
||||
Target::Closure | Target::Expression | Target::Statement | Target::Arm => {
|
||||
|
|
|
@ -551,6 +551,13 @@ pub struct ConstTrait {
|
|||
pub attr_span: Span,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(passes::link_ordinal)]
|
||||
pub struct LinkOrdinal {
|
||||
#[primary_span]
|
||||
pub attr_span: Span
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(passes::stability_promotable)]
|
||||
pub struct StabilityPromotable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue