Skip to content

Remove by val mode #5307

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 2 commits into from
Mar 13, 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
2 changes: 1 addition & 1 deletion src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod rusti {
#[abi = "rust-intrinsic"]
#[link_name = "rusti"]
pub extern {
fn forget<T>(-x: T);
fn forget<T>(+x: T);
fn reinterpret_cast<T, U>(&&e: T) -> U;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/rt/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Thread {
impl Thread {
static fn start(main: ~fn()) -> Thread {
fn substart(main: &fn()) -> *raw_thread {
unsafe { rust_raw_thread_start(main) }
unsafe { rust_raw_thread_start(&main) }
}
let raw = substart(main);
Thread {
Expand All @@ -39,6 +39,6 @@ impl Drop for Thread {
}

extern {
pub unsafe fn rust_raw_thread_start(f: &fn()) -> *raw_thread;
pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread;
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
}
4 changes: 2 additions & 2 deletions src/libcore/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod rustrt {
pub unsafe fn rust_lock_little_lock(lock: rust_little_lock);
pub unsafe fn rust_unlock_little_lock(lock: rust_little_lock);

pub unsafe fn rust_raw_thread_start(f: &fn()) -> *raw_thread;
pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread;
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
}
}
Expand All @@ -72,7 +72,7 @@ pub fn run_in_bare_thread(f: ~fn()) {
let closure: &fn() = || {
f()
};
let thread = rustrt::rust_raw_thread_start(closure);
let thread = rustrt::rust_raw_thread_start(&closure);
rustrt::rust_raw_thread_join_delete(thread);
chan.send(());
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub extern {

pub fn size_of<T>() -> uint;

pub fn move_val<T>(dst: &mut T, -src: T);
pub fn move_val_init<T>(dst: &mut T, -src: T);
pub fn move_val<T>(dst: &mut T, +src: T);
pub fn move_val_init<T>(dst: &mut T, +src: T);

pub fn min_align_of<T>() -> uint;
pub fn pref_align_of<T>() -> uint;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,

// This calculates CMH as defined above
fn crate_meta_extras_hash(symbol_hasher: &hash::State,
-cmh_items: ~[@ast::meta_item],
+cmh_items: ~[@ast::meta_item],
dep_hashes: ~[~str]) -> @str {
fn len_and_str(s: &str) -> ~str {
fmt!("%u_%s", s.len(), s)
Expand Down Expand Up @@ -535,7 +535,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
name, default));
}

fn crate_meta_name(sess: Session, output: &Path, -opt_name: Option<@str>)
fn crate_meta_name(sess: Session, output: &Path, +opt_name: Option<@str>)
-> @str {
return match opt_name {
Some(v) => v,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input,
}
}

pub fn get_os(triple: ~str) -> Option<session::os> {
pub fn get_os(triple: &str) -> Option<session::os> {
if str::contains(triple, ~"win32") ||
str::contains(triple, ~"mingw32") {
Some(session::os_win32)
Expand All @@ -455,7 +455,7 @@ pub fn get_os(triple: ~str) -> Option<session::os> {
} else { None }
}

pub fn get_arch(triple: ~str) -> Option<session::arch> {
pub fn get_arch(triple: &str) -> Option<session::arch> {
if str::contains(triple, ~"i386") ||
str::contains(triple, ~"i486") ||
str::contains(triple, ~"i586") ||
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ pub mod llvm {
/** Prepares inline assembly. */
pub unsafe fn LLVMInlineAsm(Ty: TypeRef, AsmString: *c_char,
Constraints: *c_char, SideEffects: Bool,
AlignStack: Bool, Dialect: AsmDialect)
AlignStack: Bool, Dialect: c_uint)
-> ValueRef;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn metas_with_ident(ident: @~str, +metas: ~[@ast::meta_item])
metas_with(ident, @~"name", metas)
}

fn existing_match(e: @mut Env, metas: ~[@ast::meta_item], hash: @~str)
fn existing_match(e: @mut Env, metas: &[@ast::meta_item], hash: @~str)
-> Option<int> {
for e.crate_cache.each |c| {
if loader::metadata_matches(*c.metas, metas)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ pub fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
let item_path = item_path(intr, item_doc);
vec::from_slice(item_path.init())
};
match decode_inlined_item(cdata, tcx, path, item_doc) {
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
Some(ref ii) => csearch::found((/*bad*/copy *ii)),
None => {
match item_parent_item(item_doc) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn crate_matches(crate_data: @~[u8],
metadata_matches(linkage_metas, metas)
}

pub fn metadata_matches(extern_metas: ~[@ast::meta_item],
pub fn metadata_matches(extern_metas: &[@ast::meta_item],
local_metas: &[@ast::meta_item]) -> bool {

debug!("matching %u metadata requirements against %u items",
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ fn parse_mode(st: @mut PState) -> ast::mode {
let m = ast::expl(match next(st) {
'+' => ast::by_copy,
'=' => ast::by_ref,
'#' => ast::by_val,
_ => fail!(~"bad mode")
});
return m;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ pub fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) {
match ty::resolved_mode(cx.tcx, m) {
by_copy => w.write_char('+'),
by_ref => w.write_char('='),
by_val => w.write_char('#')
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
tcx: ty::ctxt,
maps: Maps,
path: ast_map::path,
+path: ast_map::path,
par_doc: ebml::Doc)
-> Option<ast::inlined_item> {
let dcx = @DecodeContext {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/gather_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn req_loans_in_expr(ex: @ast::expr,
let arg_cmt = self.bccx.cat_expr(*arg);
self.guarantee_valid(arg_cmt, m_imm, scope_r);
}
ast::by_val | ast::by_copy => {}
ast::by_copy => {}
}
}
visit::visit_expr(ex, self, vt);
Expand All @@ -172,7 +172,7 @@ fn req_loans_in_expr(ex: @ast::expr,
let arg_cmt = self.bccx.cat_expr(*arg);
self.guarantee_valid(arg_cmt, m_imm, scope_r);
}
ast::by_val | ast::by_copy => {}
ast::by_copy => {}
}
}

Expand Down
24 changes: 23 additions & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum lint {
deprecated_self,
deprecated_mutable_fields,
deprecated_drop,
foreign_mode,

managed_heap_memory,
owned_heap_memory,
Expand Down Expand Up @@ -182,6 +183,13 @@ pub fn get_lint_dict() -> LintDict {
default: warn
}),

(@~"foreign_mode",
@LintSpec {
lint: foreign_mode,
desc: "warn about deprecated uses of modes in foreign fns",
default: warn
}),

(@~"deprecated_pattern",
@LintSpec {
lint: deprecated_pattern,
Expand Down Expand Up @@ -753,6 +761,20 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {

fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
decl: &ast::fn_decl) {
// warn about `&&` mode on foreign functions, both because it is
// deprecated and because its semantics have changed recently:
for decl.inputs.eachi |i, arg| {
match ty::resolved_mode(cx, arg.mode) {
ast::by_copy => {}
ast::by_ref => {
cx.sess.span_lint(
foreign_mode, fn_id, fn_id, arg.ty.span,
fmt!("foreign function uses `&&` mode \
on argument %u", i));
}
}
}

let tys = vec::map(decl.inputs, |a| a.ty );
for vec::each(vec::append_one(tys, decl.output)) |ty| {
match ty.node {
Expand Down Expand Up @@ -785,7 +807,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
if attr::foreign_abi(it.attrs) !=
either::Right(ast::foreign_abi_rust_intrinsic) => {
for nmod.items.each |ni| {
match /*bad*/copy ni.node {
match ni.node {
ast::foreign_item_fn(ref decl, _, _) => {
check_foreign_fn(cx, it.id, decl);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub impl IrMaps {
v.push(id);
}
Arg(_, _, by_ref) |
Arg(_, _, by_val) | ImplicitRet => {
ImplicitRet => {
debug!("--but it is not owned");
}
}
Expand Down Expand Up @@ -1006,7 +1006,7 @@ pub impl Liveness {
// inputs passed by & mode should be considered live on exit:
for decl.inputs.each |arg| {
match ty::resolved_mode(self.tcx, arg.mode) {
by_val | by_ref => {
by_ref => {
// By val and by ref do not own, so register a
// read at the end. This will prevent us from
// moving out of such variables but also prevent
Expand Down
8 changes: 0 additions & 8 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,6 @@ pub impl mem_categorization_ctxt {
let lp = match ty::resolved_mode(self.tcx, mode) {
ast::by_copy => Some(@lp_arg(vid)),
ast::by_ref => None,
ast::by_val => {
// by-value is this hybrid mode where we have a
// pointer but we do not own it. This is not
// considered loanable because, for example, a by-ref
// and and by-val argument might both actually contain
// the same unique ptr.
None
}
};
@cmt_ {
id:id,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ pub impl VisitContext {
*/

match arg_mode {
by_val | by_ref => self.use_expr(arg_expr, Read, visitor),
by_ref => self.use_expr(arg_expr, Read, visitor),
by_copy => self.consume_expr(arg_expr, visitor)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ pub impl Resolver {
}

fn import_path_to_str(@mut self,
idents: ~[ident],
idents: &[ident],
subclass: ImportDirectiveSubclass)
-> @~str {
if idents.is_empty() {
Expand Down Expand Up @@ -2573,7 +2573,7 @@ pub impl Resolver {
/// Resolves the given module path from the given root `module_`.
fn resolve_module_path_from_root(@mut self,
module_: @mut Module,
module_path: ~[ident],
module_path: &[ident],
index: uint,
span: span,
mut name_search_type: NameSearchType)
Expand Down Expand Up @@ -2658,7 +2658,7 @@ pub impl Resolver {
/// rooted at the given module.
fn resolve_module_path_for_import(@mut self,
module_: @mut Module,
module_path: ~[ident],
module_path: &[ident],
use_lexical_scope: UseLexicalScopeFlag,
span: span)
-> ResolveResult<@mut Module> {
Expand Down Expand Up @@ -2944,7 +2944,7 @@ pub impl Resolver {
*/
fn resolve_module_prefix(@mut self,
module_: @mut Module,
module_path: ~[ident])
module_path: &[ident])
-> ResolveResult<ModulePrefixResult> {
let interner = self.session.parse_sess.interner;

Expand Down Expand Up @@ -3876,7 +3876,7 @@ pub impl Resolver {
generics: &Generics,
opt_trait_reference: Option<@trait_ref>,
self_type: @Ty,
methods: ~[@method],
methods: &[@method],
visitor: ResolveVisitor) {
// If applicable, create a rib for the type parameters.
let outer_type_parameter_count = generics.ty_params.len();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ pub fn enter_rec_or_struct(bcx: block,
dm: DefMap,
m: &[@Match/&r],
col: uint,
fields: ~[ast::ident],
fields: &[ast::ident],
val: ValueRef)
-> ~[@Match/&r] {
debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)",
Expand Down
8 changes: 1 addition & 7 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1682,12 +1682,6 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,

add_clean(bcx, llarg, arg_ty.ty);
}
ast::by_val => {
// always by value, also not owned, so don't add a cleanup:
let alloc = alloc_ty(bcx, arg_ty.ty);
Store(bcx, raw_llarg, alloc);
llarg = alloc;
}
}

bcx = _match::bind_irrefutable_pat(bcx,
Expand Down Expand Up @@ -1812,7 +1806,7 @@ pub fn trans_fn(ccx: @CrateContext,
debug!("trans_fn(ty_self=%?)", ty_self);
let _icx = ccx.insn_ctxt("trans_fn");
ccx.stats.n_fns += 1;
let the_path_str = path_str(ccx.sess, &path);
let the_path_str = path_str(ccx.sess, path);
trans_closure(ccx, path, decl, body, llfndecl, ty_self,
param_substs, id, impl_id,
|fcx| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ pub fn InlineAsmCall(cx: block, asm: *c_char, cons: *c_char,

let llfty = T_fn(~[], T_void());
let v = llvm::LLVMInlineAsm(llfty, asm, cons, volatile,
alignstack, dia);
alignstack, dia as c_uint);

Call(cx, v, ~[])
}
Expand Down
10 changes: 1 addition & 9 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,6 @@ pub fn trans_arg_expr(bcx: block,
val = arg_datum.to_ref_llval(bcx);
}

ast::by_val => {
// NB: avoid running the take glue.

fail_unless!(!bcx.ccx().maps.moves_map.contains_key(
&arg_expr.id));
val = arg_datum.to_value_llval(bcx);
}

ast::by_copy => {
debug!("by copy arg with type %s, storing to scratch",
bcx.ty_to_str(arg_datum.ty));
Expand Down Expand Up @@ -757,7 +749,7 @@ pub fn trans_arg_expr(bcx: block,

if formal_ty.ty != arg_datum.ty {
// this could happen due to e.g. subtyping
let llformal_ty = type_of::type_of_explicit_arg(ccx, formal_ty);
let llformal_ty = type_of::type_of_explicit_arg(ccx, &formal_ty);
debug!("casting actual type (%s) to match formal (%s)",
bcx.val_str(val), bcx.llty_str(llformal_ty));
val = PointerCast(bcx, val, llformal_ty);
Expand Down
Loading