]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/rt/borrowck.rs
Merge remote-tracking branch 'remotes/origin/master' into str-remove-null
[rust.git] / src / libstd / rt / borrowck.rs
index dcfcc3a9fc67a401341ea845979201f8182cf22c..c18d0287bc801fc0cb1d2a8726b2cc8837de2887 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use c_str::ToCStr;
 use cast::transmute;
 use libc::{c_char, c_void, size_t, STDERR_FILENO};
 use io;
@@ -76,8 +77,8 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) {
     match try_take_task_borrow_list() {
         None => { // not recording borrows
             let msg = "borrowed";
-            do msg.as_c_str |msg_p| {
-                sys::begin_unwind_(msg_p as *c_char, file, line);
+            do msg.to_c_str().with_ref |msg_p| {
+                sys::begin_unwind_(msg_p, file, line);
             }
         }
         Some(borrow_list) => { // recording borrows
@@ -92,8 +93,8 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) {
                     sep = " and at ";
                 }
             }
-            do msg.as_c_str |msg_p| {
-                sys::begin_unwind_(msg_p as *c_char, file, line)
+            do msg.to_c_str().with_ref |msg_p| {
+                sys::begin_unwind_(msg_p, file, line)
             }
         }
     }
@@ -231,8 +232,8 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
             let br = borrow_list.pop();
             if br.box != a || br.file != file || br.line != line {
                 let err = fmt!("wrong borrow found, br=%?", br);
-                do err.as_c_str |msg_p| {
-                    sys::begin_unwind_(msg_p as *c_char, file, line)
+                do err.to_c_str().with_ref |msg_p| {
+                    sys::begin_unwind_(msg_p, file, line)
                 }
             }
             borrow_list