Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov
diagnostics: shorten paths of unique symbols This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code. The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors. ----- If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable from anywhere.
This commit is contained in:
commit
af3c6e733a
1316 changed files with 4820 additions and 4497 deletions
|
@ -32,7 +32,7 @@ use rustc_save_analysis as save;
|
|||
use rustc_save_analysis::DumpHandler;
|
||||
use rustc_serialize::json::{self, ToJson};
|
||||
use rustc_session::config::nightly_options;
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest};
|
||||
use rustc_session::config::{ErrorOutputType, Input, OutputType, PrintRequest, TrimmedDefPaths};
|
||||
use rustc_session::getopts;
|
||||
use rustc_session::lint::{Lint, LintId};
|
||||
use rustc_session::{config, DiagnosticOutput, Session};
|
||||
|
@ -126,6 +126,7 @@ impl Callbacks for TimePassesCallbacks {
|
|||
// time because it will mess up the --prints output. See #64339.
|
||||
self.time_passes = config.opts.prints.is_empty()
|
||||
&& (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time);
|
||||
config.opts.trimmed_def_paths = TrimmedDefPaths::GoodPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue