Skip to content

Commit da370fe

Browse files
authored
Rollup merge of rust-lang#106057 - jyn514:trimmed-def-paths-ice, r=compiler-errors
Give a more helpful error for "trimmed_def_paths constructed" cc https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/ice.20debugging/near/315928294, rust-lang#106056 `@mejrs` do you think this would have helped you figure out the problem faster?
2 parents 15a0dac + e433029 commit da370fe

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,7 @@ dependencies = [
40384038
"rustc_ast",
40394039
"rustc_attr",
40404040
"rustc_data_structures",
4041+
"rustc_error_messages",
40414042
"rustc_errors",
40424043
"rustc_feature",
40434044
"rustc_graphviz",

compiler/rustc_error_messages/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<S: Into<String>> From<S> for DiagnosticMessage {
381381
}
382382
}
383383

384-
/// A workaround for "good path" ICEs when formatting types in disables lints.
384+
/// A workaround for "good path" ICEs when formatting types in disabled lints.
385385
///
386386
/// Delays formatting until `.into(): DiagnosticMessage` is used.
387387
pub struct DelayDm<F>(pub F);

compiler/rustc_middle/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ rustc_ast = { path = "../rustc_ast" }
1818
rustc_attr = { path = "../rustc_attr" }
1919
rustc_data_structures = { path = "../rustc_data_structures" }
2020
rustc_errors = { path = "../rustc_errors" }
21+
# Used for intra-doc links
22+
rustc_error_messages = { path = "../rustc_error_messages" }
2123
rustc_feature = { path = "../rustc_feature" }
2224
rustc_graphviz = { path = "../rustc_graphviz" }
2325
rustc_hir = { path = "../rustc_hir" }

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -2883,13 +2883,19 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
28832883
/// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere.
28842884
///
28852885
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
2886+
///
2887+
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths`].
28862888
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
28872889
let mut map: FxHashMap<DefId, Symbol> = FxHashMap::default();
28882890

28892891
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
2892+
// Trimming paths is expensive and not optimized, since we expect it to only be used for error reporting.
2893+
//
28902894
// For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
28912895
// wrapper can be used to suppress this query, in exchange for full paths being formatted.
2892-
tcx.sess.delay_good_path_bug("trimmed_def_paths constructed");
2896+
tcx.sess.delay_good_path_bug(
2897+
"trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging",
2898+
);
28932899
}
28942900

28952901
let unique_symbols_rev: &mut FxHashMap<(Namespace, Symbol), Option<DefId>> =

0 commit comments

Comments
 (0)