diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index cfa97ff84ec..9f27ace25ab 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -49,6 +49,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { .struct_span_err(sp, "the `att_syntax` option is only supported on x86") .emit(); } + if asm.options.contains(InlineAsmOptions::MAY_UNWIND) + && !self.sess.features_untracked().asm_unwind + { + feature_err( + &self.sess.parse_sess, + sym::asm_unwind, + sp, + "the `may_unwind` option is unstable", + ) + .emit(); + } let mut clobber_abis = FxHashMap::default(); if let Some(asm_arch) = asm_arch { diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 7860f92f96f..640c4bba6da 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -290,6 +290,8 @@ declare_features! ( (active, asm_experimental_arch, "1.58.0", Some(72016), None), /// Allows using `sym` operands in inline assembly. (active, asm_sym, "1.58.0", Some(72016), None), + /// Allows the `may_unwind` option in inline assembly. + (active, asm_unwind, "1.58.0", Some(72016), None), /// Allows the user of associated type bounds. (active, associated_type_bounds, "1.34.0", Some(52662), None), /// Allows associated type defaults. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 5d16293c721..309c305293f 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -332,6 +332,7 @@ symbols! { asm_const, asm_experimental_arch, asm_sym, + asm_unwind, assert, assert_inhabited, assert_macro, diff --git a/src/test/ui/feature-gates/feature-gate-asm_unwind.rs b/src/test/ui/feature-gates/feature-gate-asm_unwind.rs new file mode 100644 index 00000000000..a7765bef293 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-asm_unwind.rs @@ -0,0 +1,8 @@ +#![feature(asm)] + +fn main() { + unsafe { + asm!("", options(may_unwind)); + //~^ ERROR the `may_unwind` option is unstable + } +} diff --git a/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr b/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr new file mode 100644 index 00000000000..67a5921a647 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-asm_unwind.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `may_unwind` option is unstable + --> $DIR/feature-gate-asm_unwind.rs:5:9 + | +LL | asm!("", options(may_unwind)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information + = help: add `#![feature(asm_unwind)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`.