diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index aff37264f24e..d4c566d4a604 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -56,7 +56,8 @@ impl EffectCheckVisitor { UnsafeBlock(block_id) => { // OK, but record this. debug!("effect: recording unsafe block as used: {:?}", block_id); - let _ = self.tcx.used_unsafe.insert(block_id); + let mut used_unsafe = self.tcx.used_unsafe.borrow_mut(); + let _ = used_unsafe.get().insert(block_id); } UnsafeFn => {} } diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 72140d333730..6a5ad369c5ab 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -1001,8 +1001,9 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) { match e.node { // Don't warn about generated blocks, that'll just pollute the output. ast::ExprBlock(ref blk) => { + let used_unsafe = cx.tcx.used_unsafe.borrow(); if blk.rules == ast::UnsafeBlock(ast::UserProvided) && - !cx.tcx.used_unsafe.contains(&blk.id) { + !used_unsafe.get().contains(&blk.id) { cx.span_lint(unused_unsafe, blk.span, "unnecessary `unsafe` block"); } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 9166f25ea5da..b86fa8ade778 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -348,7 +348,7 @@ struct ctxt_ { // Set of used unsafe nodes (functions or blocks). Unsafe nodes not // present in this set can be warned about. - used_unsafe: @mut HashSet, + used_unsafe: RefCell>, // Set of nodes which mark locals as mutable which end up getting used at // some point. Local variable definitions not in this set can be warned @@ -1004,7 +1004,7 @@ pub fn mk_ctxt(s: session::Session, trait_impls: RefCell::new(HashMap::new()), inherent_impls: RefCell::new(HashMap::new()), impls: RefCell::new(HashMap::new()), - used_unsafe: @mut HashSet::new(), + used_unsafe: RefCell::new(HashSet::new()), used_mut_nodes: @mut HashSet::new(), impl_vtables: RefCell::new(HashMap::new()), populated_external_types: @mut HashSet::new(),