Skip to content

Commit 2f4da62

Browse files
committed
Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
Stabilize asm! and global_asm! Tracking issue: #72016 It's been almost 2 years since the original [RFC](rust-lang/rfcs#2850) was posted and we're finally ready to stabilize this feature! The main changes in this PR are: - Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228. - Stabilizing the `asm` and `global_asm` features. - Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](rust-lang/reference#1105) and [rust by example](rust-lang/rust-by-example#1483). - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example. - Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`. - Updating `stdarch` and `compiler-builtins`. - Updating all the tests. r? `@joshtriplett`
2 parents 404c847 + d6f4da9 commit 2f4da62

File tree

141 files changed

+753
-1915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+753
-1915
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,9 @@ dependencies = [
680680

681681
[[package]]
682682
name = "compiler_builtins"
683-
version = "0.1.55"
683+
version = "0.1.65"
684684
source = "registry+https://github.com/rust-lang/crates.io-index"
685-
checksum = "c9ac60765140c97aaf531dae151a287646b0805ec725805da9e2a3ee31cd501c"
685+
checksum = "ed37ea958309f2451e1cea7fd2b37aa56b1894c9a9fbdbbe6a194f7b78f0362d"
686686
dependencies = [
687687
"cc",
688688
"rustc-std-workspace-core",

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,6 @@ fn parse_args<'a>(
4242
ecx.struct_span_err(sp, "the legacy LLVM-style asm! syntax is no longer supported");
4343
err.note("consider migrating to the new asm! syntax specified in RFC 2873");
4444
err.note("alternatively, switch to llvm_asm! to keep your code working as it is");
45-
46-
// Find the span of the "asm!" so that we can offer an automatic suggestion
47-
let asm_span = sp.from_inner(InnerSpan::new(0, 4));
48-
if let Ok(s) = ecx.source_map().span_to_snippet(asm_span) {
49-
if s == "asm!" {
50-
err.span_suggestion(
51-
asm_span,
52-
"replace with",
53-
"llvm_asm!".into(),
54-
Applicability::MachineApplicable,
55-
);
56-
}
57-
}
5845
return Err(err);
5946
}
6047

compiler/rustc_codegen_cranelift/src/inline_asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Codegen of [`asm!`] invocations.
1+
//! Codegen of `asm!` invocations.
22
33
use crate::prelude::*;
44

compiler/rustc_codegen_gcc/tests/run/asm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Run-time:
44
// status: 0
55

6-
#![feature(asm, global_asm)]
7-
86
global_asm!("
97
.global add_asm
108
add_asm:

compiler/rustc_hir/src/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub enum DefKind {
113113
Field,
114114
/// Lifetime parameter: the `'a` in `struct Foo<'a> { ... }`
115115
LifetimeParam,
116-
/// A use of [`global_asm!`].
116+
/// A use of `global_asm!`.
117117
GlobalAsm,
118118
Impl,
119119
Closure,

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,7 +3147,8 @@ declare_lint! {
31473147
/// ### Example
31483148
///
31493149
/// ```rust,compile_fail
3150-
/// #![feature(asm)]
3150+
/// use std::arch::asm;
3151+
///
31513152
/// fn main() {
31523153
/// unsafe {
31533154
/// asm!("foo: bar");
@@ -3164,10 +3165,7 @@ declare_lint! {
31643165
/// of this, GNU assembler [local labels] *must* be used instead of labels
31653166
/// with a name. Using named labels might cause assembler or linker errors.
31663167
///
3167-
/// See the [unstable book] for more details.
3168-
///
31693168
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
3170-
/// [unstable book]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels
31713169
pub NAMED_ASM_LABELS,
31723170
Deny,
31733171
"named labels in inline assembly",

compiler/rustc_lint/src/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ pub trait LintContext: Sized {
772772
}
773773
BuiltinLintDiagnostics::NamedAsmLabel(help) => {
774774
db.help(&help);
775-
db.note("see the asm section of the unstable book <https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#labels> for more information");
776775
}
777776
}
778777
// Rewrap `db`, and pass control to the user.

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,8 +2419,9 @@ declare_lint! {
24192419
///
24202420
/// ### Example
24212421
///
2422-
/// ```rust,ignore (fails on system llvm)
2423-
/// #![feature(asm)]
2422+
/// ```rust,ignore (fails on non-x86_64)
2423+
/// #[cfg(target_arch="x86_64")]
2424+
/// use std::arch::asm;
24242425
///
24252426
/// fn main() {
24262427
/// #[cfg(target_arch="x86_64")]
@@ -2430,19 +2431,7 @@ declare_lint! {
24302431
/// }
24312432
/// ```
24322433
///
2433-
/// This will produce:
2434-
///
2435-
/// ```text
2436-
/// warning: formatting may not be suitable for sub-register argument
2437-
/// --> src/main.rs:6:19
2438-
/// |
2439-
/// 6 | asm!("mov {0}, {0}", in(reg) 0i16);
2440-
/// | ^^^ ^^^ ---- for this argument
2441-
/// |
2442-
/// = note: `#[warn(asm_sub_register)]` on by default
2443-
/// = help: use the `x` modifier to have the register formatted as `ax`
2444-
/// = help: or use the `r` modifier to keep the default formatting of `rax`
2445-
/// ```
2434+
/// {{produces}}
24462435
///
24472436
/// ### Explanation
24482437
///
@@ -2455,10 +2444,6 @@ declare_lint! {
24552444
/// register size, to alert you of possibly using the incorrect width. To
24562445
/// fix this, add the suggested modifier to the template, or cast the
24572446
/// value to the correct size.
2458-
///
2459-
/// See [register template modifiers] for more details.
2460-
///
2461-
/// [register template modifiers]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#register-template-modifiers
24622447
pub ASM_SUB_REGISTER,
24632448
Warn,
24642449
"using only a subset of a register for inline asm inputs",
@@ -2470,34 +2455,22 @@ declare_lint! {
24702455
///
24712456
/// ### Example
24722457
///
2473-
/// ```rust,ignore (fails on system llvm)
2474-
/// #![feature(asm)]
2458+
/// ```rust,ignore (fails on non-x86_64)
2459+
/// #[cfg(target_arch="x86_64")]
2460+
/// use std::arch::asm;
24752461
///
24762462
/// fn main() {
24772463
/// #[cfg(target_arch="x86_64")]
24782464
/// unsafe {
24792465
/// asm!(
24802466
/// ".att_syntax",
2481-
/// "movl {0}, {0}", in(reg) 0usize
2467+
/// "movq %{0}, %{0}", in(reg) 0usize
24822468
/// );
24832469
/// }
24842470
/// }
24852471
/// ```
24862472
///
2487-
/// This will produce:
2488-
///
2489-
/// ```text
2490-
/// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
2491-
/// --> test.rs:7:14
2492-
/// |
2493-
/// 7 | ".att_syntax",
2494-
/// | ^^^^^^^^^^^
2495-
/// 8 | "movq {0}, {0}", out(reg) _,
2496-
/// 9 | );
2497-
/// | - help: add option: `, options(att_syntax)`
2498-
/// |
2499-
/// = note: `#[warn(bad_asm_style)]` on by default
2500-
/// ```
2473+
/// {{produces}}
25012474
///
25022475
/// ### Explanation
25032476
///
@@ -2739,7 +2712,8 @@ declare_lint! {
27392712
///
27402713
/// ```rust
27412714
/// #![feature(naked_functions)]
2742-
/// #![feature(asm)]
2715+
///
2716+
/// use std::arch::asm;
27432717
///
27442718
/// #[naked]
27452719
/// pub fn default_abi() -> u32 {

library/core/src/lib.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
#![feature(abi_unadjusted)]
154154
#![feature(allow_internal_unsafe)]
155155
#![feature(allow_internal_unstable)]
156-
#![feature(asm)]
157156
#![feature(associated_type_bounds)]
158157
#![feature(auto_traits)]
159158
#![feature(cfg_target_has_atomic)]
@@ -373,26 +372,14 @@ pub mod arch {
373372
pub use crate::core_arch::arch::*;
374373

375374
/// Inline assembly.
376-
///
377-
/// Read the [unstable book] for the usage.
378-
///
379-
/// [unstable book]: ../../unstable-book/library-features/asm.html
380-
#[unstable(
381-
feature = "asm",
382-
issue = "72016",
383-
reason = "inline assembly is not stable enough for use and is subject to change"
384-
)]
375+
#[stable(feature = "asm", since = "1.59.0")]
385376
#[rustc_builtin_macro]
386377
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
387378
/* compiler built-in */
388379
}
389380
390381
/// Module-level inline assembly.
391-
#[unstable(
392-
feature = "global_asm",
393-
issue = "35119",
394-
reason = "`global_asm!` is not stable enough for use and is subject to change"
395-
)]
382+
#[stable(feature = "global_asm", since = "1.59.0")]
396383
#[rustc_builtin_macro]
397384
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
398385
/* compiler built-in */

library/core/src/num/dec2flt/fpu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub use fpu_precision::set_precision;
1010
// computations are performed in the desired precision.
1111
#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
1212
mod fpu_precision {
13+
use core::arch::asm;
1314
use core::mem::size_of;
1415

1516
/// A structure used to preserve the original value of the FPU control word, so that it can be

0 commit comments

Comments
 (0)