From b9568cdf36661f8cfee72ee15a581c450c5596b8 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 21 Dec 2013 16:46:55 -0800 Subject: [PATCH] librustc: De-`@mut` `creader::Env` --- src/librustc/metadata/creader.rs | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index efa28b9b6bd..64d4d5939d0 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -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 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