Skip to content

Commit ce83b49

Browse files
committed
Deprecate the asm! macro
1 parent c4ca638 commit ce83b49

File tree

8 files changed

+32
-7
lines changed

8 files changed

+32
-7
lines changed

src/libcore/macros/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,13 @@ pub(crate) mod builtin {
13161316
issue = "70173",
13171317
reason = "inline assembly is not stable enough for use and is subject to change"
13181318
)]
1319-
#[rustc_deprecated(
1320-
since = "1.44.0",
1321-
reason = "the syntax of asm! will change soon, use llvm_asm! to avoid breakage"
1319+
#[cfg_attr(
1320+
not(bootstrap),
1321+
rustc_deprecated(
1322+
since = "1.44.0",
1323+
reason = "the syntax of asm! will change soon, use llvm_asm! to avoid breakage",
1324+
suggestion = "llvm_asm",
1325+
)
13221326
)]
13231327
#[rustc_builtin_macro]
13241328
#[macro_export]

src/libcore/prelude/v1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub use crate::fmt::macros::Debug;
5454
pub use crate::hash::macros::Hash;
5555

5656
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
57+
#[allow(deprecated)]
5758
#[doc(no_inline)]
5859
pub use crate::{
5960
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ pub use core::{
523523

524524
// Re-export built-in macros defined through libcore.
525525
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
526+
#[allow(deprecated)]
526527
pub use core::{
527528
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
528529
format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,

src/libstd/prelude/v1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub use crate::result::Result::{self, Err, Ok};
3636

3737
// Re-exported built-in macros
3838
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
39+
#[allow(deprecated)]
3940
#[doc(no_inline)]
4041
pub use core::prelude::v1::{
4142
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,

src/test/ui/feature-gates/feature-gate-asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
fn main() {
44
unsafe {
55
asm!(""); //~ ERROR inline assembly is not stable enough
6+
//~^ WARN use of deprecated item 'asm'
67
llvm_asm!(""); //~ ERROR inline assembly is not stable enough
78
}
89
}

src/test/ui/feature-gates/feature-gate-asm.stderr

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ LL | asm!("");
88
= help: add `#![feature(asm)]` to the crate attributes to enable
99

1010
error[E0658]: use of unstable library feature 'llvm_asm': inline assembly is not stable enough for use and is subject to change
11-
--> $DIR/feature-gate-asm.rs:6:9
11+
--> $DIR/feature-gate-asm.rs:7:9
1212
|
1313
LL | llvm_asm!("");
1414
| ^^^^^^^^
1515
|
1616
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
1717
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
1818

19-
error: aborting due to 2 previous errors
19+
warning: use of deprecated item 'asm': the syntax of asm! will change soon, use llvm_asm! to avoid breakage
20+
--> $DIR/feature-gate-asm.rs:5:9
21+
|
22+
LL | asm!("");
23+
| ^^^ help: replace the use of the deprecated item: `llvm_asm`
24+
|
25+
= note: `#[warn(deprecated)]` on by default
26+
27+
error: aborting due to 2 previous errors; 1 warning emitted
2028

2129
For more information about this error, try `rustc --explain E0658`.

src/test/ui/feature-gates/feature-gate-asm2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
fn main() {
44
unsafe {
55
println!("{:?}", asm!("")); //~ ERROR inline assembly is not stable
6+
//~^ WARN use of deprecated item 'asm'
67
println!("{:?}", llvm_asm!("")); //~ ERROR inline assembly is not stable
78
}
89
}

src/test/ui/feature-gates/feature-gate-asm2.stderr

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ LL | println!("{:?}", asm!(""));
88
= help: add `#![feature(asm)]` to the crate attributes to enable
99

1010
error[E0658]: use of unstable library feature 'llvm_asm': inline assembly is not stable enough for use and is subject to change
11-
--> $DIR/feature-gate-asm2.rs:6:26
11+
--> $DIR/feature-gate-asm2.rs:7:26
1212
|
1313
LL | println!("{:?}", llvm_asm!(""));
1414
| ^^^^^^^^
1515
|
1616
= note: see issue #70173 <https://github.com/rust-lang/rust/issues/70173> for more information
1717
= help: add `#![feature(llvm_asm)]` to the crate attributes to enable
1818

19-
error: aborting due to 2 previous errors
19+
warning: use of deprecated item 'asm': the syntax of asm! will change soon, use llvm_asm! to avoid breakage
20+
--> $DIR/feature-gate-asm2.rs:5:26
21+
|
22+
LL | println!("{:?}", asm!(""));
23+
| ^^^ help: replace the use of the deprecated item: `llvm_asm`
24+
|
25+
= note: `#[warn(deprecated)]` on by default
26+
27+
error: aborting due to 2 previous errors; 1 warning emitted
2028

2129
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)