diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-23 01:17:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-23 01:17:51 +0100 |
| commit | da370fe25afd1f4ddf3c4e545356eb3b011c1051 (patch) | |
| tree | 878fb1426298628526a6455d8dda0b23863a7ba1 | |
| parent | 15a0daca00de1308d6fe3bcd581917057f76c509 (diff) | |
| parent | e4330295d9bcb8ab302000eae60cd8b9a71f2d7a (diff) | |
| download | rust-da370fe25afd1f4ddf3c4e545356eb3b011c1051.tar.gz rust-da370fe25afd1f4ddf3c4e545356eb3b011c1051.zip | |
Rollup merge of #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, https://github.com/rust-lang/rust/pull/106056 `@mejrs` do you think this would have helped you figure out the problem faster?
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/Cargo.toml | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 8 |
4 files changed, 11 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock index 3d09068dbdf..6a3b2bde84f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4038,6 +4038,7 @@ dependencies = [ "rustc_ast", "rustc_attr", "rustc_data_structures", + "rustc_error_messages", "rustc_errors", "rustc_feature", "rustc_graphviz", diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 25d0e736e59..8b1ac617af8 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -381,7 +381,7 @@ impl<S: Into<String>> From<S> for DiagnosticMessage { } } -/// A workaround for "good path" ICEs when formatting types in disables lints. +/// A workaround for "good path" ICEs when formatting types in disabled lints. /// /// Delays formatting until `.into(): DiagnosticMessage` is used. pub struct DelayDm<F>(pub F); diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index cf1ab47de86..543bd56a20c 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -18,6 +18,8 @@ rustc_ast = { path = "../rustc_ast" } rustc_attr = { path = "../rustc_attr" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } +# Used for intra-doc links +rustc_error_messages = { path = "../rustc_error_messages" } rustc_feature = { path = "../rustc_feature" } rustc_graphviz = { path = "../rustc_graphviz" } rustc_hir = { path = "../rustc_hir" } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index a1d53506707..c49e75d68ad 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2883,13 +2883,19 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N /// `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. /// /// The implementation uses similar import discovery logic to that of 'use' suggestions. +/// +/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths`]. fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> { let mut map: FxHashMap<DefId, Symbol> = FxHashMap::default(); if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths { + // Trimming paths is expensive and not optimized, since we expect it to only be used for error reporting. + // // For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths` // wrapper can be used to suppress this query, in exchange for full paths being formatted. - tcx.sess.delay_good_path_bug("trimmed_def_paths constructed"); + tcx.sess.delay_good_path_bug( + "trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging", + ); } let unique_symbols_rev: &mut FxHashMap<(Namespace, Symbol), Option<DefId>> = |
