Skip to content

Commit

Permalink
Auto merge of rust-lang#130913 - tgross35:rollup-rhgshbb, r=tgross35
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Sep 27, 2024
2 parents 58420a0 + 6e13473 commit 24c8b9f
Show file tree
Hide file tree
Showing 27 changed files with 505 additions and 510 deletions.
105 changes: 56 additions & 49 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1622,56 +1622,63 @@ impl<'a> CrateMetadataRef<'a> {
);

for virtual_dir in virtual_rust_source_base_dir.iter().flatten() {
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir {
if let rustc_span::FileName::Real(old_name) = name {
if let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
old_name
{
if let Ok(rest) = virtual_name.strip_prefix(virtual_dir) {
let virtual_name = virtual_name.clone();

// The std library crates are in
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
// detect crates from the std libs and handle them specially.
const STD_LIBS: &[&str] = &[
"core",
"alloc",
"std",
"test",
"term",
"unwind",
"proc_macro",
"panic_abort",
"panic_unwind",
"profiler_builtins",
"rtstartup",
"rustc-std-workspace-core",
"rustc-std-workspace-alloc",
"rustc-std-workspace-std",
"backtrace",
];
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));

let new_path = if is_std_lib {
real_dir.join("library").join(rest)
} else {
real_dir.join(rest)
};

debug!(
"try_to_translate_virtual_to_real: `{}` -> `{}`",
virtual_name.display(),
new_path.display(),
);
let new_name = rustc_span::RealFileName::Remapped {
local_path: Some(new_path),
virtual_name,
};
*old_name = new_name;
}
if let Some(real_dir) = &sess.opts.real_rust_source_base_dir
&& let rustc_span::FileName::Real(old_name) = name
&& let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
old_name
&& let Ok(rest) = virtual_name.strip_prefix(virtual_dir)
{
// The std library crates are in
// `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
// may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
// detect crates from the std libs and handle them specially.
const STD_LIBS: &[&str] = &[
"core",
"alloc",
"std",
"test",
"term",
"unwind",
"proc_macro",
"panic_abort",
"panic_unwind",
"profiler_builtins",
"rtstartup",
"rustc-std-workspace-core",
"rustc-std-workspace-alloc",
"rustc-std-workspace-std",
"backtrace",
];
let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));

let new_path = if is_std_lib {
real_dir.join("library").join(rest)
} else {
real_dir.join(rest)
};

debug!(
"try_to_translate_virtual_to_real: `{}` -> `{}`",
virtual_name.display(),
new_path.display(),
);

// Check if the translated real path is affected by any user-requested
// remaps via --remap-path-prefix. Apply them if so.
// Note that this is a special case for imported rust-src paths specified by
// https://rust-lang.github.io/rfcs/3127-trim-paths.html#handling-sysroot-paths.
// Other imported paths are not currently remapped (see #66251).
let (user_remapped, applied) =
sess.source_map().path_mapping().map_prefix(&new_path);
let new_name = if applied {
rustc_span::RealFileName::Remapped {
local_path: Some(new_path.clone()),
virtual_name: user_remapped.to_path_buf(),
}
}
} else {
rustc_span::RealFileName::LocalPath(new_path)
};
*old_name = new_name;
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,13 @@ const HEXAGON_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
const POWERPC_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("altivec", Unstable(sym::powerpc_target_feature), &[]),
("partword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("power10-vector", Unstable(sym::powerpc_target_feature), &["power9-vector"]),
("power8-altivec", Unstable(sym::powerpc_target_feature), &["altivec"]),
("power8-vector", Unstable(sym::powerpc_target_feature), &["vsx", "power8-altivec"]),
("power9-altivec", Unstable(sym::powerpc_target_feature), &["power8-altivec"]),
("power9-vector", Unstable(sym::powerpc_target_feature), &["power8-vector", "power9-altivec"]),
("quadword-atomics", Unstable(sym::powerpc_target_feature), &[]),
("vsx", Unstable(sym::powerpc_target_feature), &["altivec"]),
// tidy-alphabetical-end
];
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.125"
version = "0.1.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd02a01d7bc069bed818e956600fe437ee222dd1d6ad92bfb9db87b43b71fd87"
checksum = "758019257ad46e191b587d8f711022a6ac1d1fb6745d75e1d76c587fdcbca770"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2021"

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

[dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
Expand Down
34 changes: 34 additions & 0 deletions library/core/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#[allow(unused_imports)]
#[stable(feature = "simd_arch", since = "1.27.0")]
pub use crate::core_arch::arch::*;
#[unstable(feature = "naked_functions", issue = "90957")]
#[cfg(bootstrap)]
pub use crate::naked_asm;

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

/// Inline assembly used in combination with `#[naked]` functions.
///
/// Refer to [Rust By Example] for a usage guide and the [reference] for
/// detailed information about the syntax and available options.
///
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
#[unstable(feature = "naked_functions", issue = "90957")]
#[macro_export]
#[cfg(bootstrap)]
macro_rules! naked_asm {
([$last:expr], [$($pushed:expr),*]) => {
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
{
core::arch::asm!($($pushed),*, options(att_syntax, noreturn))
}
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))]
{
core::arch::asm!($($pushed),* , $last, options(noreturn))
}
};

([$first:expr $(, $rest:expr)*], [$($pushed:expr),*]) => {
naked_asm!([$($rest),*], [$($pushed,)* $first]);
};

($($expr:expr),* $(,)?) => {
naked_asm!([$($expr),*], []);
};
}

/// Inline assembly used in combination with `#[naked]` functions.
///
/// Refer to [Rust By Example] for a usage guide and the [reference] for
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ pub macro assert_matches {
pub macro cfg_match {
// with a final wildcard
(
$(cfg($initial_meta:meta) => { $($initial_tokens:item)* })+
_ => { $($extra_tokens:item)* }
$(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+
_ => { $($extra_tokens:tt)* }
) => {
cfg_match! {
@__items ();
Expand All @@ -241,7 +241,7 @@ pub macro cfg_match {

// without a final wildcard
(
$(cfg($extra_meta:meta) => { $($extra_tokens:item)* })*
$(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })*
) => {
cfg_match! {
@__items ();
Expand All @@ -256,7 +256,7 @@ pub macro cfg_match {
(@__items ($($_:meta,)*);) => {},
(
@__items ($($no:meta,)*);
(($($yes:meta)?) ($($tokens:item)*)),
(($($yes:meta)?) ($($tokens:tt)*)),
$($rest:tt,)*
) => {
// Emit all items within one block, applying an appropriate #[cfg]. The
Expand All @@ -279,7 +279,7 @@ pub macro cfg_match {

// Internal macro to make __apply work out right for different match types,
// because of how macros match/expand stuff.
(@__identity $($tokens:item)*) => {
(@__identity $($tokens:tt)*) => {
$($tokens)*
}
}
Expand Down
20 changes: 20 additions & 0 deletions library/core/tests/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unused_must_use)]

#[allow(dead_code)]
trait Trait {
fn blah(&self);
Expand Down Expand Up @@ -173,3 +175,21 @@ fn cfg_match_two_functions() {
bar2();
}
}

fn _accepts_expressions() -> i32 {
cfg_match! {
cfg(unix) => { 1 }
_ => { 2 }
}
}

// The current implementation expands to a macro call, which allows the use of expression
// statements.
fn _allows_stmt_expr_attributes() {
let one = 1;
let two = 2;
cfg_match! {
cfg(unix) => { one * two; }
_ => { one + two; }
}
}
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "0.1.125" }
compiler_builtins = { version = "0.1.126" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.14", default-features = false, features = [
Expand Down
18 changes: 1 addition & 17 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use crate::mem::{self, ManuallyDrop};
use crate::panic::{BacktraceStyle, PanicHookInfo};
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{PoisonError, RwLock};
use crate::sys::backtrace;
use crate::sys::stdio::panic_output;
use crate::sys::{backtrace, dbg};
use crate::{fmt, intrinsics, process, thread};

// Binary interface to the panic runtime that the standard library depends on.
Expand Down Expand Up @@ -859,29 +859,13 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
#[cfg_attr(not(test), rustc_std_internal_symbol)]
#[cfg(not(feature = "panic_immediate_abort"))]
fn rust_panic(msg: &mut dyn PanicPayload) -> ! {
// Break into the debugger if it is attached.
// The return value is not currently used.
//
// This function isn't used anywhere else, and
// using inside `#[panic_handler]` doesn't seem
// to count, so a warning is issued.
let _ = dbg::breakpoint_if_debugging();

let code = unsafe { __rust_start_panic(msg) };
rtabort!("failed to initiate panic, error {code}")
}

#[cfg_attr(not(test), rustc_std_internal_symbol)]
#[cfg(feature = "panic_immediate_abort")]
fn rust_panic(_: &mut dyn PanicPayload) -> ! {
// Break into the debugger if it is attached.
// The return value is not currently used.
//
// This function isn't used anywhere else, and
// using inside `#[panic_handler]` doesn't seem
// to count, so a warning is issued.
let _ = dbg::breakpoint_if_debugging();

unsafe {
crate::intrinsics::abort();
}
Expand Down
Loading

0 comments on commit 24c8b9f

Please sign in to comment.