Skip to content

Revamp foreign code not to consider the Rust modes. This requires #5298

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
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
5 changes: 3 additions & 2 deletions src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub mod rustrt {
unsafe fn rust_getcwd() -> ~str;
unsafe fn rust_path_is_dir(path: *libc::c_char) -> c_int;
unsafe fn rust_path_exists(path: *libc::c_char) -> c_int;
unsafe fn rust_list_files2(&&path: ~str) -> ~[~str];
unsafe fn rust_list_files2(path: &~str) -> ~[~str];
unsafe fn rust_process_wait(handle: c_int) -> c_int;
unsafe fn rust_set_exit_status(code: libc::intptr_t);
}
Expand Down Expand Up @@ -621,7 +621,8 @@ pub fn list_dir(p: &Path) -> ~[~str] {
#[cfg(windows)]
fn star(p: &Path) -> Path { p.push("*") }

do rustrt::rust_list_files2(star(p).to_str()).filtered |filename| {
let s = star(p).to_str();
do rustrt::rust_list_files2(&s).filtered |filename| {
*filename != ~"." && *filename != ~".."
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 @@ -70,7 +70,7 @@ pub unsafe 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
24 changes: 23 additions & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub enum lint {
default_methods,
deprecated_self,
deprecated_mutable_fields,
foreign_mode,

managed_heap_memory,
owned_heap_memory,
Expand Down Expand Up @@ -181,6 +182,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 @@ -724,6 +732,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_val | 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 @@ -756,7 +778,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
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,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