about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2024-12-02 21:20:12 +0000
committerGary Guo <gary@garyguo.net>2025-03-17 11:12:10 +0000
commit292c622507391dabd0434adcc6437edb193ac5be (patch)
tree923b42cef266861d764fd94948d0d0087367d5e1
parent9bad8ac498985707f29b0bdc0293cc0457a3ab38 (diff)
downloadrust-292c622507391dabd0434adcc6437edb193ac5be.tar.gz
rust-292c622507391dabd0434adcc6437edb193ac5be.zip
Stabilize asm_goto
-rw-r--r--compiler/rustc_ast_lowering/messages.ftl2
-rw-r--r--compiler/rustc_ast_lowering/src/asm.rs15
-rw-r--r--compiler/rustc_feature/src/accepted.rs2
-rw-r--r--compiler/rustc_feature/src/unstable.rs2
-rw-r--r--src/doc/unstable-book/src/language-features/asm-goto-with-outputs.md27
-rw-r--r--src/doc/unstable-book/src/language-features/asm-goto.md32
-rw-r--r--tests/codegen/asm/goto.rs2
-rw-r--r--tests/ui/asm/x86_64/bad-options.rs2
-rw-r--r--tests/ui/asm/x86_64/goto-block-safe.rs1
-rw-r--r--tests/ui/asm/x86_64/goto-block-safe.stderr2
-rw-r--r--tests/ui/asm/x86_64/goto.rs2
-rw-r--r--tests/ui/feature-gates/feature-gate-asm_goto.rs10
-rw-r--r--tests/ui/feature-gates/feature-gate-asm_goto.stderr13
-rw-r--r--tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs2
-rw-r--r--tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr2
15 files changed, 36 insertions, 80 deletions
diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl
index 906fb213ee7..65e5b530bbe 100644
--- a/compiler/rustc_ast_lowering/messages.ftl
+++ b/compiler/rustc_ast_lowering/messages.ftl
@@ -185,8 +185,6 @@ ast_lowering_underscore_expr_lhs_assign =
 ast_lowering_unstable_inline_assembly = inline assembly is not stable yet on this architecture
 ast_lowering_unstable_inline_assembly_label_operand_with_outputs =
     using both label and output operands for inline assembly is unstable
-ast_lowering_unstable_inline_assembly_label_operands =
-    label operands for inline assembly are unstable
 ast_lowering_unstable_may_unwind = the `may_unwind` option is unstable
 
 ast_lowering_use_angle_brackets = use angle brackets instead
diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs
index 65784af92c7..af279e07acc 100644
--- a/compiler/rustc_ast_lowering/src/asm.rs
+++ b/compiler/rustc_ast_lowering/src/asm.rs
@@ -470,22 +470,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
             }
         }
 
-        // Feature gate checking for asm goto.
+        // Feature gate checking for `asm_goto_with_outputs`.
         if let Some((_, op_sp)) =
             operands.iter().find(|(op, _)| matches!(op, hir::InlineAsmOperand::Label { .. }))
         {
-            if !self.tcx.features().asm_goto() {
-                feature_err(
-                    sess,
-                    sym::asm_goto,
-                    *op_sp,
-                    fluent::ast_lowering_unstable_inline_assembly_label_operands,
-                )
-                .emit();
-            }
-
-            // In addition, check if an output operand is used.
-            // This is gated behind an additional feature.
+            // Check if an output operand is used.
             let output_operand_used = operands.iter().any(|(op, _)| {
                 matches!(
                     op,
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index d50fe8c6a3e..980f3946035 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -62,6 +62,8 @@ declare_features! (
     (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)),
     /// Allows using `const` operands in inline assembly.
     (accepted, asm_const, "1.82.0", Some(93332)),
+    /// Allows using `label` operands in inline assembly.
+    (accepted, asm_goto, "CURRENT_RUSTC_VERSION", Some(119364)),
     /// Allows using `sym` operands in inline assembly.
     (accepted, asm_sym, "1.66.0", Some(93333)),
     /// Allows the definition of associated constants in `trait` or `impl` blocks.
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 3c61bfd1c93..3b75c69132c 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -372,8 +372,6 @@ declare_features! (
     (unstable, asm_experimental_arch, "1.58.0", Some(93335)),
     /// Enables experimental register support in inline assembly.
     (unstable, asm_experimental_reg, "1.85.0", Some(133416)),
-    /// Allows using `label` operands in inline assembly.
-    (unstable, asm_goto, "1.78.0", Some(119364)),
     /// Allows using `label` operands in inline assembly together with output operands.
     (unstable, asm_goto_with_outputs, "1.85.0", Some(119364)),
     /// Allows the `may_unwind` option in inline assembly.
diff --git a/src/doc/unstable-book/src/language-features/asm-goto-with-outputs.md b/src/doc/unstable-book/src/language-features/asm-goto-with-outputs.md
new file mode 100644
index 00000000000..3cce5d1d74c
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/asm-goto-with-outputs.md
@@ -0,0 +1,27 @@
+# `asm_goto_with_outputs`
+
+The tracking issue for this feature is: [#119364]
+
+[#119364]: https://github.com/rust-lang/rust/issues/119364
+
+------------------------
+
+This feature allows label operands to be used together with output operands.
+
+Example:
+```rust,ignore (partial-example, x86-only)
+
+unsafe {
+    let a: usize;
+    asm!(
+        "mov {}, 1"
+        "jmp {}",
+        out(reg) a,
+        label {
+            println!("Jumped from asm {}!", a);
+        }
+    );
+}
+```
+
+The output operands are assigned before the label blocks are executed.
diff --git a/src/doc/unstable-book/src/language-features/asm-goto.md b/src/doc/unstable-book/src/language-features/asm-goto.md
deleted file mode 100644
index 823118bcae1..00000000000
--- a/src/doc/unstable-book/src/language-features/asm-goto.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# `asm_goto`
-
-The tracking issue for this feature is: [#119364]
-
-[#119364]: https://github.com/rust-lang/rust/issues/119364
-
-------------------------
-
-This feature adds a `label <block>` operand type to `asm!`.
-
-Example:
-```rust,ignore (partial-example, x86-only)
-
-unsafe {
-    asm!(
-        "jmp {}",
-        label {
-            println!("Jumped from asm!");
-        }
-    );
-}
-```
-
-The block must have unit type or diverge. The block starts a new safety context,
-so despite outer `unsafe`, you need extra unsafe to perform unsafe operations
-within `label <block>`.
-
-When `label <block>` is used together with `noreturn` option, it means that the
-assembly will not fallthrough. It's allowed to jump to a label within the
-assembly. In this case, the entire `asm!` expression will have an unit type as
-opposed to diverging, if not all label blocks diverge. The `asm!` expression
-still diverges if `noreturn` option is used and all label blocks diverge.
diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs
index 7a87bb7983b..f68c399c920 100644
--- a/tests/codegen/asm/goto.rs
+++ b/tests/codegen/asm/goto.rs
@@ -2,7 +2,7 @@
 //@ only-x86_64
 
 #![crate_type = "rlib"]
-#![feature(asm_goto, asm_goto_with_outputs)]
+#![feature(asm_goto_with_outputs)]
 
 use std::arch::asm;
 
diff --git a/tests/ui/asm/x86_64/bad-options.rs b/tests/ui/asm/x86_64/bad-options.rs
index 6424a1b1d42..123febc06fc 100644
--- a/tests/ui/asm/x86_64/bad-options.rs
+++ b/tests/ui/asm/x86_64/bad-options.rs
@@ -1,6 +1,6 @@
 //@ only-x86_64
 
-#![feature(asm_unwind, asm_goto)]
+#![feature(asm_unwind)]
 
 use std::arch::{asm, global_asm};
 
diff --git a/tests/ui/asm/x86_64/goto-block-safe.rs b/tests/ui/asm/x86_64/goto-block-safe.rs
index ee833a48a4b..b739e9f9ced 100644
--- a/tests/ui/asm/x86_64/goto-block-safe.rs
+++ b/tests/ui/asm/x86_64/goto-block-safe.rs
@@ -2,7 +2,6 @@
 //@ needs-asm-support
 
 #![deny(unreachable_code)]
-#![feature(asm_goto)]
 
 use std::arch::asm;
 
diff --git a/tests/ui/asm/x86_64/goto-block-safe.stderr b/tests/ui/asm/x86_64/goto-block-safe.stderr
index 49818db7484..ee7313bc8be 100644
--- a/tests/ui/asm/x86_64/goto-block-safe.stderr
+++ b/tests/ui/asm/x86_64/goto-block-safe.stderr
@@ -1,5 +1,5 @@
 error[E0133]: call to unsafe function `unreachable_unchecked` is unsafe and requires unsafe function or block
-  --> $DIR/goto-block-safe.rs:14:17
+  --> $DIR/goto-block-safe.rs:13:17
    |
 LL |     unsafe {
    |     ------ items do not inherit unsafety from separate enclosing items
diff --git a/tests/ui/asm/x86_64/goto.rs b/tests/ui/asm/x86_64/goto.rs
index 50e7441509a..00a8e588f96 100644
--- a/tests/ui/asm/x86_64/goto.rs
+++ b/tests/ui/asm/x86_64/goto.rs
@@ -3,7 +3,7 @@
 //@ needs-asm-support
 
 #![deny(unreachable_code)]
-#![feature(asm_goto, asm_goto_with_outputs)]
+#![feature(asm_goto_with_outputs)]
 
 use std::arch::asm;
 
diff --git a/tests/ui/feature-gates/feature-gate-asm_goto.rs b/tests/ui/feature-gates/feature-gate-asm_goto.rs
deleted file mode 100644
index beac4590349..00000000000
--- a/tests/ui/feature-gates/feature-gate-asm_goto.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//@ only-x86_64
-
-use std::arch::asm;
-
-fn main() {
-    unsafe {
-        asm!("jmp {}", label {});
-        //~^ ERROR label operands for inline assembly are unstable
-    }
-}
diff --git a/tests/ui/feature-gates/feature-gate-asm_goto.stderr b/tests/ui/feature-gates/feature-gate-asm_goto.stderr
deleted file mode 100644
index 62fd1a320d3..00000000000
--- a/tests/ui/feature-gates/feature-gate-asm_goto.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0658]: label operands for inline assembly are unstable
-  --> $DIR/feature-gate-asm_goto.rs:7:24
-   |
-LL |         asm!("jmp {}", label {});
-   |                        ^^^^^^^^
-   |
-   = note: see issue #119364 <https://github.com/rust-lang/rust/issues/119364> for more information
-   = help: add `#![feature(asm_goto)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
index 294827f78d2..26b7d5d2fbf 100644
--- a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
+++ b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
@@ -1,7 +1,5 @@
 //@ only-x86_64
 
-#![feature(asm_goto)]
-
 use std::arch::asm;
 
 fn main() {
diff --git a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr
index ff7a7d5760a..06e11301565 100644
--- a/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr
+++ b/tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.stderr
@@ -1,5 +1,5 @@
 error[E0658]: using both label and output operands for inline assembly is unstable
-  --> $DIR/feature-gate-asm_goto_with_outputs.rs:10:52
+  --> $DIR/feature-gate-asm_goto_with_outputs.rs:8:52
    |
 LL |         asm!("mov {}, 1", "jmp {}", out(reg) _out, label {});
    |                                                    ^^^^^^^^