]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_ast_passes/src/feature_gate.rs
Rollup merge of #94731 - TaKO8Ki:const-generic-expr-recovery, r=davidtwco,oli-obk
[rust.git] / compiler / rustc_ast_passes / src / feature_gate.rs
index 6c44fb0df236377baef7a736a6425b12f87f4eef..5b6147c72230d53b943586280b3a6d457d103886 100644 (file)
@@ -252,11 +252,12 @@ fn check_abi(&self, abi: ast::StrLit) {
                     "wasm ABI is experimental and subject to change"
                 );
             }
-            abi => self
-                .sess
-                .parse_sess
-                .span_diagnostic
-                .delay_span_bug(span, &format!("unrecognized ABI not caught in lowering: {}", abi)),
+            abi => {
+                self.sess.parse_sess.span_diagnostic.delay_span_bug(
+                    span,
+                    &format!("unrecognized ABI not caught in lowering: {}", abi),
+                );
+            }
         }
     }
 
@@ -420,6 +421,24 @@ macro_rules! gate_modifier { ($($name:literal => $feature:ident)*) => {
                 }
             }
         }
+
+        // Emit errors for non-staged-api crates.
+        if !self.features.staged_api {
+            if attr.has_name(sym::rustc_deprecated)
+                || attr.has_name(sym::unstable)
+                || attr.has_name(sym::stable)
+                || attr.has_name(sym::rustc_const_unstable)
+                || attr.has_name(sym::rustc_const_stable)
+            {
+                struct_span_err!(
+                    self.sess,
+                    attr.span,
+                    E0734,
+                    "stability attributes may not be used outside of the standard library",
+                )
+                .emit();
+            }
+        }
     }
 
     fn visit_item(&mut self, i: &'a ast::Item) {