Skip to content

Commit 686ace3

Browse files
committed
add unwind_asm feature gate for may_unwind option
1 parent 059d3b3 commit 686ace3

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
4949
.struct_span_err(sp, "the `att_syntax` option is only supported on x86")
5050
.emit();
5151
}
52+
if asm.options.contains(InlineAsmOptions::MAY_UNWIND)
53+
&& !self.sess.features_untracked().asm_unwind
54+
{
55+
feature_err(
56+
&self.sess.parse_sess,
57+
sym::asm_unwind,
58+
sp,
59+
"the `may_unwind` option is unstable",
60+
)
61+
.emit();
62+
}
5263

5364
let mut clobber_abis = FxHashMap::default();
5465
if let Some(asm_arch) = asm_arch {

compiler/rustc_feature/src/active.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ declare_features! (
290290
(active, asm_experimental_arch, "1.58.0", Some(72016), None),
291291
/// Allows using `sym` operands in inline assembly.
292292
(active, asm_sym, "1.58.0", Some(72016), None),
293+
/// Allows the `may_unwind` option in inline assembly.
294+
(active, asm_unwind, "1.58.0", Some(72016), None),
293295
/// Allows the user of associated type bounds.
294296
(active, associated_type_bounds, "1.34.0", Some(52662), None),
295297
/// Allows associated type defaults.

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ symbols! {
332332
asm_const,
333333
asm_experimental_arch,
334334
asm_sym,
335+
asm_unwind,
335336
assert,
336337
assert_inhabited,
337338
assert_macro,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(asm)]
2+
3+
fn main() {
4+
unsafe {
5+
asm!("", options(may_unwind));
6+
//~^ ERROR the `may_unwind` option is unstable
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0658]: the `may_unwind` option is unstable
2+
--> $DIR/feature-gate-asm_unwind.rs:5:9
3+
|
4+
LL | asm!("", options(may_unwind));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #72016 <https://github.com/rust-lang/rust/issues/72016> for more information
8+
= help: add `#![feature(asm_unwind)]` to the crate attributes to enable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)