Skip to content

Commit ccb18f4

Browse files
committed
librustc: De-@mut the used_mut_nodes table in the type context
1 parent 5c63b1f commit ccb18f4

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,10 @@ impl<'a> CheckLoanCtxt<'a> {
357357
mc::cat_local(id) |
358358
mc::cat_arg(id) |
359359
mc::cat_self(id) => {
360-
this.tcx().used_mut_nodes.insert(id);
360+
let mut used_mut_nodes = this.tcx()
361+
.used_mut_nodes
362+
.borrow_mut();
363+
used_mut_nodes.get().insert(id);
361364
return;
362365
}
363366

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,10 @@ impl<'a> GatherLoanCtxt<'a> {
607607
608608
match *loan_path {
609609
LpVar(local_id) => {
610-
self.tcx().used_mut_nodes.insert(local_id);
610+
let mut used_mut_nodes = self.tcx()
611+
.used_mut_nodes
612+
.borrow_mut();
613+
used_mut_nodes.get().insert(local_id);
611614
}
612615
LpExtend(base, mc::McInherited, _) => {
613616
self.mark_loan_path_as_mutated(base);

src/librustc/middle/lint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ fn check_unused_mut_pat(cx: &Context, p: &ast::Pat) {
10381038
}
10391039
};
10401040

1041-
if !initial_underscore && !cx.tcx.used_mut_nodes.contains(&p.id) {
1041+
let used_mut_nodes = cx.tcx.used_mut_nodes.borrow();
1042+
if !initial_underscore && !used_mut_nodes.get().contains(&p.id) {
10421043
cx.span_lint(unused_mut, p.span,
10431044
"variable does not need to be mutable");
10441045
}

src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ struct ctxt_ {
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
355355
// about.
356-
used_mut_nodes: @mut HashSet<ast::NodeId>,
356+
used_mut_nodes: RefCell<HashSet<ast::NodeId>>,
357357

358358
// vtable resolution information for impl declarations
359359
impl_vtables: typeck::impl_vtable_map,
@@ -1005,7 +1005,7 @@ pub fn mk_ctxt(s: session::Session,
10051005
inherent_impls: RefCell::new(HashMap::new()),
10061006
impls: RefCell::new(HashMap::new()),
10071007
used_unsafe: RefCell::new(HashSet::new()),
1008-
used_mut_nodes: @mut HashSet::new(),
1008+
used_mut_nodes: RefCell::new(HashSet::new()),
10091009
impl_vtables: RefCell::new(HashMap::new()),
10101010
populated_external_types: @mut HashSet::new(),
10111011
populated_external_traits: @mut HashSet::new(),

0 commit comments

Comments
 (0)