librustc: De-@mut lints in the session

This commit is contained in:
Patrick Walton 2013-12-20 20:04:17 -08:00
parent 43aee50798
commit 417378554c
3 changed files with 12 additions and 6 deletions

View File

@ -26,6 +26,7 @@
use util::common::time;
use util::ppaux;
use std::cell::RefCell;
use std::hashmap::{HashMap,HashSet};
use std::io;
use std::io::fs;
@ -872,7 +873,7 @@ pub fn build_session_(sopts: @session::options,
filesearch: filesearch,
building_library: @mut false,
working_dir: os::getcwd(),
lints: @mut HashMap::new(),
lints: RefCell::new(HashMap::new()),
node_id: @mut 1,
outputs: @mut ~[],
}

View File

@ -28,6 +28,7 @@
use syntax::parse::token;
use syntax;
use std::cell::RefCell;
use std::hashmap::{HashMap,HashSet};
pub struct config {
@ -211,7 +212,8 @@ pub struct Session_ {
filesearch: @filesearch::FileSearch,
building_library: @mut bool,
working_dir: Path,
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
lints: RefCell<HashMap<ast::NodeId,
~[(lint::lint, codemap::Span, ~str)]>>,
node_id: @mut ast::NodeId,
outputs: @mut ~[OutputStyle],
}
@ -269,11 +271,12 @@ pub fn add_lint(&self,
id: ast::NodeId,
sp: Span,
msg: ~str) {
match self.lints.find_mut(&id) {
let mut lints = self.lints.borrow_mut();
match lints.get().find_mut(&id) {
Some(arr) => { arr.push((lint, sp, msg)); return; }
None => {}
}
self.lints.insert(id, ~[(lint, sp, msg)]);
lints.get().insert(id, ~[(lint, sp, msg)]);
}
pub fn next_node_id(&self) -> ast::NodeId {
self.reserve_node_ids(1)

View File

@ -1425,7 +1425,8 @@ fn visit_ty(&mut self, _t: &ast::Ty, _: ()) {}
impl<'a> IdVisitingOperation for Context<'a> {
fn visit_id(&self, id: ast::NodeId) {
match self.tcx.sess.lints.pop(&id) {
let mut lints = self.tcx.sess.lints.borrow_mut();
match lints.get().pop(&id) {
None => {}
Some(l) => {
for (lint, span, msg) in l.move_iter() {
@ -1477,7 +1478,8 @@ pub fn check_crate(tcx: ty::ctxt,
// If we missed any lints added to the session, then there's a bug somewhere
// in the iteration code.
for (id, v) in tcx.sess.lints.iter() {
let lints = tcx.sess.lints.borrow();
for (id, v) in lints.get().iter() {
for &(lint, span, ref msg) in v.iter() {
tcx.sess.span_bug(span, format!("unprocessed lint {:?} at {}: {}",
lint,