@@ -15,7 +15,6 @@ use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
1515use rustc_hir:: def_id:: { DefIdMap , DefIdSet , ModDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
1616use rustc_hir:: definitions:: { DefKey , DefPathDataName } ;
1717use rustc_hir:: LangItem ;
18- use rustc_session:: config:: TrimmedDefPaths ;
1918use rustc_session:: cstore:: { ExternCrate , ExternCrateSource } ;
2019use rustc_session:: Limit ;
2120use rustc_span:: symbol:: { kw, Ident , Symbol } ;
@@ -369,7 +368,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
369368 return Ok ( true ) ;
370369 }
371370 if self . tcx ( ) . sess . opts . unstable_opts . trim_diagnostic_paths
372- && ! matches ! ( self . tcx( ) . sess. opts. trimmed_def_paths, TrimmedDefPaths :: Never )
371+ && self . tcx ( ) . sess . opts . trimmed_def_paths
373372 && !with_no_trimmed_paths ( )
374373 && !with_crate_prefix ( )
375374 && let Some ( symbol) = self . tcx ( ) . trimmed_def_paths ( ( ) ) . get ( & def_id)
@@ -3073,18 +3072,16 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
30733072/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths!`].
30743073// this is pub to be able to intra-doc-link it
30753074pub fn trimmed_def_paths ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> DefIdMap < Symbol > {
3076- let mut map : DefIdMap < Symbol > = Default :: default ( ) ;
3075+ assert ! ( tcx . sess . opts . trimmed_def_paths ) ;
30773076
3078- if let TrimmedDefPaths :: GoodPath = tcx. sess . opts . trimmed_def_paths {
3079- // Trimming paths is expensive and not optimized, since we expect it to only be used for
3080- // error reporting.
3081- //
3082- // For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
3083- // wrapper can be used to suppress this query, in exchange for full paths being formatted.
3084- tcx. sess . good_path_delayed_bug (
3085- "trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging" ,
3086- ) ;
3087- }
3077+ // Trimming paths is expensive and not optimized, since we expect it to only be used for error
3078+ // reporting.
3079+ //
3080+ // For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
3081+ // wrapper can be used to suppress this query, in exchange for full paths being formatted.
3082+ tcx. sess . good_path_delayed_bug (
3083+ "trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging" ,
3084+ ) ;
30883085
30893086 // Once constructed, unique namespace+symbol pairs will have a `Some(_)` entry, while
30903087 // non-unique pairs will have a `None` entry.
@@ -3118,6 +3115,7 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
31183115 } ) ;
31193116
31203117 // Put the symbol from all the unique namespace+symbol pairs into `map`.
3118+ let mut map: DefIdMap < Symbol > = Default :: default ( ) ;
31213119 for ( ( _, symbol) , opt_def_id) in unique_symbols_rev. drain ( ) {
31223120 use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
31233121
0 commit comments