Skip to content

Commit

Permalink
add unwind_asm feature gate for may_unwind option
Browse files Browse the repository at this point in the history
  • Loading branch information
cynecx committed Dec 3, 2021
1 parent 059d3b3 commit 686ace3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compiler/rustc_ast_lowering/src/asm.rs
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/active.rs
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Expand Up @@ -332,6 +332,7 @@ symbols! {
asm_const,
asm_experimental_arch,
asm_sym,
asm_unwind,
assert,
assert_inhabited,
assert_macro,
Expand Down
8 changes: 8 additions & 0 deletions 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
}
}
12 changes: 12 additions & 0 deletions 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`.

0 comments on commit 686ace3

Please sign in to comment.