Skip to content

Commit 4ff701b

Browse files
committed
auto merge of #5965 : alexcrichton/rust/issue-4364, r=pcwalton
This closes #4364. I came into rust after modes had begun to be phased out, so I'm not exactly sure what they all did. My strategy was basically to turn on the compilation warnings and then when everything compiles and passes all the tests it's all good. In most cases, I just dropped the mode, but in others I converted things to use `&` pointers when otherwise a move would happen. This depends on #5963. When running the tests, everything passed except for a few compile-fail tests. These tests leaked memory, causing the task to abort differently. By suppressing the ICE from #5963, no leaks happen and the tests all pass. I would have looked into where the leaks were coming from, but I wasn't sure where or how to debug them (I found `RUSTRT_TRACK_ALLOCATIONS`, but it wasn't all that useful).
2 parents 028dc58 + cd982ad commit 4ff701b

Some content is hidden

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

110 files changed

+1089
-1124
lines changed

src/libcore/comm.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ pub mod streamp {
112112

113113
#[allow(non_camel_case_types)]
114114
pub mod server {
115-
priv use core::kinds::Owned;
116-
117115
#[allow(non_camel_case_types)]
118116
pub type Open<T> = ::core::pipes::RecvPacket<super::Open<T>>;
119117
}
@@ -388,8 +386,6 @@ pub mod oneshot {
388386
389387
#[allow(non_camel_case_types)]
390388
pub mod server {
391-
priv use core::kinds::Owned;
392-
393389
#[allow(non_camel_case_types)]
394390
pub type Oneshot<T> =
395391
::core::pipes::RecvPacketBuffered<super::Oneshot<T>,

src/libcore/rt/sched/local_sched.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,16 @@ pub fn borrow(f: &fn(&mut Scheduler)) {
6666
/// Because this leaves the Scheduler in thread-local storage it is possible
6767
/// For the Scheduler pointer to be aliased
6868
pub unsafe fn unsafe_borrow() -> &mut Scheduler {
69-
unsafe {
70-
let key = tls_key();
71-
let mut void_sched: *mut c_void = tls::get(key);
72-
assert!(void_sched.is_not_null());
73-
{
74-
let void_sched_ptr = &mut void_sched;
75-
let sched: &mut ~Scheduler = {
76-
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
77-
};
78-
let sched: &mut Scheduler = &mut **sched;
79-
return sched;
80-
}
69+
let key = tls_key();
70+
let mut void_sched: *mut c_void = tls::get(key);
71+
assert!(void_sched.is_not_null());
72+
{
73+
let void_sched_ptr = &mut void_sched;
74+
let sched: &mut ~Scheduler = {
75+
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
76+
};
77+
let sched: &mut Scheduler = &mut **sched;
78+
return sched;
8179
}
8280
}
8381

src/libcore/rt/uv/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn connect_read() {
388388
vec_to_uv_buf(vec::from_elem(size, 0))
389389
};
390390
do stream_watcher.read_start(alloc)
391-
|stream_watcher, nread, buf, status| {
391+
|stream_watcher, _nread, buf, status| {
392392
393393
let buf = vec_from_uv_buf(buf);
394394
rtdebug!("read cb!");

src/libcore/stackwalk.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ fn test_simple_deep() {
6464
if i == 0 { return }
6565

6666
for walk_stack |_frame| {
67-
unsafe {
68-
breakpoint();
69-
}
67+
breakpoint();
7068
}
7169
run(i - 1);
7270
}

src/libcore/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,15 +3346,15 @@ mod tests {
33463346
#[test]
33473347
fn test_shift_byte() {
33483348
let mut s = ~"ABC";
3349-
let b = unsafe { raw::shift_byte(&mut s) };
3349+
let b = raw::shift_byte(&mut s);
33503350
assert!((s == ~"BC"));
33513351
assert!((b == 65u8));
33523352
}
33533353
33543354
#[test]
33553355
fn test_pop_byte() {
33563356
let mut s = ~"ABC";
3357-
let b = unsafe { raw::pop_byte(&mut s) };
3357+
let b = raw::pop_byte(&mut s);
33583358
assert!((s == ~"AB"));
33593359
assert!((b == 67u8));
33603360
}

src/libcore/task/local_data.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,32 +150,28 @@ fn test_tls_modify() {
150150
151151
#[test]
152152
fn test_tls_crust_automorestack_memorial_bug() {
153-
unsafe {
154-
// This might result in a stack-canary clobber if the runtime fails to
155-
// set sp_limit to 0 when calling the cleanup extern - it might
156-
// automatically jump over to the rust stack, which causes next_c_sp
157-
// to get recorded as something within a rust stack segment. Then a
158-
// subsequent upcall (esp. for logging, think vsnprintf) would run on
159-
// a stack smaller than 1 MB.
160-
fn my_key(_x: @~str) { }
161-
do task::spawn {
162-
unsafe { local_data_set(my_key, @~"hax"); }
163-
}
153+
// This might result in a stack-canary clobber if the runtime fails to
154+
// set sp_limit to 0 when calling the cleanup extern - it might
155+
// automatically jump over to the rust stack, which causes next_c_sp
156+
// to get recorded as something within a rust stack segment. Then a
157+
// subsequent upcall (esp. for logging, think vsnprintf) would run on
158+
// a stack smaller than 1 MB.
159+
fn my_key(_x: @~str) { }
160+
do task::spawn {
161+
unsafe { local_data_set(my_key, @~"hax"); }
164162
}
165163
}
166164
167165
#[test]
168166
fn test_tls_multiple_types() {
169-
unsafe {
170-
fn str_key(_x: @~str) { }
171-
fn box_key(_x: @@()) { }
172-
fn int_key(_x: @int) { }
173-
do task::spawn {
174-
unsafe {
175-
local_data_set(str_key, @~"string data");
176-
local_data_set(box_key, @@());
177-
local_data_set(int_key, @42);
178-
}
167+
fn str_key(_x: @~str) { }
168+
fn box_key(_x: @@()) { }
169+
fn int_key(_x: @int) { }
170+
do task::spawn {
171+
unsafe {
172+
local_data_set(str_key, @~"string data");
173+
local_data_set(box_key, @@());
174+
local_data_set(int_key, @42);
179175
}
180176
}
181177
}

src/libfuzzer/fuzzer.rc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn stash_ty_if(c: @fn(@ast::Ty, test_mode)->bool,
160160

161161
pub struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]}
162162

163-
pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
163+
pub fn steal(crate: @ast::crate, tm: test_mode) -> StolenStuff {
164164
let exprs = @mut ~[];
165165
let tys = @mut ~[];
166166
let v = visit::mk_simple_visitor(@visit::SimpleVisitor {
@@ -197,7 +197,7 @@ pub fn safe_to_replace_ty(t: &ast::ty_, _tm: test_mode) -> bool {
197197
}
198198

199199
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
200-
pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
200+
pub fn replace_expr_in_crate(crate: @ast::crate, i: uint,
201201
newexpr: ast::expr, tm: test_mode) ->
202202
ast::crate {
203203
let j: @mut uint = @mut 0u;
@@ -222,13 +222,13 @@ pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
222222
.. *fold::default_ast_fold()
223223
};
224224
let af = fold::make_fold(afp);
225-
let crate2: @ast::crate = @af.fold_crate(&crate);
225+
let crate2: @ast::crate = @af.fold_crate(crate);
226226
*crate2
227227
}
228228

229229

230230
// Replace the |i|th ty (in fold order) of |crate| with |newty|.
231-
pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
231+
pub fn replace_ty_in_crate(crate: @ast::crate, i: uint, newty: ast::Ty,
232232
tm: test_mode) -> ast::crate {
233233
let j: @mut uint = @mut 0u;
234234
fn fold_ty_rep(j_: @mut uint,
@@ -248,7 +248,7 @@ pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
248248
.. *fold::default_ast_fold()
249249
};
250250
let af = fold::make_fold(afp);
251-
let crate2: @ast::crate = @af.fold_crate(&crate);
251+
let crate2: @ast::crate = @af.fold_crate(crate);
252252
*crate2
253253
}
254254

@@ -261,7 +261,7 @@ pub fn as_str(f: @fn(+x: @io::Writer)) -> ~str {
261261
io::with_str_writer(f)
262262
}
263263

264-
pub fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
264+
pub fn check_variants_of_ast(crate: @ast::crate, codemap: @codemap::CodeMap,
265265
filename: &Path, cx: Context) {
266266
let stolen = steal(crate, cx.mode);
267267
let extra_exprs = do common_exprs().filtered |a| {
@@ -275,13 +275,13 @@ pub fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
275275
}
276276

277277
pub fn check_variants_T<T: Copy>(
278-
crate: ast::crate,
278+
crate: @ast::crate,
279279
codemap: @codemap::CodeMap,
280280
filename: &Path,
281281
thing_label: ~str,
282282
things: ~[T],
283283
stringifier: @fn(@T, @syntax::parse::token::ident_interner) -> ~str,
284-
replacer: @fn(ast::crate, uint, T, test_mode) -> ast::crate,
284+
replacer: @fn(@ast::crate, uint, T, test_mode) -> ast::crate,
285285
cx: Context
286286
) {
287287
error!("%s contains %u %s objects", filename.to_str(),
@@ -323,7 +323,7 @@ pub fn check_variants_T<T: Copy>(
323323
last_part(filename.to_str()),
324324
thing_label, i, j);
325325
let safe_to_run = !(content_is_dangerous_to_run(*str3)
326-
|| has_raw_pointers(*crate2));
326+
|| has_raw_pointers(crate2));
327327
check_whole_compiler(*str3, &Path(file_label),
328328
safe_to_run);
329329
}
@@ -480,7 +480,7 @@ pub fn parse_and_print(code: @~str) -> ~str {
480480
}
481481
}
482482

483-
pub fn has_raw_pointers(c: ast::crate) -> bool {
483+
pub fn has_raw_pointers(c: @ast::crate) -> bool {
484484
let has_rp = @mut false;
485485
fn visit_ty(flag: @mut bool, t: @ast::Ty) {
486486
match t.node {
@@ -634,7 +634,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
634634
pprust::no_ann(),
635635
false)))
636636
});
637-
check_variants_of_ast(*crate, sess.cm, file, cx);
637+
check_variants_of_ast(crate, sess.cm, file, cx);
638638
}
639639
}
640640

src/librustc/back/link.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub enum output_type {
4848
output_type_exe,
4949
}
5050

51-
pub fn llvm_err(sess: Session, +msg: ~str) -> ! {
51+
pub fn llvm_err(sess: Session, msg: ~str) -> ! {
5252
unsafe {
5353
let cstr = llvm::LLVMRustGetLastError();
5454
if cstr == ptr::null() {
@@ -153,7 +153,7 @@ pub mod jit {
153153
code: entry,
154154
env: ptr::null()
155155
};
156-
let func: &fn(++argv: ~[@~str]) = cast::transmute(closure);
156+
let func: &fn(argv: ~[@~str]) = cast::transmute(closure);
157157

158158
func(~[sess.opts.binary]);
159159
}
@@ -519,7 +519,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
519519
520520
// This calculates CMH as defined above
521521
fn crate_meta_extras_hash(symbol_hasher: &hash::State,
522-
+cmh_items: ~[@ast::meta_item],
522+
cmh_items: ~[@ast::meta_item],
523523
dep_hashes: ~[~str]) -> @str {
524524
fn len_and_str(s: &str) -> ~str {
525525
fmt!("%u_%s", s.len(), s)
@@ -568,7 +568,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
568568
name, default));
569569
}
570570
571-
fn crate_meta_name(sess: Session, output: &Path, +opt_name: Option<@str>)
571+
fn crate_meta_name(sess: Session, output: &Path, opt_name: Option<@str>)
572572
-> @str {
573573
return match opt_name {
574574
Some(v) => v,
@@ -703,7 +703,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str {
703703
}
704704
705705
pub fn exported_name(sess: Session,
706-
+path: path,
706+
path: path,
707707
hash: &str,
708708
vers: &str) -> ~str {
709709
return mangle(sess,
@@ -713,7 +713,7 @@ pub fn exported_name(sess: Session,
713713
}
714714
715715
pub fn mangle_exported_name(ccx: @CrateContext,
716-
+path: path,
716+
path: path,
717717
t: ty::t) -> ~str {
718718
let hash = get_symbol_hash(ccx, t);
719719
return exported_name(ccx.sess, path,
@@ -733,17 +733,17 @@ pub fn mangle_internal_name_by_type_only(ccx: @CrateContext,
733733
}
734734
735735
pub fn mangle_internal_name_by_path_and_seq(ccx: @CrateContext,
736-
+path: path,
737-
+flav: ~str) -> ~str {
736+
path: path,
737+
flav: ~str) -> ~str {
738738
return mangle(ccx.sess,
739739
vec::append_one(path, path_name((ccx.names)(flav))));
740740
}
741741
742-
pub fn mangle_internal_name_by_path(ccx: @CrateContext, +path: path) -> ~str {
742+
pub fn mangle_internal_name_by_path(ccx: @CrateContext, path: path) -> ~str {
743743
return mangle(ccx.sess, path);
744744
}
745745
746-
pub fn mangle_internal_name_by_seq(ccx: @CrateContext, +flav: ~str) -> ~str {
746+
pub fn mangle_internal_name_by_seq(ccx: @CrateContext, flav: ~str) -> ~str {
747747
return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
748748
}
749749
@@ -768,7 +768,7 @@ pub fn link_binary(sess: Session,
768768
out_filename: &Path,
769769
lm: LinkMeta) {
770770
// Converts a library file-stem into a cc -l argument
771-
fn unlib(config: @session::config, +stem: ~str) -> ~str {
771+
fn unlib(config: @session::config, stem: ~str) -> ~str {
772772
if stem.starts_with("lib") &&
773773
config.os != session::os_win32 {
774774
stem.slice(3, stem.len()).to_owned()

0 commit comments

Comments
 (0)