auto merge of #5914 : catamorphism/rust/copy-cops, r=catamorphism

This commit is contained in:
bors 2013-04-18 17:51:51 -07:00
commit 225d74f211
11 changed files with 46 additions and 46 deletions

View file

@ -153,9 +153,9 @@ pub mod jit {
code: entry,
env: ptr::null()
};
let func: &fn(++argv: ~[~str]) = cast::transmute(closure);
let func: &fn(++argv: ~[@~str]) = cast::transmute(closure);
func(~[/*bad*/copy sess.opts.binary]);
func(~[sess.opts.binary]);
}
}
}

View file

@ -62,7 +62,7 @@ pub fn source_name(input: input) -> ~str {
}
}
pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
pub fn default_configuration(sess: Session, argv0: @~str, input: input) ->
ast::crate_cfg {
let libc = match sess.targ_cfg.os {
session::os_win32 => ~"msvcrt.dll",
@ -101,7 +101,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
mk(@~"target_word_size", @wordsz),
mk(@~"target_libc", @libc),
// Build bindings.
mk(@~"build_compiler", @argv0),
mk(@~"build_compiler", argv0),
mk(@~"build_input", @source_name(input))];
}
@ -114,7 +114,7 @@ pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
}
}
pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
pub fn build_configuration(sess: Session, argv0: @~str, input: input) ->
ast::crate_cfg {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
@ -523,7 +523,7 @@ pub fn host_triple() -> ~str {
};
}
pub fn build_session_options(+binary: ~str,
pub fn build_session_options(binary: @~str,
matches: &getopts::Matches,
demitter: diagnostic::Emitter)
-> @session::options {
@ -898,9 +898,9 @@ mod test {
getopts::fail_str(f))
};
let sessopts = build_session_options(
~"rustc", matches, diagnostic::emit);
@~"rustc", matches, diagnostic::emit);
let sess = build_session(sessopts, diagnostic::emit);
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
let cfg = build_configuration(sess, @~"whatever", str_input(~""));
assert!((attr::contains_name(cfg, ~"test")));
}
@ -917,9 +917,9 @@ mod test {
}
};
let sessopts = build_session_options(
~"rustc", matches, diagnostic::emit);
@~"rustc", matches, diagnostic::emit);
let sess = build_session(sessopts, diagnostic::emit);
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
let cfg = build_configuration(sess, @~"whatever", str_input(~""));
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
assert!((vec::len(test_items) == 1u));
}

View file

@ -131,7 +131,7 @@ pub struct options {
// will be added to the crate AST node. This should not be used for
// anything except building the full crate config prior to parsing.
cfg: ast::crate_cfg,
binary: ~str,
binary: @~str,
test: bool,
parse_only: bool,
no_trans: bool,
@ -303,7 +303,7 @@ pub fn basic_options() -> @options {
maybe_sysroot: None,
target_triple: host_triple(),
cfg: ~[],
binary: ~"rustc",
binary: @~"rustc",
test: false,
parse_only: false,
no_trans: false,

View file

@ -184,7 +184,7 @@ pub struct CrateContext {
monomorphized: @mut HashMap<mono_id, ValueRef>,
monomorphizing: @mut HashMap<ast::def_id, uint>,
// Cache computed type parameter uses (see type_use.rs)
type_use_cache: @mut HashMap<ast::def_id, ~[type_use::type_uses]>,
type_use_cache: @mut HashMap<ast::def_id, @~[type_use::type_uses]>,
// Cache generated vtables
vtables: @mut HashMap<mono_id, ValueRef>,
// Cache of constant strings,

View file

@ -342,7 +342,7 @@ pub fn make_mono_id(ccx: @CrateContext,
substs: &[ty::t],
vtables: Option<typeck::vtable_res>,
impl_did_opt: Option<ast::def_id>,
+param_uses: Option<~[type_use::type_uses]>) -> mono_id {
param_uses: Option<@~[type_use::type_uses]>) -> mono_id {
let precise_param_ids = match vtables {
Some(vts) => {
let item_ty = ty::lookup_item_type(ccx.tcx, item);
@ -353,12 +353,12 @@ pub fn make_mono_id(ccx: @CrateContext,
match *bound {
ty::bound_trait(_) => {
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
i += 1u;
i += 1;
}
_ => ()
}
}
(*subst, if v.len() > 0u { Some(v) } else { None })
(*subst, if !v.is_empty() { Some(v) } else { None })
})
}
None => {
@ -367,7 +367,7 @@ pub fn make_mono_id(ccx: @CrateContext,
};
let param_ids = match param_uses {
Some(ref uses) => {
vec::map2(precise_param_ids, *uses, |id, uses| {
vec::map2(precise_param_ids, **uses, |id, uses| {
if ccx.sess.no_monomorphic_collapse() {
match copy *id {
(a, b) => mono_precise(a, b)
@ -377,7 +377,7 @@ pub fn make_mono_id(ccx: @CrateContext,
// XXX: Bad copy.
(a, copy b@Some(_)) => mono_precise(a, b),
(subst, None) => {
if *uses == 0u {
if *uses == 0 {
mono_any
} else if *uses == type_use::use_repr &&
!ty::type_needs_drop(ccx.tcx, subst)

View file

@ -47,9 +47,9 @@ use syntax::ast_util;
use syntax::visit;
pub type type_uses = uint; // Bitmask
pub static use_repr: uint = 1u; /* Dependency on size/alignment/mode and
pub static use_repr: uint = 1; /* Dependency on size/alignment/mode and
take/drop glue */
pub static use_tydesc: uint = 2u; /* Takes the tydesc, or compares */
pub static use_tydesc: uint = 2; /* Takes the tydesc, or compares */
pub struct Context {
ccx: @CrateContext,
@ -57,9 +57,9 @@ pub struct Context {
}
pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
-> ~[type_uses] {
-> @~[type_uses] {
match ccx.type_use_cache.find(&fn_id) {
Some(uses) => return /*bad*/ copy *uses,
Some(uses) => return *uses,
None => ()
}
@ -70,11 +70,11 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
};
// Conservatively assume full use for recursive loops
ccx.type_use_cache.insert(fn_id, vec::from_elem(n_tps, 3u));
ccx.type_use_cache.insert(fn_id, @vec::from_elem(n_tps, 3u));
let cx = Context {
ccx: ccx,
uses: @mut vec::from_elem(n_tps, 0u)
uses: @mut vec::from_elem(n_tps, 0)
};
match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).sty {
ty::ty_bare_fn(ty::BareFnTy {sig: ref sig, _}) |
@ -92,8 +92,9 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
}
if fn_id_loc.crate != local_crate {
let uses = copy *cx.uses;
ccx.type_use_cache.insert(fn_id, copy uses);
let Context { uses: @uses, _ } = cx;
let uses = @uses; // mutability
ccx.type_use_cache.insert(fn_id, uses);
return uses;
}
let map_node = match ccx.tcx.items.find(&fn_id_loc.node) {
@ -179,9 +180,9 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
ccx.tcx.sess.parse_sess.interner)));
}
}
// XXX: Bad copies, use @vec instead?
let uses = copy *cx.uses;
ccx.type_use_cache.insert(fn_id, copy uses);
let Context { uses: @uses, _ } = cx;
let uses = @uses; // mutability
ccx.type_use_cache.insert(fn_id, uses);
uses
}
@ -253,7 +254,7 @@ pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
// before stage2
let ts = /*bad*/ copy **ts;
let type_uses = type_uses_for(cx.ccx, did, ts.len());
for vec::each2(type_uses, ts) |uses, subst| {
for vec::each2(*type_uses, ts) |uses, subst| {
type_needs(cx, *uses, *subst)
}
}
@ -302,7 +303,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
let ts = copy **ts;
let id = ast_util::def_id_of_def(*cx.ccx.tcx.def_map.get(&e.id));
let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
for vec::each2(uses_for_ts, ts) |uses, subst| {
for vec::each2(*uses_for_ts, ts) |uses, subst| {
type_needs(cx, *uses, *subst)
}
}

View file

@ -206,9 +206,9 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
::core::logging::console_off();
let mut args = /*bad*/copy *args;
let binary = args.shift();
let binary = @args.shift();
if args.is_empty() { usage(binary); return; }
if args.is_empty() { usage(*binary); return; }
let matches =
&match getopts::groups::getopts(args, optgroups()) {
@ -219,7 +219,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
};
if opt_present(matches, ~"h") || opt_present(matches, ~"help") {
usage(binary);
usage(*binary);
return;
}
@ -236,7 +236,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
}
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
version(binary);
version(*binary);
return;
}
let input = match vec::len(matches.free) {
@ -253,8 +253,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
_ => early_error(demitter, ~"multiple input filenames provided")
};
// XXX: Bad copy.
let sopts = build_session_options(copy binary, matches, demitter);
let sopts = build_session_options(binary, matches, demitter);
let sess = build_session(sopts, demitter);
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
let odir = odir.map(|o| Path(*o));

View file

@ -39,5 +39,5 @@ pub fn from_str_sess(sess: session::Session, source: ~str) -> @ast::crate {
}
fn cfg(sess: session::Session, input: driver::input) -> ast::crate_cfg {
driver::build_configuration(sess, ~"rustdoc", input)
driver::build_configuration(sess, @~"rustdoc", input)
}

View file

@ -127,7 +127,7 @@ fn record(repl: Repl, blk: @ast::blk, intr: @token::ident_interner) -> Repl {
fn run(repl: Repl, input: ~str) -> Repl {
let options = @session::options {
crate_type: session::unknown_crate,
binary: repl.binary,
binary: @repl.binary,
addl_lib_search_paths: repl.lib_search_paths.map(|p| Path(*p)),
jit: true,
.. *session::basic_options()
@ -146,7 +146,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
debug!("building driver configuration");
let cfg = driver::build_configuration(sess,
repl.binary,
@repl.binary,
wrapped);
let outputs = driver::build_output_filenames(wrapped, &None, &None, sess);
@ -191,14 +191,14 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
match do task::try {
let src_path = Path(src_filename);
let options = @session::options {
binary: binary,
binary: @binary,
addl_lib_search_paths: ~[os::getcwd()],
.. *session::basic_options()
};
let input = driver::file_input(src_path);
let sess = driver::build_session(options, diagnostic::emit);
*sess.building_library = true;
let cfg = driver::build_configuration(sess, binary, input);
let cfg = driver::build_configuration(sess, @binary, input);
let outputs = driver::build_output_filenames(
input, &None, &None, sess);
// If the library already exists and is newer than the source

View file

@ -76,13 +76,13 @@ impl PkgScript {
// Build the rustc session data structures to pass
// to the compiler
let options = @session::options {
binary: binary,
binary: @binary,
crate_type: session::bin_crate,
.. *session::basic_options()
};
let input = driver::file_input(script);
let sess = driver::build_session(options, diagnostic::emit);
let cfg = driver::build_configuration(sess, binary, input);
let cfg = driver::build_configuration(sess, @binary, input);
let (crate, _) = driver::compile_upto(sess, cfg, input,
driver::cu_parse, None);
let work_dir = dest_dir(id);

View file

@ -478,7 +478,7 @@ pub fn compile_input(sysroot: Option<Path>,
test: test,
maybe_sysroot: sysroot,
addl_lib_search_paths: ~[copy *out_dir],
.. *driver::build_session_options(binary, &matches, diagnostic::emit)
.. *driver::build_session_options(@binary, &matches, diagnostic::emit)
};
let mut crate_cfg = options.cfg;
@ -518,7 +518,7 @@ pub fn compile_crate_from_input(input: driver::input,
debug!("Calling build_output_filenames with %?", build_dir_opt);
let outputs = driver::build_output_filenames(input, &build_dir_opt, &Some(out_file), sess);
debug!("Outputs are %? and output type = %?", outputs, sess.opts.output_type);
let cfg = driver::build_configuration(sess, binary, input);
let cfg = driver::build_configuration(sess, @binary, input);
match crate_opt {
Some(c) => {
debug!("Calling compile_rest, outputs = %?", outputs);