From 4dec2a8f81fd42267b9006b939b8c6f0b5e73dcf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 30 Aug 2017 11:53:57 -0700 Subject: [PATCH] rustc: Fix a borrow mut error with debug assertions --- src/librustc/dep_graph/graph.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index c487fc963ca..34cb1d2a6d7 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -235,10 +235,13 @@ impl DepGraph { debug_str_gen: F) where F: FnOnce() -> String { - let mut dep_node_debug = self.data.as_ref().unwrap().dep_node_debug.borrow_mut(); + let dep_node_debug = &self.data.as_ref().unwrap().dep_node_debug; - dep_node_debug.entry(dep_node) - .or_insert_with(debug_str_gen); + if dep_node_debug.borrow().contains_key(&dep_node) { + return + } + let debug_str = debug_str_gen(); + dep_node_debug.borrow_mut().insert(dep_node, debug_str); } pub(super) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option {