Skip to content

Commit c8bb4e8

Browse files
committed
Auto merge of #144658 - jhpratt:rollup-jdzhz27, r=jhpratt
Rollup of 8 pull requests Successful merges: - #144034 (tests: Test line number in debuginfo for diverging function calls) - #144510 (Fix Ord, Eq and Hash implementation of panic::Location) - #144583 (Enable T-compiler backport nomination) - #144586 (Update wasi-sdk to 27.0 in CI) - #144605 (Resolve: cachify `ExternPreludeEntry.binding` through a `Cell`) - #144632 (Update some tests for LLVM 21) - #144639 (Update rustc-perf submodule) - #144640 (Add support for the m68k architecture in 'object_architecture') r? `@ghost` `@rustbot` modify labels: rollup
2 parents ba7e63b + 72f4ff2 commit c8bb4e8

File tree

17 files changed

+235
-55
lines changed

17 files changed

+235
-55
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -984,18 +984,17 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
984984
// more details: https://github.com/rust-lang/rust/pull/111761
985985
return;
986986
}
987-
let entry = self
988-
.r
989-
.extern_prelude
990-
.entry(ident)
991-
.or_insert(ExternPreludeEntry { binding: None, introduced_by_item: true });
987+
let entry = self.r.extern_prelude.entry(ident).or_insert(ExternPreludeEntry {
988+
binding: Cell::new(None),
989+
introduced_by_item: true,
990+
});
992991
if orig_name.is_some() {
993992
entry.introduced_by_item = true;
994993
}
995994
// Binding from `extern crate` item in source code can replace
996995
// a binding from `--extern` on command line here.
997996
if !entry.is_import() {
998-
entry.binding = Some(imported_binding)
997+
entry.binding.set(Some(imported_binding));
999998
} else if ident.name != kw::Underscore {
1000999
self.r.dcx().span_delayed_bug(
10011000
item.span,

compiler/rustc_resolve/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,13 @@ impl<'ra> NameBindingData<'ra> {
10091009

10101010
#[derive(Default, Clone)]
10111011
struct ExternPreludeEntry<'ra> {
1012-
binding: Option<NameBinding<'ra>>,
1012+
binding: Cell<Option<NameBinding<'ra>>>,
10131013
introduced_by_item: bool,
10141014
}
10151015

10161016
impl ExternPreludeEntry<'_> {
10171017
fn is_import(&self) -> bool {
1018-
self.binding.is_some_and(|binding| binding.is_import())
1018+
self.binding.get().is_some_and(|binding| binding.is_import())
10191019
}
10201020
}
10211021

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

21712171
let norm_ident = ident.normalize_to_macros_2_0();
21722172
let binding = self.extern_prelude.get(&norm_ident).cloned().and_then(|entry| {
2173-
Some(if let Some(binding) = entry.binding {
2173+
Some(if let Some(binding) = entry.binding.get() {
21742174
if finalize {
21752175
if !entry.is_import() {
21762176
self.cstore_mut().process_path_extern(self.tcx, ident.name, ident.span);
@@ -2195,8 +2195,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
21952195
})
21962196
});
21972197

2198-
if let Some(entry) = self.extern_prelude.get_mut(&norm_ident) {
2199-
entry.binding = binding;
2198+
if let Some(entry) = self.extern_prelude.get(&norm_ident) {
2199+
entry.binding.set(binding);
22002200
}
22012201

22022202
binding

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,7 @@ impl Target {
35983598
),
35993599
"x86" => (Architecture::I386, None),
36003600
"s390x" => (Architecture::S390x, None),
3601+
"m68k" => (Architecture::M68k, None),
36013602
"mips" | "mips32r6" => (Architecture::Mips, None),
36023603
"mips64" | "mips64r6" => (
36033604
// While there are currently no builtin targets

library/core/src/panic/location.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
use crate::cmp::Ordering;
12
use crate::ffi::CStr;
23
use crate::fmt;
4+
use crate::hash::{Hash, Hasher};
35
use crate::marker::PhantomData;
46
use crate::ptr::NonNull;
57

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

49+
#[stable(feature = "panic_hooks", since = "1.10.0")]
50+
impl PartialEq for Location<'_> {
51+
fn eq(&self, other: &Self) -> bool {
52+
// Compare col / line first as they're cheaper to compare and more likely to differ,
53+
// while not impacting the result.
54+
self.col == other.col && self.line == other.line && self.file() == other.file()
55+
}
56+
}
57+
58+
#[stable(feature = "panic_hooks", since = "1.10.0")]
59+
impl Eq for Location<'_> {}
60+
61+
#[stable(feature = "panic_hooks", since = "1.10.0")]
62+
impl Ord for Location<'_> {
63+
fn cmp(&self, other: &Self) -> Ordering {
64+
self.file()
65+
.cmp(other.file())
66+
.then_with(|| self.line.cmp(&other.line))
67+
.then_with(|| self.col.cmp(&other.col))
68+
}
69+
}
70+
71+
#[stable(feature = "panic_hooks", since = "1.10.0")]
72+
impl PartialOrd for Location<'_> {
73+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
74+
Some(self.cmp(other))
75+
}
76+
}
77+
78+
#[stable(feature = "panic_hooks", since = "1.10.0")]
79+
impl Hash for Location<'_> {
80+
fn hash<H: Hasher>(&self, state: &mut H) {
81+
self.file().hash(state);
82+
self.line.hash(state);
83+
self.col.hash(state);
84+
}
85+
}
86+
4787
#[stable(feature = "panic_hooks", since = "1.10.0")]
4888
impl fmt::Debug for Location<'_> {
4989
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

library/coretests/tests/panic/location.rs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@ use core::panic::Location;
33
// Note: Some of the following tests depend on the source location,
44
// so please be careful when editing this file.
55

6+
mod file_a;
7+
mod file_b;
8+
mod file_c;
9+
10+
// A small shuffled set of locations for testing, along with their true order.
11+
const LOCATIONS: [(usize, &'static Location<'_>); 9] = [
12+
(7, file_c::two()),
13+
(0, file_a::one()),
14+
(3, file_b::one()),
15+
(5, file_b::three()),
16+
(8, file_c::three()),
17+
(6, file_c::one()),
18+
(2, file_a::three()),
19+
(4, file_b::two()),
20+
(1, file_a::two()),
21+
];
22+
623
#[test]
724
fn location_const_caller() {
825
const _CALLER_REFERENCE: &Location<'static> = Location::caller();
@@ -20,7 +37,7 @@ fn location_const_file() {
2037
fn location_const_line() {
2138
const CALLER: &Location<'static> = Location::caller();
2239
const LINE: u32 = CALLER.line();
23-
assert_eq!(LINE, 21);
40+
assert_eq!(LINE, 38);
2441
}
2542

2643
#[test]
@@ -34,6 +51,28 @@ fn location_const_column() {
3451
fn location_debug() {
3552
let f = format!("{:?}", Location::caller());
3653
assert!(f.contains(&format!("{:?}", file!())));
37-
assert!(f.contains("35"));
54+
assert!(f.contains("52"));
3855
assert!(f.contains("29"));
3956
}
57+
58+
#[test]
59+
fn location_eq() {
60+
for (i, a) in LOCATIONS {
61+
for (j, b) in LOCATIONS {
62+
if i == j {
63+
assert_eq!(a, b);
64+
} else {
65+
assert_ne!(a, b);
66+
}
67+
}
68+
}
69+
}
70+
71+
#[test]
72+
fn location_ord() {
73+
let mut locations = LOCATIONS.clone();
74+
locations.sort_by_key(|(_o, l)| **l);
75+
for (correct, (order, _l)) in locations.iter().enumerate() {
76+
assert_eq!(correct, *order);
77+
}
78+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use core::panic::Location;
2+
3+
// Used for test super::location_{ord, eq}. Must be in a dedicated file.
4+
5+
pub const fn one() -> &'static Location<'static> {
6+
Location::caller()
7+
}
8+
9+
pub const fn two() -> &'static Location<'static> {
10+
Location::caller()
11+
}
12+
13+
pub const fn three() -> &'static Location<'static> {
14+
Location::caller()
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use core::panic::Location;
2+
3+
// Used for test super::location_{ord, eq}. Must be in a dedicated file.
4+
5+
pub const fn one() -> &'static Location<'static> {
6+
Location::caller()
7+
}
8+
9+
pub const fn two() -> &'static Location<'static> {
10+
Location::caller()
11+
}
12+
13+
pub const fn three() -> &'static Location<'static> {
14+
Location::caller()
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Used for test super::location_{ord, eq}. Must be in a dedicated file.
2+
3+
// This is used for testing column ordering of Location, hence this ugly one-liner.
4+
// We must fmt skip the entire containing module or else tidy will still complain.
5+
#[rustfmt::skip]
6+
mod no_fmt {
7+
use core::panic::Location;
8+
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() }
9+
}
10+
11+
pub use no_fmt::*;

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ RUN /tmp/build-fuchsia-toolchain.sh
8181
COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/
8282
RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh
8383

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

8888
COPY scripts/freebsd-toolchain.sh /tmp/
8989
RUN /tmp/freebsd-toolchain.sh i686

src/ci/docker/host-x86_64/test-various/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ WORKDIR /
4040
COPY scripts/sccache.sh /scripts/
4141
RUN sh /scripts/sccache.sh
4242

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

4747
ENV RUST_CONFIGURE_ARGS \
4848
--musl-root-x86_64=/usr/local/x86_64-linux-musl \

0 commit comments

Comments
 (0)