]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_passes/src/check_attr.rs
Auto merge of #99983 - RalfJung:more-layout-checks, r=eddyb
[rust.git] / compiler / rustc_passes / src / check_attr.rs
index 2b213ac5c71f0b76f51514a9fe8c16382dbea332..6fea68ce8b3d1e1bf128b350f6b4e799a5d3772d 100644 (file)
@@ -146,6 +146,7 @@ fn check_attributes(
                 | 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;
@@ -1893,6 +1894,16 @@ fn check_stability_promotable(&self, attr: &Attribute, _span: Span, target: Targ
         }
     }
 
+    fn check_link_ordinal(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
+        match target {
+            Target::ForeignFn | Target::ForeignStatic => 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 => {