Skip to content

Commit ab5472a

Browse files
committed
auto merge of #5307 : nikomatsakis/rust/remove-by-val, r=nikomatsakis
This is done in two steps: First, we make foreign functions not consider modes at all. This is because previously ++ mode was the only way to pass structs to foreign functions and so forth. We also add a lint mode warning if you use `&&` mode in a foreign function, since the semantics of that change (it used to pass a pointer to the C function, now it doesn't). Then, we remove by value and make it equivalent to `+` mode. At the same time, we stop parsing `-` mode and convert all uses of it to `+` mode (it was already being parsed to `+` mode anyhow). This obsoletes pull request #5298. r? @brson
2 parents 67b0f3d + 852619d commit ab5472a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+579
-303
lines changed

src/libcore/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod rusti {
1212
#[abi = "rust-intrinsic"]
1313
#[link_name = "rusti"]
1414
pub extern {
15-
fn forget<T>(-x: T);
15+
fn forget<T>(+x: T);
1616
fn reinterpret_cast<T, U>(&&e: T) -> U;
1717
}
1818
}

src/libcore/rt/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Thread {
2222
impl Thread {
2323
static fn start(main: ~fn()) -> Thread {
2424
fn substart(main: &fn()) -> *raw_thread {
25-
unsafe { rust_raw_thread_start(main) }
25+
unsafe { rust_raw_thread_start(&main) }
2626
}
2727
let raw = substart(main);
2828
Thread {
@@ -39,6 +39,6 @@ impl Drop for Thread {
3939
}
4040

4141
extern {
42-
pub unsafe fn rust_raw_thread_start(f: &fn()) -> *raw_thread;
42+
pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread;
4343
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
4444
}

src/libcore/unstable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod rustrt {
4747
pub unsafe fn rust_lock_little_lock(lock: rust_little_lock);
4848
pub unsafe fn rust_unlock_little_lock(lock: rust_little_lock);
4949

50-
pub unsafe fn rust_raw_thread_start(f: &fn()) -> *raw_thread;
50+
pub unsafe fn rust_raw_thread_start(f: &(&fn())) -> *raw_thread;
5151
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
5252
}
5353
}
@@ -72,7 +72,7 @@ pub fn run_in_bare_thread(f: ~fn()) {
7272
let closure: &fn() = || {
7373
f()
7474
};
75-
let thread = rustrt::rust_raw_thread_start(closure);
75+
let thread = rustrt::rust_raw_thread_start(&closure);
7676
rustrt::rust_raw_thread_join_delete(thread);
7777
chan.send(());
7878
}

src/libcore/unstable/intrinsics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub extern {
3434

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

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

4040
pub fn min_align_of<T>() -> uint;
4141
pub fn pref_align_of<T>() -> uint;

src/librustc/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
486486

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

538-
fn crate_meta_name(sess: Session, output: &Path, -opt_name: Option<@str>)
538+
fn crate_meta_name(sess: Session, output: &Path, +opt_name: Option<@str>)
539539
-> @str {
540540
return match opt_name {
541541
Some(v) => v,

src/librustc/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input,
440440
}
441441
}
442442
443-
pub fn get_os(triple: ~str) -> Option<session::os> {
443+
pub fn get_os(triple: &str) -> Option<session::os> {
444444
if str::contains(triple, ~"win32") ||
445445
str::contains(triple, ~"mingw32") {
446446
Some(session::os_win32)
@@ -455,7 +455,7 @@ pub fn get_os(triple: ~str) -> Option<session::os> {
455455
} else { None }
456456
}
457457

458-
pub fn get_arch(triple: ~str) -> Option<session::arch> {
458+
pub fn get_arch(triple: &str) -> Option<session::arch> {
459459
if str::contains(triple, ~"i386") ||
460460
str::contains(triple, ~"i486") ||
461461
str::contains(triple, ~"i586") ||

src/librustc/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ pub mod llvm {
14431443
/** Prepares inline assembly. */
14441444
pub unsafe fn LLVMInlineAsm(Ty: TypeRef, AsmString: *c_char,
14451445
Constraints: *c_char, SideEffects: Bool,
1446-
AlignStack: Bool, Dialect: AsmDialect)
1446+
AlignStack: Bool, Dialect: c_uint)
14471447
-> ValueRef;
14481448
}
14491449
}

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ fn metas_with_ident(ident: @~str, +metas: ~[@ast::meta_item])
222222
metas_with(ident, @~"name", metas)
223223
}
224224

225-
fn existing_match(e: @mut Env, metas: ~[@ast::meta_item], hash: @~str)
225+
fn existing_match(e: @mut Env, metas: &[@ast::meta_item], hash: @~str)
226226
-> Option<int> {
227227
for e.crate_cache.each |c| {
228228
if loader::metadata_matches(*c.metas, metas)

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ pub fn maybe_get_item_ast(intr: @ident_interner, cdata: cmd, tcx: ty::ctxt,
560560
let item_path = item_path(intr, item_doc);
561561
vec::from_slice(item_path.init())
562562
};
563-
match decode_inlined_item(cdata, tcx, path, item_doc) {
563+
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
564564
Some(ref ii) => csearch::found((/*bad*/copy *ii)),
565565
None => {
566566
match item_parent_item(item_doc) {

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn crate_matches(crate_data: @~[u8],
176176
metadata_matches(linkage_metas, metas)
177177
}
178178
179-
pub fn metadata_matches(extern_metas: ~[@ast::meta_item],
179+
pub fn metadata_matches(extern_metas: &[@ast::meta_item],
180180
local_metas: &[@ast::meta_item]) -> bool {
181181
182182
debug!("matching %u metadata requirements against %u items",

0 commit comments

Comments
 (0)