Skip to content

librustc: Disallow "unsafe" for external functions #8235

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 2 commits 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
2 changes: 1 addition & 1 deletion doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ compiler needs assistance, though, the arguments and return types may be
annotated.

~~~~
let square = |x: int| -> uint { x * x as uint };
let square = |x: int| -> uint { (x * x) as uint };
~~~~

There are several forms of closure, each with its own role. The most
Expand Down
20 changes: 10 additions & 10 deletions src/libextra/flate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ pub mod rustrt {

#[link_name = "rustrt"]
extern {
pub unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
pub fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;

pub unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
pub fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/libextra/rl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub mod rustrt {
use std::libc::{c_char, c_int};

extern {
pub unsafe fn linenoise(prompt: *c_char) -> *c_char;
pub unsafe fn linenoiseHistoryAdd(line: *c_char) -> c_int;
pub unsafe fn linenoiseHistorySetMaxLen(len: c_int) -> c_int;
pub unsafe fn linenoiseHistorySave(file: *c_char) -> c_int;
pub unsafe fn linenoiseHistoryLoad(file: *c_char) -> c_int;
pub unsafe fn linenoiseSetCompletionCallback(callback: *u8);
pub unsafe fn linenoiseAddCompletion(completions: *(), line: *c_char);
pub fn linenoise(prompt: *c_char) -> *c_char;
pub fn linenoiseHistoryAdd(line: *c_char) -> c_int;
pub fn linenoiseHistorySetMaxLen(len: c_int) -> c_int;
pub fn linenoiseHistorySave(file: *c_char) -> c_int;
pub fn linenoiseHistoryLoad(file: *c_char) -> c_int;
pub fn linenoiseSetCompletionCallback(callback: *u8);
pub fn linenoiseAddCompletion(completions: *(), line: *c_char);
}
}

Expand Down
17 changes: 7 additions & 10 deletions src/libextra/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ pub mod rustrt {

#[abi = "cdecl"]
extern {
pub unsafe fn get_time(sec: &mut i64, nsec: &mut i32);

pub unsafe fn precise_time_ns(ns: &mut u64);

pub unsafe fn rust_tzset();

pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
pub unsafe fn rust_timegm(tm: &Tm) -> i64;
pub unsafe fn rust_mktime(tm: &Tm) -> i64;
pub fn get_time(sec: &mut i64, nsec: &mut i32);
pub fn precise_time_ns(ns: &mut u64);
pub fn rust_tzset();
pub fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
pub fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
pub fn rust_timegm(tm: &Tm) -> i64;
pub fn rust_mktime(tm: &Tm) -> i64;
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/libextra/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,13 @@ pub mod icu {
#[link_name = "icuuc"]
#[abi = "cdecl"]
extern {
pub unsafe fn u_hasBinaryProperty(c: UChar32, which: UProperty)
-> UBool;
pub unsafe fn u_isdigit(c: UChar32) -> UBool;
pub unsafe fn u_islower(c: UChar32) -> UBool;
pub unsafe fn u_isspace(c: UChar32) -> UBool;
pub unsafe fn u_isupper(c: UChar32) -> UBool;
pub unsafe fn u_tolower(c: UChar32) -> UChar32;
pub unsafe fn u_toupper(c: UChar32) -> UChar32;
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
pub fn u_isdigit(c: UChar32) -> UBool;
pub fn u_islower(c: UChar32) -> UBool;
pub fn u_isspace(c: UChar32) -> UBool;
pub fn u_isupper(c: UChar32) -> UBool;
pub fn u_tolower(c: UChar32) -> UChar32;
pub fn u_toupper(c: UChar32) -> UChar32;
}
}
}
Expand Down
Loading