Skip to content

Commit 225d74f

Browse files
committed
auto merge of #5914 : catamorphism/rust/copy-cops, r=catamorphism
2 parents df9cc2e + 3d43af1 commit 225d74f

File tree

11 files changed

+46
-46
lines changed

11 files changed

+46
-46
lines changed

src/librustc/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ pub mod jit {
153153
code: entry,
154154
env: ptr::null()
155155
};
156-
let func: &fn(++argv: ~[~str]) = cast::transmute(closure);
156+
let func: &fn(++argv: ~[@~str]) = cast::transmute(closure);
157157

158-
func(~[/*bad*/copy sess.opts.binary]);
158+
func(~[sess.opts.binary]);
159159
}
160160
}
161161
}

src/librustc/driver/driver.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn source_name(input: input) -> ~str {
6262
}
6363
}
6464
65-
pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
65+
pub fn default_configuration(sess: Session, argv0: @~str, input: input) ->
6666
ast::crate_cfg {
6767
let libc = match sess.targ_cfg.os {
6868
session::os_win32 => ~"msvcrt.dll",
@@ -101,7 +101,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
101101
mk(@~"target_word_size", @wordsz),
102102
mk(@~"target_libc", @libc),
103103
// Build bindings.
104-
mk(@~"build_compiler", @argv0),
104+
mk(@~"build_compiler", argv0),
105105
mk(@~"build_input", @source_name(input))];
106106
}
107107

@@ -114,7 +114,7 @@ pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
114114
}
115115
}
116116

117-
pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
117+
pub fn build_configuration(sess: Session, argv0: @~str, input: input) ->
118118
ast::crate_cfg {
119119
// Combine the configuration requested by the session (command line) with
120120
// some default and generated configuration items
@@ -523,7 +523,7 @@ pub fn host_triple() -> ~str {
523523
};
524524
}
525525
526-
pub fn build_session_options(+binary: ~str,
526+
pub fn build_session_options(binary: @~str,
527527
matches: &getopts::Matches,
528528
demitter: diagnostic::Emitter)
529529
-> @session::options {
@@ -898,9 +898,9 @@ mod test {
898898
getopts::fail_str(f))
899899
};
900900
let sessopts = build_session_options(
901-
~"rustc", matches, diagnostic::emit);
901+
@~"rustc", matches, diagnostic::emit);
902902
let sess = build_session(sessopts, diagnostic::emit);
903-
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
903+
let cfg = build_configuration(sess, @~"whatever", str_input(~""));
904904
assert!((attr::contains_name(cfg, ~"test")));
905905
}
906906
@@ -917,9 +917,9 @@ mod test {
917917
}
918918
};
919919
let sessopts = build_session_options(
920-
~"rustc", matches, diagnostic::emit);
920+
@~"rustc", matches, diagnostic::emit);
921921
let sess = build_session(sessopts, diagnostic::emit);
922-
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
922+
let cfg = build_configuration(sess, @~"whatever", str_input(~""));
923923
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
924924
assert!((vec::len(test_items) == 1u));
925925
}

src/librustc/driver/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub struct options {
131131
// will be added to the crate AST node. This should not be used for
132132
// anything except building the full crate config prior to parsing.
133133
cfg: ast::crate_cfg,
134-
binary: ~str,
134+
binary: @~str,
135135
test: bool,
136136
parse_only: bool,
137137
no_trans: bool,
@@ -303,7 +303,7 @@ pub fn basic_options() -> @options {
303303
maybe_sysroot: None,
304304
target_triple: host_triple(),
305305
cfg: ~[],
306-
binary: ~"rustc",
306+
binary: @~"rustc",
307307
test: false,
308308
parse_only: false,
309309
no_trans: false,

src/librustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub struct CrateContext {
184184
monomorphized: @mut HashMap<mono_id, ValueRef>,
185185
monomorphizing: @mut HashMap<ast::def_id, uint>,
186186
// Cache computed type parameter uses (see type_use.rs)
187-
type_use_cache: @mut HashMap<ast::def_id, ~[type_use::type_uses]>,
187+
type_use_cache: @mut HashMap<ast::def_id, @~[type_use::type_uses]>,
188188
// Cache generated vtables
189189
vtables: @mut HashMap<mono_id, ValueRef>,
190190
// Cache of constant strings,

src/librustc/middle/trans/monomorphize.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ pub fn make_mono_id(ccx: @CrateContext,
342342
substs: &[ty::t],
343343
vtables: Option<typeck::vtable_res>,
344344
impl_did_opt: Option<ast::def_id>,
345-
+param_uses: Option<~[type_use::type_uses]>) -> mono_id {
345+
param_uses: Option<@~[type_use::type_uses]>) -> mono_id {
346346
let precise_param_ids = match vtables {
347347
Some(vts) => {
348348
let item_ty = ty::lookup_item_type(ccx.tcx, item);
@@ -353,12 +353,12 @@ pub fn make_mono_id(ccx: @CrateContext,
353353
match *bound {
354354
ty::bound_trait(_) => {
355355
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
356-
i += 1u;
356+
i += 1;
357357
}
358358
_ => ()
359359
}
360360
}
361-
(*subst, if v.len() > 0u { Some(v) } else { None })
361+
(*subst, if !v.is_empty() { Some(v) } else { None })
362362
})
363363
}
364364
None => {
@@ -367,7 +367,7 @@ pub fn make_mono_id(ccx: @CrateContext,
367367
};
368368
let param_ids = match param_uses {
369369
Some(ref uses) => {
370-
vec::map2(precise_param_ids, *uses, |id, uses| {
370+
vec::map2(precise_param_ids, **uses, |id, uses| {
371371
if ccx.sess.no_monomorphic_collapse() {
372372
match copy *id {
373373
(a, b) => mono_precise(a, b)
@@ -377,7 +377,7 @@ pub fn make_mono_id(ccx: @CrateContext,
377377
// XXX: Bad copy.
378378
(a, copy b@Some(_)) => mono_precise(a, b),
379379
(subst, None) => {
380-
if *uses == 0u {
380+
if *uses == 0 {
381381
mono_any
382382
} else if *uses == type_use::use_repr &&
383383
!ty::type_needs_drop(ccx.tcx, subst)

src/librustc/middle/trans/type_use.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ use syntax::ast_util;
4747
use syntax::visit;
4848

4949
pub type type_uses = uint; // Bitmask
50-
pub static use_repr: uint = 1u; /* Dependency on size/alignment/mode and
50+
pub static use_repr: uint = 1; /* Dependency on size/alignment/mode and
5151
take/drop glue */
52-
pub static use_tydesc: uint = 2u; /* Takes the tydesc, or compares */
52+
pub static use_tydesc: uint = 2; /* Takes the tydesc, or compares */
5353

5454
pub struct Context {
5555
ccx: @CrateContext,
5656
uses: @mut ~[type_uses]
5757
}
5858

5959
pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
60-
-> ~[type_uses] {
60+
-> @~[type_uses] {
6161
match ccx.type_use_cache.find(&fn_id) {
62-
Some(uses) => return /*bad*/ copy *uses,
62+
Some(uses) => return *uses,
6363
None => ()
6464
}
6565

@@ -70,11 +70,11 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
7070
};
7171

7272
// Conservatively assume full use for recursive loops
73-
ccx.type_use_cache.insert(fn_id, vec::from_elem(n_tps, 3u));
73+
ccx.type_use_cache.insert(fn_id, @vec::from_elem(n_tps, 3u));
7474

7575
let cx = Context {
7676
ccx: ccx,
77-
uses: @mut vec::from_elem(n_tps, 0u)
77+
uses: @mut vec::from_elem(n_tps, 0)
7878
};
7979
match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).sty {
8080
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)
9292
}
9393

9494
if fn_id_loc.crate != local_crate {
95-
let uses = copy *cx.uses;
96-
ccx.type_use_cache.insert(fn_id, copy uses);
95+
let Context { uses: @uses, _ } = cx;
96+
let uses = @uses; // mutability
97+
ccx.type_use_cache.insert(fn_id, uses);
9798
return uses;
9899
}
99100
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)
179180
ccx.tcx.sess.parse_sess.interner)));
180181
}
181182
}
182-
// XXX: Bad copies, use @vec instead?
183-
let uses = copy *cx.uses;
184-
ccx.type_use_cache.insert(fn_id, copy uses);
183+
let Context { uses: @uses, _ } = cx;
184+
let uses = @uses; // mutability
185+
ccx.type_use_cache.insert(fn_id, uses);
185186
uses
186187
}
187188

@@ -253,7 +254,7 @@ pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
253254
// before stage2
254255
let ts = /*bad*/ copy **ts;
255256
let type_uses = type_uses_for(cx.ccx, did, ts.len());
256-
for vec::each2(type_uses, ts) |uses, subst| {
257+
for vec::each2(*type_uses, ts) |uses, subst| {
257258
type_needs(cx, *uses, *subst)
258259
}
259260
}
@@ -302,7 +303,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
302303
let ts = copy **ts;
303304
let id = ast_util::def_id_of_def(*cx.ccx.tcx.def_map.get(&e.id));
304305
let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
305-
for vec::each2(uses_for_ts, ts) |uses, subst| {
306+
for vec::each2(*uses_for_ts, ts) |uses, subst| {
306307
type_needs(cx, *uses, *subst)
307308
}
308309
}

src/librustc/rustc.rc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
206206
::core::logging::console_off();
207207

208208
let mut args = /*bad*/copy *args;
209-
let binary = args.shift();
209+
let binary = @args.shift();
210210

211-
if args.is_empty() { usage(binary); return; }
211+
if args.is_empty() { usage(*binary); return; }
212212

213213
let matches =
214214
&match getopts::groups::getopts(args, optgroups()) {
@@ -219,7 +219,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
219219
};
220220

221221
if opt_present(matches, ~"h") || opt_present(matches, ~"help") {
222-
usage(binary);
222+
usage(*binary);
223223
return;
224224
}
225225

@@ -236,7 +236,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
236236
}
237237

238238
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
239-
version(binary);
239+
version(*binary);
240240
return;
241241
}
242242
let input = match vec::len(matches.free) {
@@ -253,8 +253,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
253253
_ => early_error(demitter, ~"multiple input filenames provided")
254254
};
255255

256-
// XXX: Bad copy.
257-
let sopts = build_session_options(copy binary, matches, demitter);
256+
let sopts = build_session_options(binary, matches, demitter);
258257
let sess = build_session(sopts, demitter);
259258
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
260259
let odir = odir.map(|o| Path(*o));

src/librustdoc/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ pub fn from_str_sess(sess: session::Session, source: ~str) -> @ast::crate {
3939
}
4040
4141
fn cfg(sess: session::Session, input: driver::input) -> ast::crate_cfg {
42-
driver::build_configuration(sess, ~"rustdoc", input)
42+
driver::build_configuration(sess, @~"rustdoc", input)
4343
}

src/librusti/rusti.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn record(repl: Repl, blk: @ast::blk, intr: @token::ident_interner) -> Repl {
127127
fn run(repl: Repl, input: ~str) -> Repl {
128128
let options = @session::options {
129129
crate_type: session::unknown_crate,
130-
binary: repl.binary,
130+
binary: @repl.binary,
131131
addl_lib_search_paths: repl.lib_search_paths.map(|p| Path(*p)),
132132
jit: true,
133133
.. *session::basic_options()
@@ -146,7 +146,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
146146

147147
debug!("building driver configuration");
148148
let cfg = driver::build_configuration(sess,
149-
repl.binary,
149+
@repl.binary,
150150
wrapped);
151151

152152
let outputs = driver::build_output_filenames(wrapped, &None, &None, sess);
@@ -191,14 +191,14 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
191191
match do task::try {
192192
let src_path = Path(src_filename);
193193
let options = @session::options {
194-
binary: binary,
194+
binary: @binary,
195195
addl_lib_search_paths: ~[os::getcwd()],
196196
.. *session::basic_options()
197197
};
198198
let input = driver::file_input(src_path);
199199
let sess = driver::build_session(options, diagnostic::emit);
200200
*sess.building_library = true;
201-
let cfg = driver::build_configuration(sess, binary, input);
201+
let cfg = driver::build_configuration(sess, @binary, input);
202202
let outputs = driver::build_output_filenames(
203203
input, &None, &None, sess);
204204
// If the library already exists and is newer than the source

src/librustpkg/rustpkg.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ impl PkgScript {
7676
// Build the rustc session data structures to pass
7777
// to the compiler
7878
let options = @session::options {
79-
binary: binary,
79+
binary: @binary,
8080
crate_type: session::bin_crate,
8181
.. *session::basic_options()
8282
};
8383
let input = driver::file_input(script);
8484
let sess = driver::build_session(options, diagnostic::emit);
85-
let cfg = driver::build_configuration(sess, binary, input);
85+
let cfg = driver::build_configuration(sess, @binary, input);
8686
let (crate, _) = driver::compile_upto(sess, cfg, input,
8787
driver::cu_parse, None);
8888
let work_dir = dest_dir(id);

src/librustpkg/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub fn compile_input(sysroot: Option<Path>,
478478
test: test,
479479
maybe_sysroot: sysroot,
480480
addl_lib_search_paths: ~[copy *out_dir],
481-
.. *driver::build_session_options(binary, &matches, diagnostic::emit)
481+
.. *driver::build_session_options(@binary, &matches, diagnostic::emit)
482482
};
483483
let mut crate_cfg = options.cfg;
484484
@@ -518,7 +518,7 @@ pub fn compile_crate_from_input(input: driver::input,
518518
debug!("Calling build_output_filenames with %?", build_dir_opt);
519519
let outputs = driver::build_output_filenames(input, &build_dir_opt, &Some(out_file), sess);
520520
debug!("Outputs are %? and output type = %?", outputs, sess.opts.output_type);
521-
let cfg = driver::build_configuration(sess, binary, input);
521+
let cfg = driver::build_configuration(sess, @binary, input);
522522
match crate_opt {
523523
Some(c) => {
524524
debug!("Calling compile_rest, outputs = %?", outputs);

0 commit comments

Comments
 (0)