Skip to content

Commit 48f89e7

Browse files
committed
Auto merge of rust-lang#139581 - matthiaskrgr:rollup-d6hph16, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#138869 (Try not to use verbatim paths in `Command::current_dir`) - rust-lang#138993 (Make `cfg_match!` a semitransparent macro) - rust-lang#139099 (Promise `array::from_fn` is generated in order of increasing indices) - rust-lang#139364 (Make the compiler suggest actual paths instead of visible paths if the visible paths are through any doc hidden path.) - rust-lang#139468 (Don't call `Span::with_parent` on the good path in `has_stashed_diagnostic`) - rust-lang#139481 (Add job summary links to post-merge report) - rust-lang#139573 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f06e5c1 + 1aa6f70 commit 48f89e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1230
-879
lines changed

Cargo.lock

+35-26
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ dependencies = [
379379
name = "cargo-miri"
380380
version = "0.1.0"
381381
dependencies = [
382-
"cargo_metadata 0.18.1",
382+
"cargo_metadata 0.19.2",
383383
"directories",
384384
"rustc-build-sysroot",
385385
"rustc_tools_util 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1012,11 +1012,11 @@ dependencies = [
10121012

10131013
[[package]]
10141014
name = "directories"
1015-
version = "5.0.1"
1015+
version = "6.0.0"
10161016
source = "registry+https://github.com/rust-lang/crates.io-index"
1017-
checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
1017+
checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d"
10181018
dependencies = [
1019-
"dirs-sys",
1019+
"dirs-sys 0.5.0",
10201020
]
10211021

10221022
[[package]]
@@ -1025,7 +1025,7 @@ version = "5.0.1"
10251025
source = "registry+https://github.com/rust-lang/crates.io-index"
10261026
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
10271027
dependencies = [
1028-
"dirs-sys",
1028+
"dirs-sys 0.4.1",
10291029
]
10301030

10311031
[[package]]
@@ -1046,18 +1046,30 @@ checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
10461046
dependencies = [
10471047
"libc",
10481048
"option-ext",
1049-
"redox_users",
1049+
"redox_users 0.4.6",
10501050
"windows-sys 0.48.0",
10511051
]
10521052

1053+
[[package]]
1054+
name = "dirs-sys"
1055+
version = "0.5.0"
1056+
source = "registry+https://github.com/rust-lang/crates.io-index"
1057+
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
1058+
dependencies = [
1059+
"libc",
1060+
"option-ext",
1061+
"redox_users 0.5.0",
1062+
"windows-sys 0.59.0",
1063+
]
1064+
10531065
[[package]]
10541066
name = "dirs-sys-next"
10551067
version = "0.1.2"
10561068
source = "registry+https://github.com/rust-lang/crates.io-index"
10571069
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
10581070
dependencies = [
10591071
"libc",
1060-
"redox_users",
1072+
"redox_users 0.4.6",
10611073
"winapi",
10621074
]
10631075

@@ -2211,20 +2223,6 @@ dependencies = [
22112223
"digest",
22122224
]
22132225

2214-
[[package]]
2215-
name = "measureme"
2216-
version = "11.0.1"
2217-
source = "registry+https://github.com/rust-lang/crates.io-index"
2218-
checksum = "dfa4a40f09af7aa6faef38285402a78847d0d72bf8827006cd2a332e1e6e4a8d"
2219-
dependencies = [
2220-
"log",
2221-
"memmap2",
2222-
"parking_lot",
2223-
"perf-event-open-sys",
2224-
"rustc-hash 1.1.0",
2225-
"smallvec",
2226-
]
2227-
22282226
[[package]]
22292227
name = "measureme"
22302228
version = "12.0.1"
@@ -2322,15 +2320,15 @@ dependencies = [
23222320
"libc",
23232321
"libffi",
23242322
"libloading",
2325-
"measureme 11.0.1",
2323+
"measureme",
23262324
"rand 0.9.0",
23272325
"regex",
23282326
"rustc_version",
23292327
"smallvec",
23302328
"tempfile",
23312329
"tikv-jemalloc-sys",
23322330
"ui_test",
2333-
"windows-sys 0.52.0",
2331+
"windows-sys 0.59.0",
23342332
]
23352333

23362334
[[package]]
@@ -3029,6 +3027,17 @@ dependencies = [
30293027
"thiserror 1.0.69",
30303028
]
30313029

3030+
[[package]]
3031+
name = "redox_users"
3032+
version = "0.5.0"
3033+
source = "registry+https://github.com/rust-lang/crates.io-index"
3034+
checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b"
3035+
dependencies = [
3036+
"getrandom 0.2.15",
3037+
"libredox",
3038+
"thiserror 2.0.12",
3039+
]
3040+
30323041
[[package]]
30333042
name = "regex"
30343043
version = "1.11.1"
@@ -3469,7 +3478,7 @@ dependencies = [
34693478
"gimli 0.31.1",
34703479
"itertools",
34713480
"libc",
3472-
"measureme 12.0.1",
3481+
"measureme",
34733482
"object 0.36.7",
34743483
"rustc-demangle",
34753484
"rustc_abi",
@@ -3584,7 +3593,7 @@ dependencies = [
35843593
"indexmap",
35853594
"jobserver",
35863595
"libc",
3587-
"measureme 12.0.1",
3596+
"measureme",
35883597
"memmap2",
35893598
"parking_lot",
35903599
"portable-atomic",
@@ -4344,7 +4353,7 @@ dependencies = [
43444353
name = "rustc_query_impl"
43454354
version = "0.0.0"
43464355
dependencies = [
4347-
"measureme 12.0.1",
4356+
"measureme",
43484357
"rustc_data_structures",
43494358
"rustc_hashes",
43504359
"rustc_hir",

compiler/rustc_errors/src/lib.rs

+44-26
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ struct DiagCtxtInner {
589589
/// add more information). All stashed diagnostics must be emitted with
590590
/// `emit_stashed_diagnostics` by the time the `DiagCtxtInner` is dropped,
591591
/// otherwise an assertion failure will occur.
592-
stashed_diagnostics: FxIndexMap<(Span, StashKey), (DiagInner, Option<ErrorGuaranteed>)>,
592+
stashed_diagnostics:
593+
FxIndexMap<StashKey, FxIndexMap<Span, (DiagInner, Option<ErrorGuaranteed>)>>,
593594

594595
future_breakage_diagnostics: Vec<DiagInner>,
595596

@@ -912,8 +913,12 @@ impl<'a> DiagCtxtHandle<'a> {
912913
// FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic
913914
// if/when we have a more robust macro-friendly replacement for `(span, key)` as a key.
914915
// See the PR for a discussion.
915-
let key = (span.with_parent(None), key);
916-
self.inner.borrow_mut().stashed_diagnostics.insert(key, (diag, guar));
916+
self.inner
917+
.borrow_mut()
918+
.stashed_diagnostics
919+
.entry(key)
920+
.or_default()
921+
.insert(span.with_parent(None), (diag, guar));
917922

918923
guar
919924
}
@@ -922,9 +927,10 @@ impl<'a> DiagCtxtHandle<'a> {
922927
/// and [`StashKey`] as the key. Panics if the found diagnostic is an
923928
/// error.
924929
pub fn steal_non_err(self, span: Span, key: StashKey) -> Option<Diag<'a, ()>> {
925-
let key = (span.with_parent(None), key);
926930
// FIXME(#120456) - is `swap_remove` correct?
927-
let (diag, guar) = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key)?;
931+
let (diag, guar) = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
932+
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
933+
)?;
928934
assert!(!diag.is_error());
929935
assert!(guar.is_none());
930936
Some(Diag::new_diagnostic(self, diag))
@@ -943,9 +949,10 @@ impl<'a> DiagCtxtHandle<'a> {
943949
where
944950
F: FnMut(&mut Diag<'_>),
945951
{
946-
let key = (span.with_parent(None), key);
947952
// FIXME(#120456) - is `swap_remove` correct?
948-
let err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
953+
let err = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
954+
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
955+
);
949956
err.map(|(err, guar)| {
950957
// The use of `::<ErrorGuaranteed>` is safe because level is `Level::Error`.
951958
assert_eq!(err.level, Error);
@@ -966,9 +973,10 @@ impl<'a> DiagCtxtHandle<'a> {
966973
key: StashKey,
967974
new_err: Diag<'_>,
968975
) -> ErrorGuaranteed {
969-
let key = (span.with_parent(None), key);
970976
// FIXME(#120456) - is `swap_remove` correct?
971-
let old_err = self.inner.borrow_mut().stashed_diagnostics.swap_remove(&key);
977+
let old_err = self.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then(
978+
|stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)),
979+
);
972980
match old_err {
973981
Some((old_err, guar)) => {
974982
assert_eq!(old_err.level, Error);
@@ -983,7 +991,14 @@ impl<'a> DiagCtxtHandle<'a> {
983991
}
984992

985993
pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool {
986-
self.inner.borrow().stashed_diagnostics.get(&(span.with_parent(None), key)).is_some()
994+
let inner = self.inner.borrow();
995+
if let Some(stashed_diagnostics) = inner.stashed_diagnostics.get(&key)
996+
&& !stashed_diagnostics.is_empty()
997+
{
998+
stashed_diagnostics.contains_key(&span.with_parent(None))
999+
} else {
1000+
false
1001+
}
9871002
}
9881003

9891004
/// Emit all stashed diagnostics.
@@ -997,7 +1012,11 @@ impl<'a> DiagCtxtHandle<'a> {
9971012
let inner = self.inner.borrow();
9981013
inner.err_guars.len()
9991014
+ inner.lint_err_guars.len()
1000-
+ inner.stashed_diagnostics.values().filter(|(_diag, guar)| guar.is_some()).count()
1015+
+ inner
1016+
.stashed_diagnostics
1017+
.values()
1018+
.map(|a| a.values().filter(|(_, guar)| guar.is_some()).count())
1019+
.sum::<usize>()
10011020
}
10021021

10031022
/// This excludes lint errors and delayed bugs. Unless absolutely
@@ -1486,16 +1505,18 @@ impl DiagCtxtInner {
14861505
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
14871506
let mut guar = None;
14881507
let has_errors = !self.err_guars.is_empty();
1489-
for (_, (diag, _guar)) in std::mem::take(&mut self.stashed_diagnostics).into_iter() {
1490-
if !diag.is_error() {
1491-
// Unless they're forced, don't flush stashed warnings when
1492-
// there are errors, to avoid causing warning overload. The
1493-
// stash would've been stolen already if it were important.
1494-
if !diag.is_force_warn() && has_errors {
1495-
continue;
1508+
for (_, stashed_diagnostics) in std::mem::take(&mut self.stashed_diagnostics).into_iter() {
1509+
for (_, (diag, _guar)) in stashed_diagnostics {
1510+
if !diag.is_error() {
1511+
// Unless they're forced, don't flush stashed warnings when
1512+
// there are errors, to avoid causing warning overload. The
1513+
// stash would've been stolen already if it were important.
1514+
if !diag.is_force_warn() && has_errors {
1515+
continue;
1516+
}
14961517
}
1518+
guar = guar.or(self.emit_diagnostic(diag, None));
14971519
}
1498-
guar = guar.or(self.emit_diagnostic(diag, None));
14991520
}
15001521
guar
15011522
}
@@ -1688,6 +1709,7 @@ impl DiagCtxtInner {
16881709
if let Some((_diag, guar)) = self
16891710
.stashed_diagnostics
16901711
.values()
1712+
.flat_map(|stashed_diagnostics| stashed_diagnostics.values())
16911713
.find(|(diag, guar)| guar.is_some() && diag.is_lint.is_none())
16921714
{
16931715
*guar
@@ -1700,13 +1722,9 @@ impl DiagCtxtInner {
17001722
fn has_errors(&self) -> Option<ErrorGuaranteed> {
17011723
self.err_guars.get(0).copied().or_else(|| self.lint_err_guars.get(0).copied()).or_else(
17021724
|| {
1703-
if let Some((_diag, guar)) =
1704-
self.stashed_diagnostics.values().find(|(_diag, guar)| guar.is_some())
1705-
{
1706-
*guar
1707-
} else {
1708-
None
1709-
}
1725+
self.stashed_diagnostics.values().find_map(|stashed_diagnostics| {
1726+
stashed_diagnostics.values().find_map(|(_, guar)| *guar)
1727+
})
17101728
},
17111729
)
17121730
}

compiler/rustc_hir_typeck/src/method/suggest.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use rustc_middle::bug;
2525
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams, simplify_type};
2626
use rustc_middle::ty::print::{
2727
PrintTraitRefExt as _, with_crate_prefix, with_forced_trimmed_paths,
28+
with_no_visible_paths_if_doc_hidden,
2829
};
2930
use rustc_middle::ty::{self, GenericArgKind, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
3031
use rustc_span::def_id::DefIdSet;
@@ -3328,15 +3329,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33283329
let path_strings = candidates.iter().map(|trait_did| {
33293330
format!(
33303331
"{prefix}{}{postfix}\n",
3331-
with_crate_prefix!(self.tcx.def_path_str(*trait_did)),
3332+
with_no_visible_paths_if_doc_hidden!(with_crate_prefix!(
3333+
self.tcx.def_path_str(*trait_did)
3334+
)),
33323335
)
33333336
});
33343337

33353338
let glob_path_strings = globs.iter().map(|trait_did| {
33363339
let parent_did = parent_map.get(trait_did).unwrap();
33373340
format!(
33383341
"{prefix}{}::*{postfix} // trait {}\n",
3339-
with_crate_prefix!(self.tcx.def_path_str(*parent_did)),
3342+
with_no_visible_paths_if_doc_hidden!(with_crate_prefix!(
3343+
self.tcx.def_path_str(*parent_did)
3344+
)),
33403345
self.tcx.item_name(*trait_did),
33413346
)
33423347
});

compiler/rustc_middle/src/ty/print/pretty.rs

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ thread_local! {
6363
static FORCE_TRIMMED_PATH: Cell<bool> = const { Cell::new(false) };
6464
static REDUCED_QUERIES: Cell<bool> = const { Cell::new(false) };
6565
static NO_VISIBLE_PATH: Cell<bool> = const { Cell::new(false) };
66+
static NO_VISIBLE_PATH_IF_DOC_HIDDEN: Cell<bool> = const { Cell::new(false) };
6667
static RTN_MODE: Cell<RtnMode> = const { Cell::new(RtnMode::ForDiagnostic) };
6768
}
6869

@@ -134,6 +135,8 @@ define_helper!(
134135
/// Prevent selection of visible paths. `Display` impl of DefId will prefer
135136
/// visible (public) reexports of types as paths.
136137
fn with_no_visible_paths(NoVisibleGuard, NO_VISIBLE_PATH);
138+
/// Prevent selection of visible paths if the paths are through a doc hidden path.
139+
fn with_no_visible_paths_if_doc_hidden(NoVisibleIfDocHiddenGuard, NO_VISIBLE_PATH_IF_DOC_HIDDEN);
137140
);
138141

139142
#[must_use]
@@ -569,6 +572,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
569572
return Ok(false);
570573
};
571574

575+
if self.tcx().is_doc_hidden(visible_parent) && with_no_visible_paths_if_doc_hidden() {
576+
return Ok(false);
577+
}
578+
572579
let actual_parent = self.tcx().opt_parent(def_id);
573580
debug!(
574581
"try_print_visible_def_path: visible_parent={:?} actual_parent={:?}",

0 commit comments

Comments
 (0)