From a712d828f93ca08c072808d57fb110b1f9d0ca72 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sat, 23 Feb 2013 17:41:44 -0500 Subject: [PATCH 1/5] libcore: remove default to_str implementations for pointer types These couldn't be overridden and so ended up being quite restrictive. This has the side effect of changing the stringification of ~vecs, but nothing in relied on this. Closes #4869. --- src/libcore/to_str.rs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 0145adc77b8..02192ec344f 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -94,15 +94,6 @@ impl ToStr for ~[A] { } } -impl ToStr for @A { - #[inline(always)] - pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() } -} -impl ToStr for ~A { - #[inline(always)] - pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() } -} - #[cfg(test)] #[allow(non_implicitly_copyable_typarams)] mod tests { @@ -127,19 +118,12 @@ mod tests { } #[test] - #[ignore] fn test_vectors() { let x: ~[int] = ~[]; - assert x.to_str() == ~"~[]"; - assert (~[1]).to_str() == ~"~[1]"; - assert (~[1, 2, 3]).to_str() == ~"~[1, 2, 3]"; + assert x.to_str() == ~"[]"; + assert (~[1]).to_str() == ~"[1]"; + assert (~[1, 2, 3]).to_str() == ~"[1, 2, 3]"; assert (~[~[], ~[1], ~[1, 1]]).to_str() == - ~"~[~[], ~[1], ~[1, 1]]"; - } - - #[test] - fn test_pointer_types() { - assert (@1).to_str() == ~"@1"; - assert (~(true, false)).to_str() == ~"~(true, false)"; + ~"[[], [1], [1, 1]]"; } } From b8dd2d8c67907f61a985e4200d46249211b0306d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 25 Feb 2013 16:34:38 +0100 Subject: [PATCH 2/5] Fix typo in grammar: underscore, not minus, can appear amongst hex digits. --- doc/rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rust.md b/doc/rust.md index 975e4bbb8a2..10fb203d022 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -297,7 +297,7 @@ the following forms: num_lit : nonzero_dec [ dec_digit | '_' ] * num_suffix ? | '0' [ [ dec_digit | '_' ] + num_suffix ? | 'b' [ '1' | '0' | '_' ] + int_suffix ? - | 'x' [ hex_digit | '-' ] + int_suffix ? ] ; + | 'x' [ hex_digit | '_' ] + int_suffix ? ] ; num_suffix : int_suffix | float_suffix ; From dbbdca31b45997604d4bf99662cb32939c838149 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 22 Feb 2013 22:15:11 -0800 Subject: [PATCH 3/5] testsuite: Update and un-xfail #3601 test --- src/test/compile-fail/issue-3601.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index 3dd070b44a0..e0adf9eca51 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test struct HTMLImageData { image: Option<~str> } @@ -25,18 +24,19 @@ enum NodeKind { Element(ElementData) } -enum NodeData = { +struct NodeData { kind: ~NodeKind -}; +} fn main() { let mut id = HTMLImageData { image: None }; let ed = ElementData { kind: ~HTMLImageElement(id) }; - let n = NodeData({kind : ~Element(ed)}); + let n = NodeData {kind : ~Element(ed)}; + // n.b. span could be better match n.kind { - ~Element(ed) => match ed.kind { - ~HTMLImageElement(d) if d.image.is_some() => { true } + ~Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns + ~HTMLImageElement(ref d) if d.image.is_some() => { true } }, - _ => fail!(~"WAT") //~ ERROR wat + _ => fail!(~"WAT") //~ ERROR unreachable pattern }; } From 43d43adf6bd2024b1ddc0e596d4bed88e1df82b1 Mon Sep 17 00:00:00 2001 From: Ben Striegel Date: Wed, 27 Feb 2013 19:13:53 -0500 Subject: [PATCH 4/5] Turn old `drop` blocks into `Drop` traits --- src/libcore/io.rs | 10 ++++++++-- src/libcore/option.rs | 5 ++++- src/libcore/pipes.rs | 5 ++++- src/libcore/private.rs | 15 +++++++++++--- src/libcore/rand.rs | 5 ++++- src/libcore/run.rs | 5 ++++- src/libcore/task/spawn.rs | 10 ++++++++-- src/libcore/util.rs | 5 ++++- src/librustc/lib/llvm.rs | 20 +++++++++++++++---- src/librustc/middle/trans/base.rs | 5 ++++- src/librustc/middle/trans/common.rs | 5 ++++- src/librustc/rustc.rc | 5 ++++- src/librustc/util/common.rs | 5 ++++- src/librustdoc/demo.rs | 5 ++++- src/libstd/task_pool.rs | 5 ++++- src/libsyntax/parse/parser.rs | 6 +++++- src/test/auxiliary/moves_based_on_type_lib.rs | 5 ++++- .../use-after-move-self-based-on-type.rs | 5 ++++- .../run-fail/too-much-recursion-unwinding.rs | 5 ++++- src/test/run-fail/unwind-resource-fail.rs | 5 ++++- src/test/run-fail/unwind-resource-fail2.rs | 5 ++++- src/test/run-pass/issue-3563-3.rs | 5 ++++- 22 files changed, 117 insertions(+), 29 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 421eb94a291..45d89b29a2e 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -474,7 +474,10 @@ impl Reader for Wrapper { pub struct FILERes { f: *libc::FILE, - drop { +} + +impl Drop for FILERes { + fn finalize(&self) { unsafe { libc::fclose(self.f); } @@ -683,7 +686,10 @@ impl Writer for fd_t { pub struct FdRes { fd: fd_t, - drop { +} + +impl Drop for FdRes { + fn finalize(&self) { unsafe { libc::close(self.fd); } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 1c2df949a2e..12ed0df0076 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -450,7 +450,10 @@ fn test_unwrap_str() { fn test_unwrap_resource() { struct R { i: @mut int, - drop { *(self.i) += 1; } + } + + impl ::ops::Drop for R { + fn finalize(&self) { *(self.i) += 1; } } fn R(i: @mut int) -> R { diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 15a6e700ffd..a0a29c6b516 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -346,7 +346,10 @@ pub unsafe fn get_buffer(p: *PacketHeader) -> ~Buffer { struct BufferResource { buffer: ~Buffer, - drop { +} + +impl ::ops::Drop for BufferResource { + fn finalize(&self) { unsafe { let b = move_it!(self.buffer); //let p = ptr::addr_of(*b); diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 2580efe6d09..e4fab18966c 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -126,7 +126,10 @@ struct ArcData { struct ArcDestruct { mut data: *libc::c_void, - drop { +} + +impl Drop for ArcDestruct{ + fn finalize(&self) { unsafe { if self.data.is_null() { return; // Happens when destructing an unwrapper's handle. @@ -178,7 +181,10 @@ pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) struct DeathThroes { mut ptr: Option<~ArcData>, mut response: Option>, - drop { + } + + impl Drop for DeathThroes{ + fn finalize(&self) { unsafe { let response = option::swap_unwrap(&mut self.response); // In case we get killed early, we need to tell the person who @@ -311,7 +317,10 @@ type rust_little_lock = *libc::c_void; struct LittleLock { l: rust_little_lock, - drop { +} + +impl Drop for LittleLock { + fn finalize(&self) { unsafe { rustrt::rust_destroy_little_lock(self.l); } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index a88b8346516..15362f89e3f 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -365,7 +365,10 @@ impl Rng { struct RandRes { rng: *rust_rng, - drop { +} + +impl Drop for RandRes { + fn finalize(&self) { unsafe { rustrt::rand_free(self.rng); } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 4e2337b8331..aa1e473e3bf 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -248,7 +248,10 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { } struct ProgRes { r: ProgRepr, - drop { + } + + impl Drop for ProgRes { + fn finalize(&self) { unsafe { // FIXME #4943: This is bad. destroy_repr(cast::transmute(&self.r)); diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 5110f70ff11..bf7209f9fc3 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -308,8 +308,11 @@ struct TCB { mut ancestors: AncestorList, is_main: bool, notifier: Option, +} + +impl Drop for TCB { // Runs on task exit. - drop { + fn finalize(&self) { unsafe { // If we are failing, the whole taskgroup needs to die. if rt::rust_task_is_unwinding(self.me) { @@ -353,7 +356,10 @@ fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, struct AutoNotify { notify_chan: Chan, mut failed: bool, - drop { +} + +impl Drop for AutoNotify { + fn finalize(&self) { let result = if self.failed { Failure } else { Success }; self.notify_chan.send(result); } diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 629c4a3291c..522cb2d2783 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -66,7 +66,10 @@ pub fn replace(dest: &mut T, src: T) -> T { /// A non-copyable dummy type. pub struct NonCopyable { i: (), - drop { } +} + +impl Drop for NonCopyable { + fn finalize(&self) { } } pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } } diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index d2bb7c75a27..78528fa053a 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -1458,7 +1458,10 @@ pub fn struct_tys(struct_ty: TypeRef) -> ~[TypeRef] { pub struct target_data_res { TD: TargetDataRef, - drop { +} + +impl Drop for target_data_res { + fn finalize(&self) { unsafe { llvm::LLVMDisposeTargetData(self.TD); } @@ -1492,7 +1495,10 @@ pub fn mk_target_data(string_rep: ~str) -> TargetData { pub struct pass_manager_res { PM: PassManagerRef, - drop { +} + +impl Drop for pass_manager_res { + fn finalize(&self) { unsafe { llvm::LLVMDisposePassManager(self.PM); } @@ -1525,7 +1531,10 @@ pub fn mk_pass_manager() -> PassManager { pub struct object_file_res { ObjectFile: ObjectFileRef, - drop { +} + +impl Drop for object_file_res { + fn finalize(&self) { unsafe { llvm::LLVMDisposeObjectFile(self.ObjectFile); } @@ -1559,7 +1568,10 @@ pub fn mk_object_file(llmb: MemoryBufferRef) -> Option { pub struct section_iter_res { SI: SectionIteratorRef, - drop { +} + +impl Drop for section_iter_res { + fn finalize(&self) { unsafe { llvm::LLVMDisposeSectionIterator(self.SI); } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 740a7e043d4..c7f59a83cf5 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -90,7 +90,10 @@ use syntax::{ast, ast_util, codemap, ast_map}; pub struct icx_popper { ccx: @CrateContext, - drop { +} + +impl Drop for icx_popper { + fn finalize(&self) { if self.ccx.sess.count_llvm_insns() { self.ccx.stats.llvm_insn_ctxt.pop(); } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index f8a7f477976..c45278ee454 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -141,7 +141,10 @@ pub struct Stats { pub struct BuilderRef_res { B: BuilderRef, - drop { +} + +impl Drop for BuilderRef_res { + fn finalize(&self) { unsafe { llvm::LLVMDisposeBuilder(self.B); } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 5df7ae493ba..56ad56c3ae6 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -336,7 +336,10 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) { struct finally { ch: SharedChan, - drop { self.ch.send(done); } + } + + impl Drop for finally { + fn finalize(&self) { self.ch.send(done); } } let _finally = finally { ch: ch }; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 7b980b9de0d..a83447432a0 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -32,7 +32,10 @@ pub fn indent(op: fn() -> R) -> R { pub struct _indenter { _i: (), - drop { debug!("<<"); } +} + +impl Drop for _indenter { + fn finalize(&self) { debug!("<<"); } } pub fn _indenter(_i: ()) -> _indenter { diff --git a/src/librustdoc/demo.rs b/src/librustdoc/demo.rs index 3c45c4a6fa0..b823be95ef7 100644 --- a/src/librustdoc/demo.rs +++ b/src/librustdoc/demo.rs @@ -125,7 +125,10 @@ mod blade_runner { */ struct Bored { bored: bool, - drop { log(error, self.bored); } +} + +impl Drop for Bored { + fn finalize(&self) { log(error, self.bored); } } /** diff --git a/src/libstd/task_pool.rs b/src/libstd/task_pool.rs index 6b8ea8a6ef4..35b7ff5ad27 100644 --- a/src/libstd/task_pool.rs +++ b/src/libstd/task_pool.rs @@ -28,7 +28,10 @@ pub struct TaskPool { channels: ~[Chan>], mut next_index: uint, - drop { +} + +impl Drop for TaskPool { + fn finalize(&self) { for self.channels.each |channel| { channel.send(Quit); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 59ad35b38e4..1799d807564 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -243,7 +243,11 @@ pub struct Parser { /// Used to determine the path to externally loaded source files mod_path_stack: @mut ~[~str], - drop {} /* do not copy the parser; its state is tied to outside state */ +} + +impl Drop for Parser { + /* do not copy the parser; its state is tied to outside state */ + fn finalize(&self) {} } pub impl Parser { diff --git a/src/test/auxiliary/moves_based_on_type_lib.rs b/src/test/auxiliary/moves_based_on_type_lib.rs index 3dd78eb3f1c..826bd0db129 100644 --- a/src/test/auxiliary/moves_based_on_type_lib.rs +++ b/src/test/auxiliary/moves_based_on_type_lib.rs @@ -12,7 +12,10 @@ pub struct S { x: int, - drop { +} + +impl Drop for S { + fn finalize(&self) { io::println("goodbye"); } } diff --git a/src/test/compile-fail/use-after-move-self-based-on-type.rs b/src/test/compile-fail/use-after-move-self-based-on-type.rs index 270fe3626e8..a06bc42d29a 100644 --- a/src/test/compile-fail/use-after-move-self-based-on-type.rs +++ b/src/test/compile-fail/use-after-move-self-based-on-type.rs @@ -1,6 +1,9 @@ struct S { x: int, - drop {} +} + +impl Drop for S { + fn finalize(&self) {} } impl S { diff --git a/src/test/run-fail/too-much-recursion-unwinding.rs b/src/test/run-fail/too-much-recursion-unwinding.rs index fbea8022cfc..3890e24cdfe 100644 --- a/src/test/run-fail/too-much-recursion-unwinding.rs +++ b/src/test/run-fail/too-much-recursion-unwinding.rs @@ -21,7 +21,10 @@ fn recurse() { struct r { recursed: *mut bool, - drop { +} + +impl Drop for r { + fn finalize(&self) { unsafe { if !*(self.recursed) { *(self.recursed) = true; diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs index 0d57e9279bc..d60e575bac4 100644 --- a/src/test/run-fail/unwind-resource-fail.rs +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -12,7 +12,10 @@ struct r { i: int, - drop { fail!(~"squirrel") } +} + +impl Drop for r { + fn finalize(&self) { fail!(~"squirrel") } } fn r(i: int) -> r { r { i: i } } diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs index 0b33326abe7..e276f2065f7 100644 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ b/src/test/run-fail/unwind-resource-fail2.rs @@ -13,7 +13,10 @@ struct r { i: int, - drop { fail!(~"wombat") } +} + +impl Drop for r { + fn finalize(&self) { fail!(~"wombat") } } fn r(i: int) -> r { r { i: i } } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index c4f4aa46a8a..f66a3cc474c 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -54,7 +54,10 @@ struct AsciiArt // This struct can be quite large so we'll disable copying: developers need // to either pass these structs around via borrowed pointers or move them. - drop {} +} + +impl Drop for AsciiArt { + fn finalize(&self) {} } // It's common to define a constructor sort of function to create struct instances. From 2f858de1c39f3fd8bdc77a6517e12a6458c54f03 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 27 Feb 2013 18:34:04 -0800 Subject: [PATCH 5/5] Remove the last remnants of rtcalls --- src/libcore/cleanup.rs | 4 ++-- src/libcore/rt.rs | 28 ++++++++++-------------- src/librustc/middle/trans/_match.rs | 4 ++-- src/librustc/middle/trans/base.rs | 2 +- src/librustc/middle/trans/callee.rs | 22 +++++++++---------- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/common.rs | 2 +- src/librustc/middle/trans/controlflow.rs | 6 ++--- src/librustc/middle/trans/datum.rs | 4 ++-- src/librustc/middle/trans/glue.rs | 4 ++-- src/librustc/middle/trans/tvec.rs | 2 +- 11 files changed, 37 insertions(+), 43 deletions(-) diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index 567d6da23a6..6912d6d995b 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -154,7 +154,7 @@ fn debug_mem() -> bool { #[cfg(notest)] #[lang="annihilate"] pub unsafe fn annihilate() { - use rt::rt_free; + use rt::local_free; use io::WriterUtil; use io; use libc; @@ -192,7 +192,7 @@ pub unsafe fn annihilate() { stats.n_bytes_freed += (*((*box).header.type_desc)).size + sys::size_of::(); - rt_free(transmute(box)); + local_free(transmute(box)); } } diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs index c3e4f925c40..5d0bad3ceb3 100644 --- a/src/libcore/rt.rs +++ b/src/libcore/rt.rs @@ -36,60 +36,54 @@ pub extern mod rustrt { unsafe fn rust_upcall_free(ptr: *c_char); } -#[rt(fail_)] #[lang="fail_"] -pub fn rt_fail_(expr: *c_char, file: *c_char, line: size_t) -> ! { +pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! { sys::begin_unwind_(expr, file, line); } -#[rt(fail_bounds_check)] #[lang="fail_bounds_check"] -pub unsafe fn rt_fail_bounds_check(file: *c_char, line: size_t, - index: size_t, len: size_t) { +pub unsafe fn fail_bounds_check(file: *c_char, line: size_t, + index: size_t, len: size_t) { let msg = fmt!("index out of bounds: the len is %d but the index is %d", len as int, index as int); do str::as_buf(msg) |p, _len| { - rt_fail_(p as *c_char, file, line); + fail_(p as *c_char, file, line); } } -pub unsafe fn rt_fail_borrowed() { +pub unsafe fn fail_borrowed() { let msg = "borrowed"; do str::as_buf(msg) |msg_p, _| { do str::as_buf("???") |file_p, _| { - rt_fail_(msg_p as *c_char, file_p as *c_char, 0); + fail_(msg_p as *c_char, file_p as *c_char, 0); } } } // FIXME #4942: Make these signatures agree with exchange_alloc's signatures -#[rt(exchange_malloc)] #[lang="exchange_malloc"] -pub unsafe fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { +pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { transmute(exchange_alloc::malloc(transmute(td), transmute(size))) } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from // inside a landing pad may corrupt the state of the exception handler. If a // problem occurs, call exit instead. -#[rt(exchange_free)] #[lang="exchange_free"] -pub unsafe fn rt_exchange_free(ptr: *c_char) { +pub unsafe fn exchange_free(ptr: *c_char) { exchange_alloc::free(transmute(ptr)) } -#[rt(malloc)] #[lang="malloc"] -pub unsafe fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char { +pub unsafe fn local_malloc(td: *c_char, size: uintptr_t) -> *c_char { return rustrt::rust_upcall_malloc(td, size); } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from // inside a landing pad may corrupt the state of the exception handler. If a // problem occurs, call exit instead. -#[rt(free)] #[lang="free"] -pub unsafe fn rt_free(ptr: *c_char) { +pub unsafe fn local_free(ptr: *c_char) { rustrt::rust_upcall_free(ptr); } @@ -112,7 +106,7 @@ pub unsafe fn return_to_mut(a: *u8) { pub unsafe fn check_not_borrowed(a: *u8) { let a: *mut BoxRepr = transmute(a); if ((*a).header.ref_count & FROZEN_BIT) != 0 { - rt_fail_borrowed(); + fail_borrowed(); } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 3686c31ea6e..8ed85b8f421 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1054,7 +1054,7 @@ pub fn compare_values(cx: block, let scratch_rhs = alloca(cx, val_ty(rhs)); Store(cx, rhs, scratch_rhs); let did = cx.tcx().lang_items.uniq_str_eq_fn(); - let bcx = callee::trans_rtcall_or_lang_call(cx, did, + let bcx = callee::trans_lang_call(cx, did, ~[scratch_lhs, scratch_rhs], expr::SaveIn( @@ -1069,7 +1069,7 @@ pub fn compare_values(cx: block, let scratch_result = scratch_datum(cx, ty::mk_bool(cx.tcx()), false); let did = cx.tcx().lang_items.str_eq_fn(); - let bcx = callee::trans_rtcall_or_lang_call(cx, did, + let bcx = callee::trans_lang_call(cx, did, ~[lhs, rhs], expr::SaveIn( scratch_result.val)); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 740a7e043d4..b92501a2f7c 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -304,7 +304,7 @@ pub fn malloc_raw_dyn(bcx: block, // Allocate space: let tydesc = PointerCast(bcx, static_ti.tydesc, T_ptr(T_i8())); let rval = alloca(bcx, T_ptr(T_i8())); - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, langcall, ~[tydesc, size], diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 6924ccf3ab6..42542d79f39 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -332,11 +332,11 @@ pub fn trans_method_call(in_cx: block, DontAutorefArg) } -pub fn trans_rtcall_or_lang_call(bcx: block, - did: ast::def_id, - args: &[ValueRef], - dest: expr::Dest) - -> block { +pub fn trans_lang_call(bcx: block, + did: ast::def_id, + args: &[ValueRef], + dest: expr::Dest) + -> block { let fty = if did.crate == ast::local_crate { ty::node_id_to_type(bcx.ccx().tcx, did.node) } else { @@ -349,12 +349,12 @@ pub fn trans_rtcall_or_lang_call(bcx: block, ArgVals(args), dest, DontAutorefArg); } -pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block, - did: ast::def_id, - args: &[ValueRef], - type_params: ~[ty::t], - dest: expr::Dest) - -> block { +pub fn trans_lang_call_with_type_params(bcx: block, + did: ast::def_id, + args: &[ValueRef], + type_params: ~[ty::t], + dest: expr::Dest) + -> block { let fty; if did.crate == ast::local_crate { fty = ty::node_id_to_type(bcx.tcx(), did.node); diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 1409199a0d2..40407fbf52b 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -500,7 +500,7 @@ pub fn make_opaque_cbox_take_glue( // Allocate memory, update original ptr, and copy existing data let opaque_tydesc = PointerCast(bcx, tydesc, T_ptr(T_i8())); let rval = alloca(bcx, T_ptr(T_i8())); - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.exchange_malloc_fn(), ~[opaque_tydesc, sz], diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index f8a7f477976..642de12e552 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -442,7 +442,7 @@ pub fn add_clean_frozen_root(bcx: block, val: ValueRef, t: ty::t) { do in_scope_cx(bcx) |scope_info| { scope_info.cleanups.push( clean_temp(val, |bcx| { - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.return_to_mut_fn(), ~[ diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 57cb1a93776..70321d50f3f 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -216,7 +216,7 @@ pub fn trans_log(log_ex: @ast::expr, // Call the polymorphic log function let val = val_datum.to_ref_llval(bcx); let did = bcx.tcx().lang_items.log_type_fn(); - let bcx = callee::trans_rtcall_or_lang_call_with_type_params( + let bcx = callee::trans_lang_call_with_type_params( bcx, did, ~[level, val], ~[val_datum.ty], expr::Ignore); bcx } @@ -384,7 +384,7 @@ fn trans_fail_value(bcx: block, let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8())); let V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8())); let args = ~[V_str, V_filename, C_int(ccx, V_line)]; - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.fail_fn(), args, expr::Ignore); Unreachable(bcx); return bcx; @@ -401,7 +401,7 @@ pub fn trans_fail_bounds_check(bcx: block, sp: span, let filename = PointerCast(bcx, filename_cstr, T_ptr(T_i8())); let args = ~[filename, line, index, len]; - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.fail_bounds_check_fn(), args, expr::Ignore); Unreachable(bcx); return bcx; diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 07499dac62e..c93ab056de0 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -544,7 +544,7 @@ pub impl Datum { // If we need to freeze the box, do that now. if root_info.freezes { - callee::trans_rtcall_or_lang_call( + callee::trans_lang_call( bcx, bcx.tcx().lang_items.borrow_as_imm_fn(), ~[ @@ -566,7 +566,7 @@ pub impl Datum { ByRef => Load(bcx, self.val), }; - callee::trans_rtcall_or_lang_call( + callee::trans_lang_call( bcx, bcx.tcx().lang_items.check_not_borrowed_fn(), ~[ PointerCast(bcx, llval, T_ptr(T_i8())) ], diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index cd3a14b69e7..bcb22022d46 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -30,7 +30,7 @@ use core::str; pub fn trans_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_free"); - callee::trans_rtcall_or_lang_call( + callee::trans_lang_call( cx, cx.tcx().lang_items.free_fn(), ~[PointerCast(cx, v, T_ptr(T_i8()))], @@ -39,7 +39,7 @@ pub fn trans_free(cx: block, v: ValueRef) -> block { pub fn trans_exchange_free(cx: block, v: ValueRef) -> block { let _icx = cx.insn_ctxt("trans_exchange_free"); - callee::trans_rtcall_or_lang_call( + callee::trans_lang_call( cx, cx.tcx().lang_items.exchange_free_fn(), ~[PointerCast(cx, v, T_ptr(T_i8()))], diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index df89647321a..dc004c81b11 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -306,7 +306,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: block, let llsizeval = C_uint(bcx.ccx(), s.len()); let typ = ty::mk_estr(bcx.tcx(), ty::vstore_uniq); let lldestval = datum::scratch_datum(bcx, typ, false); - let bcx = callee::trans_rtcall_or_lang_call( + let bcx = callee::trans_lang_call( bcx, bcx.tcx().lang_items.strdup_uniq_fn(), ~[ llptrval, llsizeval ],