Skip to content

Commit 24c8b9f

Browse files
committed
Auto merge of rust-lang#130913 - tgross35:rollup-rhgshbb, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#129687 (Implement RFC3137 trim-paths sysroot changes - take 2) - rust-lang#130313 ([`cfg_match`] Generalize inputs) - rust-lang#130706 ([rustdoc] Remove unneeded jinja comments) - rust-lang#130846 (Revert Break into the debugger on panic (129019)) - rust-lang#130873 (rustc_target: Add powerpc64 atomic-related features) - rust-lang#130875 (update `compiler-builtins` to 0.1.126) - rust-lang#130889 (Weekly `cargo update`: only `rustbook`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 58420a0 + 6e13473 commit 24c8b9f

27 files changed

+505
-510
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+56-49
Original file line numberDiff line numberDiff line change
@@ -1622,56 +1622,63 @@ impl<'a> CrateMetadataRef<'a> {
16221622
);
16231623

16241624
for virtual_dir in virtual_rust_source_base_dir.iter().flatten() {
1625-
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir {
1626-
if let rustc_span::FileName::Real(old_name) = name {
1627-
if let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
1628-
old_name
1629-
{
1630-
if let Ok(rest) = virtual_name.strip_prefix(virtual_dir) {
1631-
let virtual_name = virtual_name.clone();
1632-
1633-
// The std library crates are in
1634-
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1635-
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1636-
// detect crates from the std libs and handle them specially.
1637-
const STD_LIBS: &[&str] = &[
1638-
"core",
1639-
"alloc",
1640-
"std",
1641-
"test",
1642-
"term",
1643-
"unwind",
1644-
"proc_macro",
1645-
"panic_abort",
1646-
"panic_unwind",
1647-
"profiler_builtins",
1648-
"rtstartup",
1649-
"rustc-std-workspace-core",
1650-
"rustc-std-workspace-alloc",
1651-
"rustc-std-workspace-std",
1652-
"backtrace",
1653-
];
1654-
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
1655-
1656-
let new_path = if is_std_lib {
1657-
real_dir.join("library").join(rest)
1658-
} else {
1659-
real_dir.join(rest)
1660-
};
1661-
1662-
debug!(
1663-
"try_to_translate_virtual_to_real: `{}` -> `{}`",
1664-
virtual_name.display(),
1665-
new_path.display(),
1666-
);
1667-
let new_name = rustc_span::RealFileName::Remapped {
1668-
local_path: Some(new_path),
1669-
virtual_name,
1670-
};
1671-
*old_name = new_name;
1672-
}
1625+
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir
1626+
&& let rustc_span::FileName::Real(old_name) = name
1627+
&& let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
1628+
old_name
1629+
&& let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
1630+
{
1631+
// The std library crates are in
1632+
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
1633+
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
1634+
// detect crates from the std libs and handle them specially.
1635+
const STD_LIBS: &[&str] = &[
1636+
"core",
1637+
"alloc",
1638+
"std",
1639+
"test",
1640+
"term",
1641+
"unwind",
1642+
"proc_macro",
1643+
"panic_abort",
1644+
"panic_unwind",
1645+
"profiler_builtins",
1646+
"rtstartup",
1647+
"rustc-std-workspace-core",
1648+
"rustc-std-workspace-alloc",
1649+
"rustc-std-workspace-std",
1650+
"backtrace",
1651+
];
1652+
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
1653+
1654+
let new_path = if is_std_lib {
1655+
real_dir.join("library").join(rest)
1656+
} else {
1657+
real_dir.join(rest)
1658+
};
1659+
1660+
debug!(
1661+
"try_to_translate_virtual_to_real: `{}` -> `{}`",
1662+
virtual_name.display(),
1663+
new_path.display(),
1664+
);
1665+
1666+
// Check if the translated real path is affected by any user-requested
1667+
// remaps via --remap-path-prefix. Apply them if so.
1668+
// Note that this is a special case for imported rust-src paths specified by
1669+
// https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths.
1670+
// Other imported paths are not currently remapped (see #66251).
1671+
let (user_remapped, applied) =
1672+
sess.source_map().path_mapping().map_prefix(&new_path);
1673+
let new_name = if applied {
1674+
rustc_span::RealFileName::Remapped {
1675+
local_path: Some(new_path.clone()),
1676+
virtual_name: user_remapped.to_path_buf(),
16731677
}
1674-
}
1678+
} else {
1679+
rustc_span::RealFileName::LocalPath(new_path)
1680+
};
1681+
*old_name = new_name;
16751682
}
16761683
}
16771684
};

compiler/rustc_target/src/target_features.rs

+2
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ const HEXAGON_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
352352
const POWERPC_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
353353
// tidy-alphabetical-start
354354
("altivec", Unstable(sym::powerpc_target_feature), &[]),
355+
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
355356
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
356357
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
357358
("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
358359
("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
359360
("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
361+
("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
360362
("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
361363
// tidy-alphabetical-end
362364
];

library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ dependencies = [
5858

5959
[[package]]
6060
name = "compiler_builtins"
61-
version = "0.1.125"
61+
version = "0.1.126"
6262
source = "registry+https://github.com/rust-lang/crates.io-index"
63-
checksum = "bd02a01d7bc069bed818e956600fe437ee222dd1d6ad92bfb9db87b43b71fd87"
63+
checksum = "758019257ad46e191b587d8f711022a6ac1d1fb6745d75e1d76c587fdcbca770"
6464
dependencies = [
6565
"cc",
6666
"rustc-std-workspace-core",

library/alloc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2021"
1010

1111
[dependencies]
1212
core = { path = "../core" }
13-
compiler_builtins = { version = "0.1.125", features = ['rustc-dep-of-std'] }
13+
compiler_builtins = { version = "0.1.126", features = ['rustc-dep-of-std'] }
1414

1515
[dev-dependencies]
1616
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

library/core/src/arch.rs

+34
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#[allow(unused_imports)]
44
#[stable(feature = "simd_arch", since = "1.27.0")]
55
pub use crate::core_arch::arch::*;
6+
#[unstable(feature = "naked_functions", issue = "90957")]
7+
#[cfg(bootstrap)]
8+
pub use crate::naked_asm;
69

710
/// Inline assembly.
811
///
@@ -17,6 +20,37 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
1720
/* compiler built-in */
1821
}
1922

23+
/// Inline assembly used in combination with `#[naked]` functions.
24+
///
25+
/// Refer to [Rust By Example] for a usage guide and the [reference] for
26+
/// detailed information about the syntax and available options.
27+
///
28+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
29+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
30+
#[unstable(feature = "naked_functions", issue = "90957")]
31+
#[macro_export]
32+
#[cfg(bootstrap)]
33+
macro_rules! naked_asm {
34+
([$last:expr], [$($pushed:expr),*]) => {
35+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
36+
{
37+
core::arch::asm!($($pushed),*, options(att_syntax, noreturn))
38+
}
39+
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
40+
{
41+
core::arch::asm!($($pushed),* , $last, options(noreturn))
42+
}
43+
};
44+
45+
([$first:expr $(, $rest:expr)*], [$($pushed:expr),*]) => {
46+
naked_asm!([$($rest),*], [$($pushed,)* $first]);
47+
};
48+
49+
($($expr:expr),* $(,)?) => {
50+
naked_asm!([$($expr),*], []);
51+
};
52+
}
53+
2054
/// Inline assembly used in combination with `#[naked]` functions.
2155
///
2256
/// Refer to [Rust By Example] for a usage guide and the [reference] for

library/core/src/macros/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ pub macro assert_matches {
229229
pub macro cfg_match {
230230
// with a final wildcard
231231
(
232-
$(cfg($initial_meta:meta) => { $($initial_tokens:item)* })+
233-
_ => { $($extra_tokens:item)* }
232+
$(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+
233+
_ => { $($extra_tokens:tt)* }
234234
) => {
235235
cfg_match! {
236236
@__items ();
@@ -241,7 +241,7 @@ pub macro cfg_match {
241241

242242
// without a final wildcard
243243
(
244-
$(cfg($extra_meta:meta) => { $($extra_tokens:item)* })*
244+
$(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })*
245245
) => {
246246
cfg_match! {
247247
@__items ();
@@ -256,7 +256,7 @@ pub macro cfg_match {
256256
(@__items ($($_:meta,)*);) => {},
257257
(
258258
@__items ($($no:meta,)*);
259-
(($($yes:meta)?) ($($tokens:item)*)),
259+
(($($yes:meta)?) ($($tokens:tt)*)),
260260
$($rest:tt,)*
261261
) => {
262262
// Emit all items within one block, applying an appropriate #[cfg]. The
@@ -279,7 +279,7 @@ pub macro cfg_match {
279279

280280
// Internal macro to make __apply work out right for different match types,
281281
// because of how macros match/expand stuff.
282-
(@__identity $($tokens:item)*) => {
282+
(@__identity $($tokens:tt)*) => {
283283
$($tokens)*
284284
}
285285
}

library/core/tests/macros.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unused_must_use)]
2+
13
#[allow(dead_code)]
24
trait Trait {
35
fn blah(&self);
@@ -173,3 +175,21 @@ fn cfg_match_two_functions() {
173175
bar2();
174176
}
175177
}
178+
179+
fn _accepts_expressions() -> i32 {
180+
cfg_match! {
181+
cfg(unix) => { 1 }
182+
_ => { 2 }
183+
}
184+
}
185+
186+
// The current implementation expands to a macro call, which allows the use of expression
187+
// statements.
188+
fn _allows_stmt_expr_attributes() {
189+
let one = 1;
190+
let two = 2;
191+
cfg_match! {
192+
cfg(unix) => { one * two; }
193+
_ => { one + two; }
194+
}
195+
}

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1717
panic_unwind = { path = "../panic_unwind", optional = true }
1818
panic_abort = { path = "../panic_abort" }
1919
core = { path = "../core", public = true }
20-
compiler_builtins = { version = "0.1.125" }
20+
compiler_builtins = { version = "0.1.126" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.14", default-features = false, features = [

library/std/src/panicking.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use crate::mem::{self, ManuallyDrop};
2323
use crate::panic::{BacktraceStyle, PanicHookInfo};
2424
use crate::sync::atomic::{AtomicBool, Ordering};
2525
use crate::sync::{PoisonError, RwLock};
26+
use crate::sys::backtrace;
2627
use crate::sys::stdio::panic_output;
27-
use crate::sys::{backtrace, dbg};
2828
use crate::{fmt, intrinsics, process, thread};
2929

3030
// Binary interface to the panic runtime that the standard library depends on.
@@ -859,29 +859,13 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
859859
#[cfg_attr(not(test), rustc_std_internal_symbol)]
860860
#[cfg(not(feature = "panic_immediate_abort"))]
861861
fn rust_panic(msg: &mut dyn PanicPayload) -> ! {
862-
// Break into the debugger if it is attached.
863-
// The return value is not currently used.
864-
//
865-
// This function isn't used anywhere else, and
866-
// using inside `#[panic_handler]` doesn't seem
867-
// to count, so a warning is issued.
868-
let _ = dbg::breakpoint_if_debugging();
869-
870862
let code = unsafe { __rust_start_panic(msg) };
871863
rtabort!("failed to initiate panic, error {code}")
872864
}
873865

874866
#[cfg_attr(not(test), rustc_std_internal_symbol)]
875867
#[cfg(feature = "panic_immediate_abort")]
876868
fn rust_panic(_: &mut dyn PanicPayload) -> ! {
877-
// Break into the debugger if it is attached.
878-
// The return value is not currently used.
879-
//
880-
// This function isn't used anywhere else, and
881-
// using inside `#[panic_handler]` doesn't seem
882-
// to count, so a warning is issued.
883-
let _ = dbg::breakpoint_if_debugging();
884-
885869
unsafe {
886870
crate::intrinsics::abort();
887871
}

0 commit comments

Comments
 (0)