Skip to content

Commit 7c10378

Browse files
committed
Auto merge of #142234 - matthiaskrgr:rollup-kg5wibu, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #141751 (Remap compiler vs non-compiler sources differently (bootstrap side)) - #142160 (Only allow `bootstrap` cfg in rustc & related) - #142191 (early return in trait detection for non-trait item) - #142211 (Do not checkout GCC submodule for the tidy job) - #142218 (CI: rfl: move job forward to Linux v6.16-rc1) - #142224 (Avoid a gratuitous 10s wait in a stress test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b6685d7 + bf17f13 commit 7c10378

File tree

12 files changed

+152
-45
lines changed

12 files changed

+152
-45
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,7 +3494,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34943494
continue;
34953495
}
34963496
trait_in_other_version_found = self
3497-
.detect_and_explain_multiple_crate_versions(
3497+
.detect_and_explain_multiple_crate_versions_of_trait_item(
34983498
err,
34993499
pick.item.def_id,
35003500
rcvr.hir_id,
@@ -3701,12 +3701,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
37013701
// same crate.
37023702

37033703
let rcvr_ty = self.node_ty_opt(ty.hir_id);
3704-
trait_in_other_version_found = self.detect_and_explain_multiple_crate_versions(
3705-
err,
3706-
assoc.def_id,
3707-
ty.hir_id,
3708-
rcvr_ty,
3709-
);
3704+
trait_in_other_version_found = self
3705+
.detect_and_explain_multiple_crate_versions_of_trait_item(
3706+
err,
3707+
assoc.def_id,
3708+
ty.hir_id,
3709+
rcvr_ty,
3710+
);
37103711
}
37113712
if !trait_in_other_version_found
37123713
&& self.suggest_valid_traits(err, item_name, valid_out_of_scope_traits, true)
@@ -4098,7 +4099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
40984099
}
40994100
}
41004101

4101-
fn detect_and_explain_multiple_crate_versions(
4102+
fn detect_and_explain_multiple_crate_versions_of_trait_item(
41024103
&self,
41034104
err: &mut Diag<'_>,
41044105
item_def_id: DefId,
@@ -4111,6 +4112,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
41114112
return false;
41124113
}
41134114
let trait_def_id = self.tcx.parent(item_def_id);
4115+
if !self.tcx.is_trait(trait_def_id) {
4116+
return false;
4117+
}
41144118
let krate = self.tcx.crate_name(trait_def_id.krate);
41154119
let name = self.tcx.item_name(trait_def_id);
41164120
let candidates: Vec<_> = traits

library/core/src/iter/sources/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/// ```
2121
#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")]
2222
#[allow_internal_unstable(coroutines, iter_from_coroutine)]
23-
#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
23+
#[rustc_builtin_macro]
2424
pub macro iter($($t:tt)*) {
2525
/* compiler-builtin */
2626
}

library/std/tests/sync/mpmc.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ fn oneshot_single_thread_recv_timeout() {
462462
#[test]
463463
fn stress_recv_timeout_two_threads() {
464464
let (tx, rx) = channel();
465-
let stress = stress_factor() + 100;
466-
let timeout = Duration::from_millis(100);
465+
let stress = stress_factor() + 50;
466+
let timeout = Duration::from_millis(5);
467467

468468
thread::spawn(move || {
469469
for i in 0..stress {
@@ -475,18 +475,23 @@ fn stress_recv_timeout_two_threads() {
475475
});
476476

477477
let mut recv_count = 0;
478+
let mut got_timeout = false;
478479
loop {
479480
match rx.recv_timeout(timeout) {
480481
Ok(n) => {
481482
assert_eq!(n, 1usize);
482483
recv_count += 1;
483484
}
484-
Err(RecvTimeoutError::Timeout) => continue,
485+
Err(RecvTimeoutError::Timeout) => {
486+
got_timeout = true;
487+
continue;
488+
}
485489
Err(RecvTimeoutError::Disconnected) => break,
486490
}
487491
}
488492

489493
assert_eq!(recv_count, stress);
494+
assert!(got_timeout);
490495
}
491496

492497
#[test]

library/std/tests/sync/mpsc.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ fn oneshot_single_thread_recv_timeout() {
425425
#[test]
426426
fn stress_recv_timeout_two_threads() {
427427
let (tx, rx) = channel();
428-
let stress = stress_factor() + 100;
429-
let timeout = Duration::from_millis(100);
428+
let stress = stress_factor() + 50;
429+
let timeout = Duration::from_millis(5);
430430

431431
thread::spawn(move || {
432432
for i in 0..stress {
@@ -438,18 +438,23 @@ fn stress_recv_timeout_two_threads() {
438438
});
439439

440440
let mut recv_count = 0;
441+
let mut got_timeout = false;
441442
loop {
442443
match rx.recv_timeout(timeout) {
443444
Ok(n) => {
444445
assert_eq!(n, 1usize);
445446
recv_count += 1;
446447
}
447-
Err(RecvTimeoutError::Timeout) => continue,
448+
Err(RecvTimeoutError::Timeout) => {
449+
got_timeout = true;
450+
continue;
451+
}
448452
Err(RecvTimeoutError::Disconnected) => break,
449453
}
450454
}
451455

452456
assert_eq!(recv_count, stress);
457+
assert!(got_timeout);
453458
}
454459

455460
#[test]

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::utils::build_stamp;
1111
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_args, linker_flags};
1212
use crate::{
1313
BootstrapCommand, CLang, Compiler, Config, DocTests, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
14-
TargetSelection, command, prepare_behaviour_dump_dir, t,
14+
RemapScheme, TargetSelection, command, prepare_behaviour_dump_dir, t,
1515
};
1616

1717
/// Represents flag values in `String` form with whitespace delimiter to pass it to the compiler
@@ -636,6 +636,15 @@ impl Builder<'_> {
636636
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
637637
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
638638
rustflags.arg(&check_cfg_arg(name, *values));
639+
640+
if *name == "bootstrap" {
641+
// Cargo doesn't pass RUSTFLAGS to proc_macros:
642+
// https://github.com/rust-lang/cargo/issues/4423
643+
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
644+
// We also declare that the flag is expected, which we need to do to not
645+
// get warnings about it being unexpected.
646+
hostflags.arg(check_cfg_arg(name, *values));
647+
}
639648
}
640649
}
641650

@@ -645,13 +654,6 @@ impl Builder<'_> {
645654
if stage == 0 {
646655
hostflags.arg("--cfg=bootstrap");
647656
}
648-
// Cargo doesn't pass RUSTFLAGS to proc_macros:
649-
// https://github.com/rust-lang/cargo/issues/4423
650-
// Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
651-
// We also declare that the flag is expected, which we need to do to not
652-
// get warnings about it being unexpected.
653-
hostflags.arg("-Zunstable-options");
654-
hostflags.arg("--check-cfg=cfg(bootstrap)");
655657

656658
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
657659
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
@@ -920,13 +922,46 @@ impl Builder<'_> {
920922
hostflags.arg(format!("-Ctarget-feature={sign}crt-static"));
921923
}
922924

923-
if let Some(map_to) = self.build.debuginfo_map_to(GitRepo::Rustc) {
924-
let map = format!("{}={}", self.build.src.display(), map_to);
925-
cargo.env("RUSTC_DEBUGINFO_MAP", map);
925+
// `rustc` needs to know the remapping scheme, in order to know how to reverse it (unremap)
926+
// later. Two env vars are set and made available to the compiler
927+
//
928+
// - `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR`: `rust-src` remap scheme (`NonCompiler`)
929+
// - `CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR`: `rustc-dev` remap scheme (`Compiler`)
930+
//
931+
// Keep this scheme in sync with `rustc_metadata::rmeta::decoder`'s
932+
// `try_to_translate_virtual_to_real`.
933+
//
934+
// `RUSTC_DEBUGINFO_MAP` is used to pass through to the underlying rustc
935+
// `--remap-path-prefix`.
936+
match mode {
937+
Mode::Rustc | Mode::Codegen => {
938+
if let Some(ref map_to) =
939+
self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler)
940+
{
941+
cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to);
942+
}
926943

927-
// `rustc` needs to know the virtual `/rustc/$hash` we're mapping to,
928-
// in order to opportunistically reverse it later.
929-
cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to);
944+
if let Some(ref map_to) =
945+
self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::Compiler)
946+
{
947+
// When building compiler sources, we want to apply the compiler remap scheme.
948+
cargo.env(
949+
"RUSTC_DEBUGINFO_MAP",
950+
format!("{}={}", self.build.src.display(), map_to),
951+
);
952+
cargo.env("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR", map_to);
953+
}
954+
}
955+
Mode::Std | Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd => {
956+
if let Some(ref map_to) =
957+
self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler)
958+
{
959+
cargo.env(
960+
"RUSTC_DEBUGINFO_MAP",
961+
format!("{}={}", self.build.src.display(), map_to),
962+
);
963+
}
964+
}
930965
}
931966

932967
if self.config.rust_remap_debuginfo {

src/bootstrap/src/lib.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
8181
/// (Mode restriction, config name, config values (if any))
8282
#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above.
8383
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
84-
(None, "bootstrap", None),
84+
(Some(Mode::Rustc), "bootstrap", None),
85+
(Some(Mode::Codegen), "bootstrap", None),
86+
(Some(Mode::ToolRustc), "bootstrap", None),
87+
(Some(Mode::ToolStd), "bootstrap", None),
8588
(Some(Mode::Rustc), "llvm_enzyme", None),
8689
(Some(Mode::Codegen), "llvm_enzyme", None),
8790
(Some(Mode::ToolRustc), "llvm_enzyme", None),
@@ -272,6 +275,16 @@ impl Mode {
272275
}
273276
}
274277

278+
/// When `rust.rust_remap_debuginfo` is requested, the compiler needs to know how to
279+
/// opportunistically unremap compiler vs non-compiler sources. We use two schemes,
280+
/// [`RemapScheme::Compiler`] and [`RemapScheme::NonCompiler`].
281+
pub enum RemapScheme {
282+
/// The [`RemapScheme::Compiler`] scheme will remap to `/rustc-dev/{hash}`.
283+
Compiler,
284+
/// The [`RemapScheme::NonCompiler`] scheme will remap to `/rustc/{hash}`.
285+
NonCompiler,
286+
}
287+
275288
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
276289
pub enum CLang {
277290
C,
@@ -1217,15 +1230,32 @@ Executed at: {executed_at}"#,
12171230
})
12181231
}
12191232

1220-
fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
1233+
fn debuginfo_map_to(&self, which: GitRepo, remap_scheme: RemapScheme) -> Option<String> {
12211234
if !self.config.rust_remap_debuginfo {
12221235
return None;
12231236
}
12241237

12251238
match which {
12261239
GitRepo::Rustc => {
12271240
let sha = self.rust_sha().unwrap_or(&self.version);
1228-
Some(format!("/rustc/{sha}"))
1241+
1242+
match remap_scheme {
1243+
RemapScheme::Compiler => {
1244+
// For compiler sources, remap via `/rustc-dev/{sha}` to allow
1245+
// distinguishing between compiler sources vs library sources, since
1246+
// `rustc-dev` dist component places them under
1247+
// `$sysroot/lib/rustlib/rustc-src/rust` as opposed to `rust-src`'s
1248+
// `$sysroot/lib/rustlib/src/rust`.
1249+
//
1250+
// Keep this scheme in sync with `rustc_metadata::rmeta::decoder`'s
1251+
// `try_to_translate_virtual_to_real`.
1252+
Some(format!("/rustc-dev/{sha}"))
1253+
}
1254+
RemapScheme::NonCompiler => {
1255+
// For non-compiler sources, use `/rustc/{sha}` remapping scheme.
1256+
Some(format!("/rustc/{sha}"))
1257+
}
1258+
}
12291259
}
12301260
GitRepo::Llvm => Some(String::from("/rustc/llvm")),
12311261
}
@@ -1292,7 +1322,7 @@ Executed at: {executed_at}"#,
12921322
base.push("-fno-omit-frame-pointer".into());
12931323
}
12941324

1295-
if let Some(map_to) = self.debuginfo_map_to(which) {
1325+
if let Some(map_to) = self.debuginfo_map_to(which, RemapScheme::NonCompiler) {
12961326
let map = format!("{}={}", self.src.display(), map_to);
12971327
let cc = self.cc(target);
12981328
if cc.ends_with("clang") || cc.ends_with("gcc") {

src/ci/docker/scripts/rfl-build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
set -euo pipefail
44

5-
# https://github.com/Rust-for-Linux/linux/issues/1163
6-
LINUX_VERSION=3ca02fc80cc4fdac63aaa6796642f1e07be591d6
5+
LINUX_VERSION=v6.16-rc1
76

87
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
98
../x.py build --stage 2 library rustdoc clippy rustfmt

src/ci/github-actions/jobs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ pr:
129129
- name: mingw-check-tidy
130130
continue_on_error: true
131131
free_disk: false
132+
env:
133+
# This submodule is expensive to checkout, and it should not be needed for
134+
# tidy. This speeds up the PR CI job by ~1 minute.
135+
SKIP_SUBMODULES: src/gcc
132136
<<: *job-linux-4c
133137
- name: x86_64-gnu-llvm-19
134138
env:

src/ci/scripts/checkout-submodules.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ for i in ${!modules[@]}; do
5555
bg_pids[${i}]=$!
5656
continue
5757
else
58+
# Submodule paths contained in SKIP_SUBMODULES (comma-separated list) will not be
59+
# checked out.
60+
if [ -z "${SKIP_SUBMODULES:-}" ] || [[ ! ",$SKIP_SUBMODULES," = *",$module,"* ]]; then
5861
use_git="$use_git $module"
62+
fi
5963
fi
6064
done
6165
retry sh -c "git submodule deinit -f $use_git && \

tests/crashes/135863.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// issue#135863
2+
3+
struct A;
4+
5+
impl A {
6+
fn len(self: &&A) {}
7+
}
8+
9+
fn main() {
10+
A.len();
11+
//~^ ERROR: no method named `len` found for struct `A` in the current scope
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0599]: no method named `len` found for struct `A` in the current scope
2+
--> $DIR/double-reference-ty-in-self-ty.rs:10:7
3+
|
4+
LL | struct A;
5+
| -------- method `len` not found for this struct
6+
...
7+
LL | fn len(self: &&A) {}
8+
| --- the method is available for `&A` here
9+
...
10+
LL | A.len();
11+
| ^^^ method not found in `A`
12+
|
13+
= help: items from traits can only be used if the trait is implemented and in scope
14+
= note: the following trait defines an item `len`, perhaps you need to implement it:
15+
candidate #1: `ExactSizeIterator`
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0599`.

0 commit comments

Comments
 (0)