Skip to content

Remove many shared pointers #7429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ pub fn compile_rest(sess: Session,

let time_passes = sess.time_passes();

let mut crate_opt = curr;
let mut crate = curr.unwrap();

if phases.from == cu_parse || phases.from == cu_everything {

*sess.building_library = session::building_library(
sess.opts.crate_type, crate_opt.unwrap(), sess.opts.test);
sess.opts.crate_type, crate, sess.opts.test);

// strip before expansion to allow macros to depend on
// configuration variables e.g/ in
Expand All @@ -195,27 +195,25 @@ pub fn compile_rest(sess: Session,
// mod bar { macro_rules! baz!(() => {{}}) }
//
// baz! should not use this definition unless foo is enabled.
crate_opt = Some(time(time_passes, ~"configuration 1", ||
front::config::strip_unconfigured_items(crate_opt.unwrap())));
crate = time(time_passes, ~"configuration 1", ||
front::config::strip_unconfigured_items(crate));

crate_opt = Some(time(time_passes, ~"expansion", ||
crate = time(time_passes, ~"expansion", ||
syntax::ext::expand::expand_crate(sess.parse_sess, copy cfg,
crate_opt.unwrap())));
crate));

// strip again, in case expansion added anything with a #[cfg].
crate_opt = Some(time(time_passes, ~"configuration 2", ||
front::config::strip_unconfigured_items(crate_opt.unwrap())));
crate = time(time_passes, ~"configuration 2", ||
front::config::strip_unconfigured_items(crate));

crate_opt = Some(time(time_passes, ~"maybe building test harness", ||
front::test::modify_for_testing(sess, crate_opt.unwrap())));
crate = time(time_passes, ~"maybe building test harness", ||
front::test::modify_for_testing(sess, crate));
}

if phases.to == cu_expand { return (crate_opt, None); }
if phases.to == cu_expand { return (Some(crate), None); }

assert!(phases.from != cu_no_trans);

let mut crate = crate_opt.unwrap();

let (llcx, llmod, link_meta) = {
crate = time(time_passes, ~"extra injection", ||
front::std_inject::maybe_inject_libstd_ref(sess, crate));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ pub fn expect<T:Copy>(sess: Session,
}

pub fn building_library(req_crate_type: crate_type,
crate: @ast::crate,
crate: &ast::crate,
testing: bool) -> bool {
match req_crate_type {
bin_crate => false,
Expand Down
13 changes: 6 additions & 7 deletions src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ struct Context {
// any items that do not belong in the current configuration
pub fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
do strip_items(crate) |attrs| {
in_cfg(/*bad*/copy crate.node.config, attrs)
in_cfg(crate.node.config, attrs)
}
}

pub fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
pub fn strip_items(crate: &ast::crate, in_cfg: in_cfg_pred)
-> @ast::crate {

let ctxt = @Context { in_cfg: in_cfg };
Expand All @@ -44,8 +44,7 @@ pub fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
.. *fold::default_ast_fold()};

let fold = fold::make_fold(precursor);
let res = @fold.fold_crate(&*crate);
return res;
@fold.fold_crate(crate)
}

fn filter_item(cx: @Context, item: @ast::item) ->
Expand Down Expand Up @@ -183,12 +182,12 @@ fn trait_method_in_cfg(cx: @Context, meth: &ast::trait_method) -> bool {

// Determine if an item should be translated in the current crate
// configuration based on the item's attributes
fn in_cfg(cfg: ast::crate_cfg, attrs: ~[ast::attribute]) -> bool {
fn in_cfg(cfg: &[@ast::meta_item], attrs: &[ast::attribute]) -> bool {
metas_in_cfg(cfg, attr::attr_metas(attrs))
}

pub fn metas_in_cfg(cfg: ast::crate_cfg,
metas: ~[@ast::meta_item]) -> bool {
pub fn metas_in_cfg(cfg: &[@ast::meta_item],
metas: &[@ast::meta_item]) -> bool {
// The "cfg" attributes on the item
let cfg_metas = attr::find_meta_items_by_name(metas, "cfg");

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/front/std_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::crate)
}
}

fn use_std(crate: @ast::crate) -> bool {
fn use_std(crate: &ast::crate) -> bool {
!attr::attrs_contains_name(crate.node.attrs, "no_std")
}

fn inject_libstd_ref(sess: Session, crate: @ast::crate) -> @ast::crate {
fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
fn spanned<T:Copy>(x: T) -> codemap::spanned<T> {
codemap::spanned { node: x, span: dummy_sp() }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn generate_test_harness(sess: session::Session,
return res;
}

fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
fn strip_test_functions(crate: &ast::crate) -> @ast::crate {
// When not compiling with --test we should not compile the
// #[test] functions
do config::strip_items(crate) |attrs| {
Expand Down
30 changes: 13 additions & 17 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use metadata::filesearch::FileSearch;
use metadata::loader;

use core::hashmap::HashMap;
use core::vec;
use syntax::attr;
use syntax::codemap::{span, dummy_sp};
use syntax::diagnostic::span_handler;
Expand All @@ -30,7 +29,7 @@ use syntax::ast;
// Traverses an AST, reading all the information about use'd crates and extern
// libraries necessary for later resolving, typechecking, linking, etc.
pub fn read_crates(diag: @span_handler,
crate: @ast::crate,
crate: &ast::crate,
cstore: @mut cstore::CStore,
filesearch: @FileSearch,
os: loader::os,
Expand All @@ -53,8 +52,8 @@ pub fn read_crates(diag: @span_handler,
.. *visit::default_simple_visitor()});
visit_crate(e, crate);
visit::visit_crate(crate, ((), v));
dump_crates(e.crate_cache);
warn_if_multiple_versions(e, diag, e.crate_cache);
dump_crates(*e.crate_cache);
warn_if_multiple_versions(e, diag, *e.crate_cache);
}

struct cache_entry {
Expand All @@ -64,7 +63,7 @@ struct cache_entry {
metas: @~[@ast::meta_item]
}

fn dump_crates(crate_cache: @mut ~[cache_entry]) {
fn dump_crates(crate_cache: &[cache_entry]) {
debug!("resolved crates:");
for crate_cache.iter().advance |entry| {
debug!("cnum: %?", entry.cnum);
Expand All @@ -75,11 +74,9 @@ fn dump_crates(crate_cache: @mut ~[cache_entry]) {

fn warn_if_multiple_versions(e: @mut Env,
diag: @span_handler,
crate_cache: @mut ~[cache_entry]) {
crate_cache: &[cache_entry]) {
use core::either::*;

let crate_cache = &mut *crate_cache;

if crate_cache.len() != 0u {
let name = loader::crate_name_from_metas(
*crate_cache[crate_cache.len() - 1].metas
Expand Down Expand Up @@ -111,7 +108,7 @@ fn warn_if_multiple_versions(e: @mut Env,
}
}

warn_if_multiple_versions(e, diag, @mut non_matches);
warn_if_multiple_versions(e, diag, non_matches);
}
}

Expand All @@ -126,7 +123,7 @@ struct Env {
intr: @ident_interner
}

fn visit_crate(e: @mut Env, c: &ast::crate) {
fn visit_crate(e: &Env, c: &ast::crate) {
let cstore = e.cstore;
let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args");

Expand All @@ -152,7 +149,7 @@ fn visit_view_item(e: @mut Env, i: @ast::view_item) {
}
}

fn visit_item(e: @mut Env, i: @ast::item) {
fn visit_item(e: &Env, i: @ast::item) {
match i.node {
ast::item_foreign_mod(ref fm) => {
if fm.abis.is_rust() || fm.abis.is_intrinsic() {
Expand Down Expand Up @@ -204,26 +201,25 @@ fn visit_item(e: @mut Env, i: @ast::item) {
}
}

fn metas_with(ident: @str, key: @str, metas: ~[@ast::meta_item])
fn metas_with(ident: @str, key: @str, mut metas: ~[@ast::meta_item])
-> ~[@ast::meta_item] {
let name_items = attr::find_meta_items_by_name(metas, key);
if name_items.is_empty() {
vec::append_one(metas, attr::mk_name_value_item_str(key, ident))
} else {
metas
metas.push(attr::mk_name_value_item_str(key, ident));
}
metas
}

fn metas_with_ident(ident: @str, metas: ~[@ast::meta_item])
-> ~[@ast::meta_item] {
metas_with(ident, @"name", metas)
}

fn existing_match(e: @mut Env, metas: &[@ast::meta_item], hash: @str)
fn existing_match(e: &Env, metas: &[@ast::meta_item], hash: &str)
-> Option<int> {
for e.crate_cache.iter().advance |c| {
if loader::metadata_matches(*c.metas, metas)
&& (hash.is_empty() || c.hash == hash) {
&& (hash.is_empty() || c.hash.as_slice() == hash) {
return Some(c.cnum);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn check_crate(
moves_map: moves::MovesMap,
moved_variables_set: moves::MovedVariablesSet,
capture_map: moves::CaptureMap,
crate: @ast::crate) -> (root_map, write_guard_map)
crate: &ast::crate) -> (root_map, write_guard_map)
{
let bccx = @BorrowckCtxt {
tcx: tcx,
Expand Down Expand Up @@ -507,7 +507,7 @@ impl BorrowckCtxt {
pub fn report_use_of_moved_value(&self,
use_span: span,
use_kind: MovedValueUseKind,
lp: @LoanPath,
lp: &LoanPath,
move: &move_data::Move,
moved_lp: @LoanPath) {
let verb = match use_kind {
Expand Down Expand Up @@ -570,7 +570,7 @@ impl BorrowckCtxt {

pub fn report_reassigned_immutable_variable(&self,
span: span,
lp: @LoanPath,
lp: &LoanPath,
assign:
&move_data::Assignment) {
self.tcx.sess.span_err(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use syntax::codemap;
use syntax::{visit, ast_util, ast_map};

pub fn check_crate(sess: Session,
crate: @crate,
crate: &crate,
ast_map: ast_map::map,
def_map: resolve::DefMap,
method_map: typeck::method_map,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Context {
can_ret: bool
}

pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
pub fn check_crate(tcx: ty::ctxt, crate: &crate) {
visit::visit_crate(crate,
(Context { in_loop: false, can_ret: true },
visit::mk_vt(@visit::Visitor {
Expand Down
Loading