Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize asm_goto feature gate #133870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,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
Expand Down
15 changes: 2 additions & 13 deletions compiler/rustc_ast_lowering/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,22 +478,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,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
32 changes: 0 additions & 32 deletions src/doc/unstable-book/src/language-features/asm-goto.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/codegen/asm/goto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/asm/x86_64/bad-options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ only-x86_64

#![feature(asm_unwind, asm_goto)]
#![feature(asm_unwind)]

use std::arch::{asm, global_asm};

Expand Down
1 change: 0 additions & 1 deletion tests/ui/asm/x86_64/goto-block-safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//@ needs-asm-support

#![deny(unreachable_code)]
#![feature(asm_goto)]

use std::arch::asm;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/asm/x86_64/goto-block-safe.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/asm/x86_64/goto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 0 additions & 10 deletions tests/ui/feature-gates/feature-gate-asm_goto.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/feature-gates/feature-gate-asm_goto.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ only-x86_64

#![feature(asm_goto)]

use std::arch::asm;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {});
| ^^^^^^^^
Expand Down
Loading