Skip to content

Commit 8f80a8d

Browse files
Use entry API in store_path
1 parent 00d7bc7 commit 8f80a8d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/librustdoc/visit_ast.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
6666
}
6767

6868
fn store_path(&mut self, did: DefId) {
69-
// We can't use the entry API, as that keeps the mutable borrow of `self` active
70-
// when we try to use `cx`.
71-
if self.exact_paths.get(&did).is_none() {
72-
let path = def_id_to_path(self.cx.tcx, did);
73-
self.exact_paths.insert(did, path);
74-
}
69+
let tcx = self.cx.tcx;
70+
self.exact_paths.entry(did).or_insert_with(|| def_id_to_path(tcx, did));
7571
}
7672

7773
pub fn visit(mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {

0 commit comments

Comments
 (0)