Skip to content

Rollup of 8 pull requests #144658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c5b4606
Enable t-compiler backport nomination
apiraino Jul 28, 2025
56d9ed7
Fix nvptx-safe-naming.rs test on LLVM 21
nikic Jul 22, 2025
d50b4f1
Adjust enum-discriminant-eq.rs for LLVM 21
nikic Jul 29, 2025
652b9eb
Add support for the m68k architecture in 'object_architecture'
FractalFir Jul 29, 2025
ccf660f
Relax check lines in x86-return-float.rs
nikic Jul 29, 2025
c39b447
"Cachify" `ExternPreludeEntry.binding` through a `Cell`.
LorrensP-2158466 Jul 28, 2025
0b807fc
Update rustc-perf submodule
Kobzol Jul 29, 2025
d1a877a
Improve tidy error on dependency license exceptions
Kobzol Jul 29, 2025
ab4024e
Update license exceptions for rustc-perf
Kobzol Jul 29, 2025
b60026a
Remove no longer needed handling of nonstandard licenses
Kobzol Jul 29, 2025
77fc593
Update wasi-sdk to 27.0 in CI
alexcrichton Jul 28, 2025
307fd41
tests: Test line number in debuginfo for diverging function calls
Enselic Jul 16, 2025
05da623
Fix Ord, Eq and Hash implementation of panic::Location
orlp Jul 26, 2025
56bf50d
Rollup merge of #144034 - Enselic:diverging-function-call-debuginfo, …
jhpratt Jul 29, 2025
48dfddd
Rollup merge of #144510 - orlp:fix-location-ord, r=ibraheemdev
jhpratt Jul 29, 2025
5334780
Rollup merge of #144583 - apiraino:enable-t-compiler-backport-nominat…
jhpratt Jul 29, 2025
79ad87e
Rollup merge of #144586 - alexcrichton:update-weasi-sdk, r=Mark-Simul…
jhpratt Jul 29, 2025
0912d66
Rollup merge of #144605 - LorrensP-2158466:cache-extern-prelude, r=pe…
jhpratt Jul 29, 2025
bd40dd6
Rollup merge of #144632 - nikic:llvm-21-tests, r=durin42
jhpratt Jul 29, 2025
322686d
Rollup merge of #144639 - Kobzol:x-perf-tui, r=lqd
jhpratt Jul 29, 2025
72f4ff2
Rollup merge of #144640 - FractalFir:m68k_arch, r=Urgau
jhpratt Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,18 +984,17 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
// more details: https://github.com/rust-lang/rust/pull/111761
return;
}
let entry = self
.r
.extern_prelude
.entry(ident)
.or_insert(ExternPreludeEntry { binding: None, introduced_by_item: true });
let entry = self.r.extern_prelude.entry(ident).or_insert(ExternPreludeEntry {
binding: Cell::new(None),
introduced_by_item: true,
});
if orig_name.is_some() {
entry.introduced_by_item = true;
}
// Binding from `extern crate` item in source code can replace
// a binding from `--extern` on command line here.
if !entry.is_import() {
entry.binding = Some(imported_binding)
entry.binding.set(Some(imported_binding));
} else if ident.name != kw::Underscore {
self.r.dcx().span_delayed_bug(
item.span,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,13 +1009,13 @@ impl<'ra> NameBindingData<'ra> {

#[derive(Default, Clone)]
struct ExternPreludeEntry<'ra> {
binding: Option<NameBinding<'ra>>,
binding: Cell<Option<NameBinding<'ra>>>,
introduced_by_item: bool,
}

impl ExternPreludeEntry<'_> {
fn is_import(&self) -> bool {
self.binding.is_some_and(|binding| binding.is_import())
self.binding.get().is_some_and(|binding| binding.is_import())
}
}

Expand Down Expand Up @@ -2006,7 +2006,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
// but not introduce it, as used if they are accessed from lexical scope.
if used == Used::Scope {
if let Some(entry) = self.extern_prelude.get(&ident.normalize_to_macros_2_0()) {
if !entry.introduced_by_item && entry.binding == Some(used_binding) {
if !entry.introduced_by_item && entry.binding.get() == Some(used_binding) {
return;
}
}
Expand Down Expand Up @@ -2170,7 +2170,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

let norm_ident = ident.normalize_to_macros_2_0();
let binding = self.extern_prelude.get(&norm_ident).cloned().and_then(|entry| {
Some(if let Some(binding) = entry.binding {
Some(if let Some(binding) = entry.binding.get() {
if finalize {
if !entry.is_import() {
self.cstore_mut().process_path_extern(self.tcx, ident.name, ident.span);
Expand All @@ -2195,8 +2195,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
})
});

if let Some(entry) = self.extern_prelude.get_mut(&norm_ident) {
entry.binding = binding;
if let Some(entry) = self.extern_prelude.get(&norm_ident) {
entry.binding.set(binding);
}

binding
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3598,6 +3598,7 @@ impl Target {
),
"x86" => (Architecture::I386, None),
"s390x" => (Architecture::S390x, None),
"m68k" => (Architecture::M68k, None),
"mips" | "mips32r6" => (Architecture::Mips, None),
"mips64" | "mips64r6" => (
// While there are currently no builtin targets
Expand Down
42 changes: 41 additions & 1 deletion library/core/src/panic/location.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::cmp::Ordering;
use crate::ffi::CStr;
use crate::fmt;
use crate::hash::{Hash, Hasher};
use crate::marker::PhantomData;
use crate::ptr::NonNull;

Expand Down Expand Up @@ -32,7 +34,7 @@ use crate::ptr::NonNull;
/// Files are compared as strings, not `Path`, which could be unexpected.
/// See [`Location::file`]'s documentation for more discussion.
#[lang = "panic_location"]
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(Copy, Clone)]
#[stable(feature = "panic_hooks", since = "1.10.0")]
pub struct Location<'a> {
// A raw pointer is used rather than a reference because the pointer is valid for one more byte
Expand All @@ -44,6 +46,44 @@ pub struct Location<'a> {
_filename: PhantomData<&'a str>,
}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl PartialEq for Location<'_> {
fn eq(&self, other: &Self) -> bool {
// Compare col / line first as they're cheaper to compare and more likely to differ,
// while not impacting the result.
self.col == other.col && self.line == other.line && self.file() == other.file()
}
}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl Eq for Location<'_> {}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl Ord for Location<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.file()
.cmp(other.file())
.then_with(|| self.line.cmp(&other.line))
.then_with(|| self.col.cmp(&other.col))
}
}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl PartialOrd for Location<'_> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl Hash for Location<'_> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.file().hash(state);
self.line.hash(state);
self.col.hash(state);
}
}

#[stable(feature = "panic_hooks", since = "1.10.0")]
impl fmt::Debug for Location<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
43 changes: 41 additions & 2 deletions library/coretests/tests/panic/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ use core::panic::Location;
// Note: Some of the following tests depend on the source location,
// so please be careful when editing this file.

mod file_a;
mod file_b;
mod file_c;

// A small shuffled set of locations for testing, along with their true order.
const LOCATIONS: [(usize, &'static Location<'_>); 9] = [
(7, file_c::two()),
(0, file_a::one()),
(3, file_b::one()),
(5, file_b::three()),
(8, file_c::three()),
(6, file_c::one()),
(2, file_a::three()),
(4, file_b::two()),
(1, file_a::two()),
];

#[test]
fn location_const_caller() {
const _CALLER_REFERENCE: &Location<'static> = Location::caller();
Expand All @@ -20,7 +37,7 @@ fn location_const_file() {
fn location_const_line() {
const CALLER: &Location<'static> = Location::caller();
const LINE: u32 = CALLER.line();
assert_eq!(LINE, 21);
assert_eq!(LINE, 38);
}

#[test]
Expand All @@ -34,6 +51,28 @@ fn location_const_column() {
fn location_debug() {
let f = format!("{:?}", Location::caller());
assert!(f.contains(&format!("{:?}", file!())));
assert!(f.contains("35"));
assert!(f.contains("52"));
assert!(f.contains("29"));
}

#[test]
fn location_eq() {
for (i, a) in LOCATIONS {
for (j, b) in LOCATIONS {
if i == j {
assert_eq!(a, b);
} else {
assert_ne!(a, b);
}
}
}
}

#[test]
fn location_ord() {
let mut locations = LOCATIONS.clone();
locations.sort_by_key(|(_o, l)| **l);
for (correct, (order, _l)) in locations.iter().enumerate() {
assert_eq!(correct, *order);
}
}
15 changes: 15 additions & 0 deletions library/coretests/tests/panic/location/file_a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use core::panic::Location;

// Used for test super::location_{ord, eq}. Must be in a dedicated file.

pub const fn one() -> &'static Location<'static> {
Location::caller()
}

pub const fn two() -> &'static Location<'static> {
Location::caller()
}

pub const fn three() -> &'static Location<'static> {
Location::caller()
}
15 changes: 15 additions & 0 deletions library/coretests/tests/panic/location/file_b.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use core::panic::Location;

// Used for test super::location_{ord, eq}. Must be in a dedicated file.

pub const fn one() -> &'static Location<'static> {
Location::caller()
}

pub const fn two() -> &'static Location<'static> {
Location::caller()
}

pub const fn three() -> &'static Location<'static> {
Location::caller()
}
11 changes: 11 additions & 0 deletions library/coretests/tests/panic/location/file_c.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Used for test super::location_{ord, eq}. Must be in a dedicated file.

// This is used for testing column ordering of Location, hence this ugly one-liner.
// We must fmt skip the entire containing module or else tidy will still complain.
#[rustfmt::skip]
mod no_fmt {
use core::panic::Location;
pub const fn one() -> &'static Location<'static> { Location::caller() } pub const fn two() -> &'static Location<'static> { Location::caller() } pub const fn three() -> &'static Location<'static> { Location::caller() }
}

pub use no_fmt::*;
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ RUN /tmp/build-fuchsia-toolchain.sh
COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh

RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz | \
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \
tar -xz
ENV WASI_SDK_PATH=/tmp/wasi-sdk-25.0-x86_64-linux
ENV WASI_SDK_PATH=/tmp/wasi-sdk-27.0-x86_64-linux

COPY scripts/freebsd-toolchain.sh /tmp/
RUN /tmp/freebsd-toolchain.sh i686
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ WORKDIR /
COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-25.0-x86_64-linux.tar.gz | \
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \
tar -xz
ENV WASI_SDK_PATH=/wasi-sdk-25.0-x86_64-linux
ENV WASI_SDK_PATH=/wasi-sdk-27.0-x86_64-linux

ENV RUST_CONFIGURE_ARGS \
--musl-root-x86_64=/usr/local/x86_64-linux-musl \
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustc-perf
Submodule rustc-perf updated 1740 files
51 changes: 24 additions & 27 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const EXCEPTIONS_RUSTC_PERF: ExceptionList = &[
("brotli-decompressor", "BSD-3-Clause/MIT"),
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
("inferno", "CDDL-1.0"),
("ring", NON_STANDARD_LICENSE), // see EXCEPTIONS_NON_STANDARD_LICENSE_DEPS for more.
("option-ext", "MPL-2.0"),
("ryu", "Apache-2.0 OR BSL-1.0"),
("snap", "BSD-3-Clause"),
("subtle", "BSD-3-Clause"),
Expand Down Expand Up @@ -226,20 +226,6 @@ const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[
("r-efi", "MIT OR Apache-2.0 OR LGPL-2.1-or-later"), // LGPL is not acceptable, but we use it under MIT OR Apache-2.0
];

/// Placeholder for non-standard license file.
const NON_STANDARD_LICENSE: &str = "NON_STANDARD_LICENSE";

/// These dependencies have non-standard licenses but are genenrally permitted.
const EXCEPTIONS_NON_STANDARD_LICENSE_DEPS: &[&str] = &[
// `ring` is included because it is an optional dependency of `hyper`,
// which is a training data in rustc-perf for optimized build.
// The license of it is generally `ISC AND MIT AND OpenSSL`,
// though the `package.license` field is not set.
//
// See https://github.com/briansmith/ring/issues/902
"ring",
];

const PERMITTED_DEPS_LOCATION: &str = concat!(file!(), ":", line!());

/// Crates rustc is allowed to depend on. Avoid adding to the list if possible.
Expand Down Expand Up @@ -599,7 +585,7 @@ pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
.other_options(vec!["--locked".to_owned()]);
let metadata = t!(cmd.exec());

check_license_exceptions(&metadata, exceptions, bad);
check_license_exceptions(&metadata, workspace, exceptions, bad);
if let Some((crates, permitted_deps)) = permitted_deps {
check_permitted_dependencies(&metadata, workspace, permitted_deps, crates, bad);
}
Expand Down Expand Up @@ -730,14 +716,19 @@ fn check_runtime_license_exceptions(metadata: &Metadata, bad: &mut bool) {
/// Check that all licenses of tool dependencies are in the valid list in `LICENSES`.
///
/// Packages listed in `exceptions` are allowed for tools.
fn check_license_exceptions(metadata: &Metadata, exceptions: &[(&str, &str)], bad: &mut bool) {
fn check_license_exceptions(
metadata: &Metadata,
workspace: &str,
exceptions: &[(&str, &str)],
bad: &mut bool,
) {
// Validate the EXCEPTIONS list hasn't changed.
for (name, license) in exceptions {
// Check that the package actually exists.
if !metadata.packages.iter().any(|p| *p.name == *name) {
tidy_error!(
bad,
"could not find exception package `{}`\n\
"could not find exception package `{}` in workspace `{workspace}`\n\
Remove from EXCEPTIONS list if it is no longer used.",
name
);
Expand All @@ -746,20 +737,17 @@ fn check_license_exceptions(metadata: &Metadata, exceptions: &[(&str, &str)], ba
for pkg in metadata.packages.iter().filter(|p| *p.name == *name) {
match &pkg.license {
None => {
if *license == NON_STANDARD_LICENSE
&& EXCEPTIONS_NON_STANDARD_LICENSE_DEPS.contains(&pkg.name.as_str())
{
continue;
}
tidy_error!(
bad,
"dependency exception `{}` does not declare a license expression",
"dependency exception `{}` in workspace `{workspace}` does not declare a license expression",
pkg.id
);
}
Some(pkg_license) => {
if pkg_license.as_str() != *license {
println!("dependency exception `{name}` license has changed");
println!(
"dependency exception `{name}` license in workspace `{workspace}` has changed"
);
println!(" previously `{license}` now `{pkg_license}`");
println!(" update EXCEPTIONS for the new license");
*bad = true;
Expand All @@ -783,12 +771,21 @@ fn check_license_exceptions(metadata: &Metadata, exceptions: &[(&str, &str)], ba
let license = match &pkg.license {
Some(license) => license,
None => {
tidy_error!(bad, "dependency `{}` does not define a license expression", pkg.id);
tidy_error!(
bad,
"dependency `{}` in workspace `{workspace}` does not define a license expression",
pkg.id
);
continue;
}
};
if !LICENSES.contains(&license.as_str()) {
tidy_error!(bad, "invalid license `{}` in `{}`", license, pkg.id);
tidy_error!(
bad,
"invalid license `{}` for package `{}` in workspace `{workspace}`",
license,
pkg.id
);
}
}
}
Expand Down
Loading
Loading