From 8f80a8d7d564b17fe3831c4b5e5404d93a013bf5 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 10 Aug 2019 13:52:45 -0400 Subject: [PATCH] Use entry API in store_path --- src/librustdoc/visit_ast.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 5fad9038104..35b6d9972da 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -66,12 +66,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { } fn store_path(&mut self, did: DefId) { - // We can't use the entry API, as that keeps the mutable borrow of `self` active - // when we try to use `cx`. - if self.exact_paths.get(&did).is_none() { - let path = def_id_to_path(self.cx.tcx, did); - self.exact_paths.insert(did, path); - } + let tcx = self.cx.tcx; + self.exact_paths.entry(did).or_insert_with(|| def_id_to_path(tcx, did)); } pub fn visit(mut self, krate: &'tcx hir::Crate) -> Module<'tcx> {