Skip to content

Commit 01e3168

Browse files
committed
librustc: De-@mut used_unsafe in the type context
1 parent 7b71ca3 commit 01e3168

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/librustc/middle/effect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ impl EffectCheckVisitor {
5656
UnsafeBlock(block_id) => {
5757
// OK, but record this.
5858
debug!("effect: recording unsafe block as used: {:?}", block_id);
59-
let _ = self.tcx.used_unsafe.insert(block_id);
59+
let mut used_unsafe = self.tcx.used_unsafe.borrow_mut();
60+
let _ = used_unsafe.get().insert(block_id);
6061
}
6162
UnsafeFn => {}
6263
}

src/librustc/middle/lint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,9 @@ fn check_unused_unsafe(cx: &Context, e: &ast::Expr) {
10011001
match e.node {
10021002
// Don't warn about generated blocks, that'll just pollute the output.
10031003
ast::ExprBlock(ref blk) => {
1004+
let used_unsafe = cx.tcx.used_unsafe.borrow();
10041005
if blk.rules == ast::UnsafeBlock(ast::UserProvided) &&
1005-
!cx.tcx.used_unsafe.contains(&blk.id) {
1006+
!used_unsafe.get().contains(&blk.id) {
10061007
cx.span_lint(unused_unsafe, blk.span,
10071008
"unnecessary `unsafe` block");
10081009
}

src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ struct ctxt_ {
348348

349349
// Set of used unsafe nodes (functions or blocks). Unsafe nodes not
350350
// present in this set can be warned about.
351-
used_unsafe: @mut HashSet<ast::NodeId>,
351+
used_unsafe: RefCell<HashSet<ast::NodeId>>,
352352

353353
// Set of nodes which mark locals as mutable which end up getting used at
354354
// some point. Local variable definitions not in this set can be warned
@@ -1004,7 +1004,7 @@ pub fn mk_ctxt(s: session::Session,
10041004
trait_impls: RefCell::new(HashMap::new()),
10051005
inherent_impls: RefCell::new(HashMap::new()),
10061006
impls: RefCell::new(HashMap::new()),
1007-
used_unsafe: @mut HashSet::new(),
1007+
used_unsafe: RefCell::new(HashSet::new()),
10081008
used_mut_nodes: @mut HashSet::new(),
10091009
impl_vtables: RefCell::new(HashMap::new()),
10101010
populated_external_types: @mut HashSet::new(),

0 commit comments

Comments
 (0)