Skip to content

Commit 4efddb1

Browse files
committed
Add some helpful comments in trimmed_def_paths.
To explain things that took me a minute to work out.
1 parent d78329b commit 4efddb1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3083,7 +3083,8 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
30833083
let mut map: DefIdMap<Symbol> = Default::default();
30843084

30853085
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
3086-
// Trimming paths is expensive and not optimized, since we expect it to only be used for error reporting.
3086+
// Trimming paths is expensive and not optimized, since we expect it to only be used for
3087+
// error reporting.
30873088
//
30883089
// For good paths causing this bug, the `rustc_middle::ty::print::with_no_trimmed_paths`
30893090
// wrapper can be used to suppress this query, in exchange for full paths being formatted.
@@ -3092,6 +3093,8 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
30923093
);
30933094
}
30943095

3096+
// Once constructed, unique namespace+symbol pairs will have a `Some(_)` entry, while
3097+
// non-unique pairs will have a `None` entry.
30953098
let unique_symbols_rev: &mut FxHashMap<(Namespace, Symbol), Option<DefId>> =
30963099
&mut FxHashMap::default();
30973100

@@ -3121,6 +3124,7 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
31213124
}
31223125
});
31233126

3127+
// Put the symbol from all the unique namespace+symbol pairs into `map`.
31243128
for ((_, symbol), opt_def_id) in unique_symbols_rev.drain() {
31253129
use std::collections::hash_map::Entry::{Occupied, Vacant};
31263130

0 commit comments

Comments
 (0)