Skip to content

Commit 65b7aa9

Browse files
Rollup merge of rust-lang#87227 - bstrie:asm2arch, r=Amanieu
Move asm! and global_asm! to core::arch Follow-up to rust-lang/stdarch#1183 . Implements the libs-api team decision from rust-lang#84019 (comment) . In order to not break nightly users, this PR also adds the newly-moved items to the prelude. However, a decision will need to be made before stabilization as to whether these items should remain in the prelude. I will file an issue for this separately. Fixes rust-lang#84019 . r? `@Amanieu`
2 parents 456ebd3 + f26fbe2 commit 65b7aa9

File tree

5 files changed

+73
-49
lines changed

5 files changed

+73
-49
lines changed

library/core/src/lib.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,35 @@ pub mod primitive;
316316
#[unstable(feature = "stdsimd", issue = "48556")]
317317
mod core_arch;
318318

319+
#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
319320
#[stable(feature = "simd_arch", since = "1.27.0")]
320-
pub use core_arch::arch;
321+
pub mod arch {
322+
#[stable(feature = "simd_arch", since = "1.27.0")]
323+
pub use crate::core_arch::arch::*;
324+
325+
/// Inline assembly.
326+
///
327+
/// Read the [unstable book] for the usage.
328+
///
329+
/// [unstable book]: ../../unstable-book/library-features/asm.html
330+
#[unstable(
331+
feature = "asm",
332+
issue = "72016",
333+
reason = "inline assembly is not stable enough for use and is subject to change"
334+
)]
335+
#[rustc_builtin_macro]
336+
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
337+
/* compiler built-in */
338+
}
339+
340+
/// Module-level inline assembly.
341+
#[unstable(
342+
feature = "global_asm",
343+
issue = "35119",
344+
reason = "`global_asm!` is not stable enough for use and is subject to change"
345+
)]
346+
#[rustc_builtin_macro]
347+
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {
348+
/* compiler built-in */
349+
}
350+
}

library/core/src/macros/mod.rs

-38
Original file line numberDiff line numberDiff line change
@@ -1312,27 +1312,6 @@ pub(crate) mod builtin {
13121312
($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
13131313
}
13141314

1315-
/// Inline assembly.
1316-
///
1317-
/// Read the [unstable book] for the usage.
1318-
///
1319-
/// [unstable book]: ../unstable-book/library-features/asm.html
1320-
#[unstable(
1321-
feature = "asm",
1322-
issue = "72016",
1323-
reason = "inline assembly is not stable enough for use and is subject to change"
1324-
)]
1325-
#[rustc_builtin_macro]
1326-
#[macro_export]
1327-
macro_rules! asm {
1328-
("assembly template",
1329-
$(operands,)*
1330-
$(options($(option),*))?
1331-
) => {
1332-
/* compiler built-in */
1333-
};
1334-
}
1335-
13361315
/// LLVM-style inline assembly.
13371316
///
13381317
/// Read the [unstable book] for the usage.
@@ -1355,23 +1334,6 @@ pub(crate) mod builtin {
13551334
};
13561335
}
13571336

1358-
/// Module-level inline assembly.
1359-
#[unstable(
1360-
feature = "global_asm",
1361-
issue = "35119",
1362-
reason = "`global_asm!` is not stable enough for use and is subject to change"
1363-
)]
1364-
#[rustc_builtin_macro]
1365-
#[macro_export]
1366-
macro_rules! global_asm {
1367-
("assembly template",
1368-
$(operands,)*
1369-
$(options($(option),*))?
1370-
) => {
1371-
/* compiler built-in */
1372-
};
1373-
}
1374-
13751337
/// Prints passed tokens into the standard output.
13761338
#[unstable(
13771339
feature = "log_syntax",

library/core/src/prelude/v1.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,27 @@ pub use crate::hash::macros::Hash;
5555
#[allow(deprecated)]
5656
#[doc(no_inline)]
5757
pub use crate::{
58-
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
59-
format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
60-
module_path, option_env, stringify, trace_macros,
58+
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
59+
format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
60+
option_env, stringify, trace_macros,
6161
};
6262

63+
#[unstable(
64+
feature = "asm",
65+
issue = "72016",
66+
reason = "inline assembly is not stable enough for use and is subject to change"
67+
)]
68+
#[doc(no_inline)]
69+
pub use crate::arch::asm;
70+
71+
#[unstable(
72+
feature = "global_asm",
73+
issue = "35119",
74+
reason = "`global_asm!` is not stable enough for use and is subject to change"
75+
)]
76+
#[doc(no_inline)]
77+
pub use crate::arch::global_asm;
78+
6379
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6480
#[allow(deprecated, deprecated_in_future)]
6581
#[doc(no_inline)]

library/std/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ pub use core::{
556556
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
557557
#[allow(deprecated)]
558558
pub use core::{
559-
asm, assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
560-
format_args, format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm,
561-
log_syntax, module_path, option_env, stringify, trace_macros,
559+
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, env, file,
560+
format_args, format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax,
561+
module_path, option_env, stringify, trace_macros,
562562
};
563563

564564
#[stable(feature = "core_primitive", since = "1.43.0")]

library/std/src/prelude/v1.rs

+20-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,28 @@ pub use crate::result::Result::{self, Err, Ok};
3939
#[allow(deprecated)]
4040
#[doc(no_inline)]
4141
pub use core::prelude::v1::{
42-
asm, assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
43-
format_args_nl, global_asm, include, include_bytes, include_str, line, llvm_asm, log_syntax,
44-
module_path, option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord,
45-
PartialEq, PartialOrd,
42+
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
43+
format_args_nl, include, include_bytes, include_str, line, llvm_asm, log_syntax, module_path,
44+
option_env, stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq,
45+
PartialOrd,
4646
};
4747

48+
#[unstable(
49+
feature = "asm",
50+
issue = "72016",
51+
reason = "inline assembly is not stable enough for use and is subject to change"
52+
)]
53+
#[doc(no_inline)]
54+
pub use core::prelude::v1::asm;
55+
56+
#[unstable(
57+
feature = "global_asm",
58+
issue = "35119",
59+
reason = "`global_asm!` is not stable enough for use and is subject to change"
60+
)]
61+
#[doc(no_inline)]
62+
pub use core::prelude::v1::global_asm;
63+
4864
// FIXME: Attribute and internal derive macros are not documented because for them rustdoc generates
4965
// dead links which fail link checker testing.
5066
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]

0 commit comments

Comments
 (0)