librustc: De-@mut creader::Env

This commit is contained in:
Patrick Walton 2013-12-21 16:46:55 -08:00
parent 07279011b8
commit b9568cdf36

View File

@ -33,22 +33,29 @@ pub fn read_crates(sess: Session,
crate: &ast::Crate,
os: loader::Os,
intr: @ident_interner) {
let e = @mut Env {
let mut e = Env {
sess: sess,
os: os,
crate_cache: @mut ~[],
next_crate_num: 1,
intr: intr
};
let mut v = ReadCrateVisitor{ e:e };
visit_crate(e, crate);
visit::walk_crate(&mut v, crate, ());
visit_crate(&e, crate);
{
let mut v = ReadCrateVisitor {
e: &mut e
};
visit::walk_crate(&mut v, crate, ());
}
dump_crates(*e.crate_cache);
warn_if_multiple_versions(e, sess.diagnostic(), *e.crate_cache);
warn_if_multiple_versions(&mut e, sess.diagnostic(), *e.crate_cache);
}
struct ReadCrateVisitor { e:@mut Env }
impl visit::Visitor<()> for ReadCrateVisitor {
struct ReadCrateVisitor<'a> {
e: &'a mut Env,
}
impl<'a> visit::Visitor<()> for ReadCrateVisitor<'a> {
fn visit_view_item(&mut self, a:&ast::view_item, _:()) {
visit_view_item(self.e, a);
visit::walk_view_item(self, a, ());
@ -76,7 +83,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
}
}
fn warn_if_multiple_versions(e: @mut Env,
fn warn_if_multiple_versions(e: &mut Env,
diag: @mut span_handler,
crate_cache: &[cache_entry]) {
if crate_cache.len() != 0u {
@ -121,7 +128,7 @@ fn visit_crate(e: &Env, c: &ast::Crate) {
}
}
fn visit_view_item(e: @mut Env, i: &ast::view_item) {
fn visit_view_item(e: &mut Env, i: &ast::view_item) {
match i.node {
ast::view_item_extern_mod(ident, path_opt, _, id) => {
let ident = token::ident_to_str(&ident);
@ -248,7 +255,7 @@ fn existing_match(e: &Env, name: @str, version: @str, hash: &str) -> Option<ast:
None
}
fn resolve_crate(e: @mut Env,
fn resolve_crate(e: &mut Env,
ident: @str,
name: @str,
version: @str,
@ -311,7 +318,7 @@ fn resolve_crate(e: @mut Env,
}
// Go through the crate metadata and load any crates that it references
fn resolve_crate_deps(e: @mut Env, cdata: &[u8]) -> cstore::cnum_map {
fn resolve_crate_deps(e: &mut Env, cdata: &[u8]) -> cstore::cnum_map {
debug!("resolving deps of external crate");
// The map from crate numbers in the crate we're resolving to local crate
// numbers