mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
Make asm_goto_with_outputs a separate feature gate
This commit is contained in:
parent
73f8309300
commit
0178ba2c25
@ -181,6 +181,8 @@ ast_lowering_underscore_expr_lhs_assign =
|
||||
.label = `_` not allowed here
|
||||
|
||||
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
|
||||
|
@ -239,15 +239,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
InlineAsmOperand::Label { block } => {
|
||||
if !self.tcx.features().asm_goto() {
|
||||
feature_err(
|
||||
sess,
|
||||
sym::asm_goto,
|
||||
*op_sp,
|
||||
fluent::ast_lowering_unstable_inline_assembly_label_operands,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
hir::InlineAsmOperand::Label { block: self.lower_block(block, false) }
|
||||
}
|
||||
};
|
||||
@ -466,6 +457,41 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
// Feature gate checking for asm goto.
|
||||
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.
|
||||
let output_operand_used = operands.iter().any(|(op, _)| {
|
||||
matches!(
|
||||
op,
|
||||
hir::InlineAsmOperand::Out { expr: Some(_), .. }
|
||||
| hir::InlineAsmOperand::InOut { .. }
|
||||
| hir::InlineAsmOperand::SplitInOut { out_expr: Some(_), .. }
|
||||
)
|
||||
});
|
||||
if output_operand_used && !self.tcx.features().asm_goto_with_outputs() {
|
||||
feature_err(
|
||||
sess,
|
||||
sym::asm_goto_with_outputs,
|
||||
*op_sp,
|
||||
fluent::ast_lowering_unstable_inline_assembly_label_operand_with_outputs,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
let operands = self.arena.alloc_from_iter(operands);
|
||||
let template = self.arena.alloc_from_iter(asm.template.iter().cloned());
|
||||
let template_strs = self.arena.alloc_from_iter(
|
||||
|
@ -378,6 +378,8 @@ declare_features! (
|
||||
(unstable, asm_experimental_arch, "1.58.0", Some(93335)),
|
||||
/// 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, "CURRENT_RUSTC_VERSION", Some(119364)),
|
||||
/// Allows the `may_unwind` option in inline assembly.
|
||||
(unstable, asm_unwind, "1.58.0", Some(93334)),
|
||||
/// Allows users to enforce equality of associated constants `TraitImpl<AssocConst=3>`.
|
||||
|
@ -417,6 +417,7 @@ symbols! {
|
||||
asm_const,
|
||||
asm_experimental_arch,
|
||||
asm_goto,
|
||||
asm_goto_with_outputs,
|
||||
asm_sym,
|
||||
asm_unwind,
|
||||
assert,
|
||||
|
@ -2,7 +2,7 @@
|
||||
//@ only-x86_64
|
||||
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(asm_goto)]
|
||||
#![feature(asm_goto, asm_goto_with_outputs)]
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
//@ needs-asm-support
|
||||
|
||||
#![deny(unreachable_code)]
|
||||
#![feature(asm_goto)]
|
||||
#![feature(asm_goto, asm_goto_with_outputs)]
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
|
13
tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
Normal file
13
tests/ui/feature-gates/feature-gate-asm_goto_with_outputs.rs
Normal file
@ -0,0 +1,13 @@
|
||||
//@ only-x86_64
|
||||
|
||||
#![feature(asm_goto)]
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
fn main() {
|
||||
let mut _out: u64;
|
||||
unsafe {
|
||||
asm!("mov {}, 1", "jmp {}", out(reg) _out, label {});
|
||||
//~^ ERROR using both label and output operands for inline assembly is unstable
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
error[E0658]: using both label and output operands for inline assembly is unstable
|
||||
--> $DIR/feature-gate-asm_goto_with_outputs.rs:10:52
|
||||
|
|
||||
LL | asm!("mov {}, 1", "jmp {}", out(reg) _out, label {});
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: see issue #119364 <https://github.com/rust-lang/rust/issues/119364> for more information
|
||||
= help: add `#![feature(asm_goto_with_outputs)]` 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`.
|
Loading…
Reference in New Issue
Block a user