Skip to content

librustc: Make vectors no longer implicitly copyable in rustc. #4362

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

Closed
wants to merge 1 commit into from
Closed
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
72 changes: 43 additions & 29 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


use back::rpath;
use driver::session;
use lib::llvm::llvm;
Expand Down Expand Up @@ -56,11 +57,13 @@ impl output_type : cmp::Eq {
pure fn ne(&self, other: &output_type) -> bool { !(*self).eq(other) }
}

fn llvm_err(sess: Session, msg: ~str) -> ! unsafe {
fn llvm_err(sess: Session, +msg: ~str) -> ! unsafe {
let cstr = llvm::LLVMRustGetLastError();
if cstr == ptr::null() {
sess.fatal(msg);
} else { sess.fatal(msg + ~": " + str::raw::from_c_str(cstr)); }
} else {
sess.fatal(msg + ~": " + str::raw::from_c_str(cstr));
}
}

fn WriteOutputFile(sess: Session,
Expand Down Expand Up @@ -147,7 +150,7 @@ pub mod jit {
};
let func: fn(++argv: ~[~str]) = cast::transmute(move closure);

func(~[sess.opts.binary]);
func(~[/*bad*/copy sess.opts.binary]);
}
}
}
Expand Down Expand Up @@ -177,7 +180,7 @@ mod write {
if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); }
let mut pm = mk_pass_manager();
let td = mk_target_data(
sess.targ_cfg.target_strs.data_layout);
/*bad*/copy sess.targ_cfg.target_strs.data_layout);
llvm::LLVMAddTargetData(td.lltd, pm.llpm);
// FIXME (#2812): run the linter here also, once there are llvm-c
// bindings for it.
Expand Down Expand Up @@ -438,17 +441,19 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
let mut name: Option<~str> = None;
let mut vers: Option<~str> = None;
let mut cmh_items: ~[@ast::meta_item] = ~[];
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas);
let linkage_metas =
attr::find_linkage_metas(/*bad*/copy c.node.attrs);
// XXX: Bad copy.
attr::require_unique_names(sess.diagnostic(), copy linkage_metas);
for linkage_metas.each |meta| {
if attr::get_meta_item_name(*meta) == ~"name" {
match attr::get_meta_item_value_str(*meta) {
Some(ref v) => { name = Some((*v)); }
Some(ref v) => { name = Some((/*bad*/copy *v)); }
None => cmh_items.push(*meta)
}
} else if attr::get_meta_item_name(*meta) == ~"vers" {
match attr::get_meta_item_value_str(*meta) {
Some(ref v) => { vers = Some((*v)); }
Some(ref v) => { vers = Some((/*bad*/copy *v)); }
None => cmh_items.push(*meta)
}
} else { cmh_items.push(*meta); }
Expand All @@ -469,7 +474,7 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
return len_and_str(pprust::lit_to_str(@l));
}

let cmh_items = attr::sort_meta_items(metas.cmh_items);
let cmh_items = attr::sort_meta_items(/*bad*/copy metas.cmh_items);

symbol_hasher.reset();
for cmh_items.each |m| {
Expand Down Expand Up @@ -504,15 +509,16 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
fn crate_meta_name(sess: Session, _crate: ast::crate,
output: &Path, metas: provided_metas) -> ~str {
return match metas.name {
Some(ref v) => (*v),
Some(ref v) => (/*bad*/copy *v),
None => {
let name = match output.filestem() {
None => sess.fatal(fmt!("output file name `%s` doesn't\
appear to have a stem",
output.to_str())),
Some(ref s) => (*s)
Some(ref s) => (/*bad*/copy *s)
};
warn_missing(sess, ~"name", name);
// XXX: Bad copy.
warn_missing(sess, ~"name", copy name);
name
}
};
Expand All @@ -521,10 +527,11 @@ fn build_link_meta(sess: Session, c: ast::crate, output: &Path,
fn crate_meta_vers(sess: Session, _crate: ast::crate,
metas: provided_metas) -> ~str {
return match metas.vers {
Some(ref v) => (*v),
Some(ref v) => (/*bad*/copy *v),
None => {
let vers = ~"0.0";
warn_missing(sess, ~"vers", vers);
// Bad copy.
warn_missing(sess, ~"vers", copy vers);
vers
}
};
Expand Down Expand Up @@ -565,10 +572,11 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,

fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str {
match ccx.type_hashcodes.find(t) {
Some(ref h) => return (*h),
Some(ref h) => return (/*bad*/copy *h),
None => {
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
ccx.type_hashcodes.insert(t, hash);
// XXX: Bad copy. Prefer `@str`?
ccx.type_hashcodes.insert(t, copy hash);
return hash;
}
}
Expand Down Expand Up @@ -625,21 +633,26 @@ fn mangle(sess: Session, ss: path) -> ~str {
n
}

fn exported_name(sess: Session, path: path, hash: ~str, vers: ~str) -> ~str {
fn exported_name(sess: Session,
+path: path,
+hash: ~str,
+vers: ~str) -> ~str {
return mangle(sess,
vec::append_one(
vec::append_one(path, path_name(sess.ident_of(hash))),
path_name(sess.ident_of(vers))));
}

fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str {
fn mangle_exported_name(ccx: @crate_ctxt, +path: path, t: ty::t) -> ~str {
let hash = get_symbol_hash(ccx, t);
return exported_name(ccx.sess, path, hash, ccx.link_meta.vers);
return exported_name(ccx.sess, path,
hash,
/*bad*/copy ccx.link_meta.vers);
}

fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
t: ty::t, name: ~str) ->
~str {
t: ty::t,
+name: ~str) -> ~str {
let s = ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
return mangle(ccx.sess,
Expand All @@ -648,17 +661,18 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
path_name(ccx.sess.ident_of(hash))]);
}

fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: ~str) -> ~str {
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt,
+path: path,
+flav: ~str) -> ~str {
return mangle(ccx.sess,
vec::append_one(path, path_name((ccx.names)(flav))));
}

fn mangle_internal_name_by_path(ccx: @crate_ctxt, path: path) -> ~str {
fn mangle_internal_name_by_path(ccx: @crate_ctxt, +path: path) -> ~str {
return mangle(ccx.sess, path);
}

fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str {
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, +flav: ~str) -> ~str {
return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
}

Expand All @@ -669,7 +683,7 @@ fn link_binary(sess: Session,
out_filename: &Path,
lm: link_meta) {
// Converts a library file-stem into a cc -l argument
fn unlib(config: @session::config, stem: ~str) -> ~str {
fn unlib(config: @session::config, +stem: ~str) -> ~str {
if stem.starts_with("lib") &&
config.os != session::os_win32 {
stem.slice(3, stem.len())
Expand All @@ -689,7 +703,7 @@ fn link_binary(sess: Session,

out_filename.dir_path().push(long_libname)
} else {
*out_filename
/*bad*/copy *out_filename
};

log(debug, ~"output: " + output.to_str());
Expand Down Expand Up @@ -736,7 +750,7 @@ fn link_binary(sess: Session,
}

let ula = cstore::get_used_link_args(cstore);
for ula.each |arg| { cc_args.push(*arg); }
for ula.each |arg| { cc_args.push(/*bad*/copy *arg); }

// # Extern library linking

Expand All @@ -746,7 +760,7 @@ fn link_binary(sess: Session,
// to be found at compile time so it is still entirely up to outside
// forces to make sure that library can be found at runtime.

let addl_paths = sess.opts.addl_lib_search_paths;
let addl_paths = /*bad*/copy sess.opts.addl_lib_search_paths;
for addl_paths.each |path| { cc_args.push(~"-L" + path.to_str()); }

// The names of the extern libraries
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


use driver::session;
use metadata::cstore;
use metadata::filesearch;
Expand Down Expand Up @@ -45,7 +46,7 @@ fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
// where rustrt is and we know every rust program needs it
let libs = vec::append_one(libs, get_sysroot_absolute_rt_lib(sess));

let target_triple = sess.opts.target_triple;
let target_triple = /*bad*/copy sess.opts.target_triple;
let rpaths = get_rpaths(os, &sysroot, output, libs, target_triple);
rpaths_to_flags(rpaths)
}
Expand Down Expand Up @@ -139,8 +140,8 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
let abs2 = abs2.normalize();
debug!("finding relative path from %s to %s",
abs1.to_str(), abs2.to_str());
let split1 = abs1.components;
let split2 = abs2.components;
let split1 = /*bad*/copy abs1.components;
let split2 = /*bad*/copy abs2.components;
let len1 = vec::len(split1);
let len2 = vec::len(split2);
assert len1 > 0;
Expand Down Expand Up @@ -190,7 +191,7 @@ fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] {
for rpaths.each |rpath| {
let s = rpath.to_str();
if !set.contains_key(s) {
minimized.push(*rpath);
minimized.push(/*bad*/copy *rpath);
set.insert(s, ());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc/back/target_strs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


type t = {
module_asm: ~str,
meta_sect_name: ~str,
Expand Down
6 changes: 4 additions & 2 deletions src/librustc/back/upcall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ fn declare_upcalls(targ_cfg: @session::config,
fn nothrow(f: ValueRef) -> ValueRef {
base::set_no_unwind(f); f
}
let d = |a,b,c| decl(llmod, ~"upcall_", a, b, c);
let dv = |a,b| decl(llmod, ~"upcall_", a, b, T_void());
let d: &fn(+a: ~str, +b: ~[TypeRef], +c: TypeRef) -> ValueRef =
|a,b,c| decl(llmod, ~"upcall_", a, b, c);
let dv: &fn(+a: ~str, +b: ~[TypeRef]) -> ValueRef =
|a,b| decl(llmod, ~"upcall_", a, b, T_void());

let int_t = T_int(targ_cfg);

Expand Down
1 change: 1 addition & 0 deletions src/librustc/back/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


use back::target_strs;
use driver::session;
use metadata::loader::meta_section_name;
Expand Down
1 change: 1 addition & 0 deletions src/librustc/back/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.


use back::target_strs;
use driver::session;
use metadata::loader::meta_section_name;
Expand Down
Loading