about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-08-10 13:52:45 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-08-11 10:36:46 -0400
commit8f80a8d7d564b17fe3831c4b5e5404d93a013bf5 (patch)
tree5f0ba2fe69f374d11befe40c7582f2255e1d17ab
parent00d7bc7688c31e22e3f27d3e225087b1f8ea694b (diff)
downloadrust-8f80a8d7d564b17fe3831c4b5e5404d93a013bf5.tar.gz
rust-8f80a8d7d564b17fe3831c4b5e5404d93a013bf5.zip
Use entry API in store_path
-rw-r--r--src/librustdoc/visit_ast.rs8
1 files 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> {