From 1334f2ceaea5e012bba02b6afc0371bf92e976e7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sat, 22 Aug 2015 13:01:54 +0530 Subject: [PATCH] Fix doubleborrow of refcell in consts.rs --- src/consts.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/consts.rs b/src/consts.rs index 70d5ff4bc..e54ac77b5 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -330,8 +330,13 @@ impl<'c, 'cc> ConstEvalContext<'c, 'cc> { /// lookup a possibly constant expression from a ExprPath fn fetch_path(&mut self, e: &Expr) -> Option { if let Some(lcx) = self.lcx { + let mut maybe_id = None; if let Some(&PathResolution { base_def: DefConst(id), ..}) = lcx.tcx.def_map.borrow().get(&e.id) { + maybe_id = Some(id); + } + // separate if lets to avoid doubleborrowing the defmap + if let Some(id) = maybe_id { if let Some(const_expr) = lookup_const_by_id(lcx.tcx, id, None) { let ret = self.expr(const_expr); if ret.is_some() {