Skip to content

Commit 70e77c7

Browse files
committed
librustc: Removed the RefCell around DefMap in check_static_recursion
1 parent 447e0a2 commit 70e77c7

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/librustc/middle/check_static_recursion.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ use syntax::{ast_util, ast_map};
1919
use syntax::visit::Visitor;
2020
use syntax::visit;
2121

22-
use std::cell::RefCell;
23-
2422
struct CheckCrateVisitor<'a, 'ast: 'a> {
2523
sess: &'a Session,
26-
def_map: &'a RefCell<DefMap>,
24+
def_map: &'a DefMap,
2725
ast_map: &'a ast_map::Map<'ast>
2826
}
2927

@@ -35,7 +33,7 @@ impl<'v, 'a, 'ast> Visitor<'v> for CheckCrateVisitor<'a, 'ast> {
3533

3634
pub fn check_crate<'ast>(sess: &Session,
3735
krate: &ast::Crate,
38-
def_map: &RefCell<DefMap>,
36+
def_map: &DefMap,
3937
ast_map: &ast_map::Map<'ast>) {
4038
let mut visitor = CheckCrateVisitor {
4139
sess: sess,
@@ -61,15 +59,15 @@ struct CheckItemRecursionVisitor<'a, 'ast: 'a> {
6159
root_it: &'a ast::Item,
6260
sess: &'a Session,
6361
ast_map: &'a ast_map::Map<'ast>,
64-
def_map: &'a RefCell<DefMap>,
62+
def_map: &'a DefMap,
6563
idstack: Vec<ast::NodeId>
6664
}
6765

6866
// Make sure a const item doesn't recursively refer to itself
6967
// FIXME: Should use the dependency graph when it's available (#1356)
7068
pub fn check_item_recursion<'a>(sess: &'a Session,
7169
ast_map: &'a ast_map::Map,
72-
def_map: &'a RefCell<DefMap>,
70+
def_map: &'a DefMap,
7371
it: &'a ast::Item) {
7472

7573
let mut visitor = CheckItemRecursionVisitor {
@@ -96,7 +94,7 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
9694
fn visit_expr(&mut self, e: &ast::Expr) {
9795
match e.node {
9896
ast::ExprPath(..) => {
99-
match self.def_map.borrow().get(&e.id).map(|d| d.base_def) {
97+
match self.def_map.get(&e.id).map(|d| d.base_def) {
10098
Some(DefStatic(def_id, _)) |
10199
Some(DefConst(def_id)) if
102100
ast_util::is_local(def_id) => {

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
617617
middle::check_loop::check_crate(&sess, krate));
618618

619619
time(time_passes, "static item recursion checking", (), |_|
620-
middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map));
620+
middle::check_static_recursion::check_crate(&sess, krate, &def_map.borrow(), &ast_map));
621621

622622
let ty_cx = ty::mk_ctxt(sess,
623623
arenas,

0 commit comments

Comments
 (0)