]> git.lizzy.rs Git - rust.git/commitdiff
fix conflicts
authorAriel Ben-Yehuda <ariel.byd@gmail.com>
Wed, 13 May 2015 18:58:26 +0000 (21:58 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Tue, 19 May 2015 14:42:14 +0000 (17:42 +0300)
src/liballoc/rc.rs
src/librustc_trans/trans/expr.rs
src/librustc_typeck/check/mod.rs
src/test/compile-fail/cast-rfc0401.rs
src/test/compile-fail/fat-ptr-cast.rs
src/test/run-pass/cast-rfc0401.rs
src/test/run-pass/fat-ptr-cast.rs

index 88c5c38172acad831be9c5c289bc124811def361..b8d8e6ad0a1b5c23755e27212c1bd246cbc73a86 100644 (file)
@@ -543,7 +543,7 @@ fn drop(&mut self) {
         unsafe {
             let ptr = *self._ptr;
             if !(*(&ptr as *const _ as *const *const ())).is_null() &&
-               ptr as usize != mem::POST_DROP_USIZE {
+               ptr as *const () as usize != mem::POST_DROP_USIZE {
                 self.dec_strong();
                 if self.strong() == 0 {
                     // destroy the contained object
@@ -1051,7 +1051,7 @@ fn drop(&mut self) {
         unsafe {
             let ptr = *self._ptr;
             if !(*(&ptr as *const _ as *const *const ())).is_null() &&
-               ptr as usize != mem::POST_DROP_USIZE {
+               ptr as *const () as usize != mem::POST_DROP_USIZE {
                 self.dec_weak();
                 // the weak count starts at 1, and will only go to zero if all
                 // the strong pointers have disappeared.
index a65d4225a1f4d4adffe8c7cad6975b887e0cc227..e5c9a81818319c19b43701960e2fa616c60c508b 100644 (file)
@@ -2048,9 +2048,8 @@ fn float_cast(bcx: Block,
         } else { llsrc };
     }
 
-    let _icx = push_ctxt("trans_cast");
-    let mut bcx = bcx;
-    let ccx = bcx.ccx();
+    let _icx = push_ctxt("trans_cast"); let mut bcx = bcx; let ccx =
+    bcx.ccx();
 
     let t_in = expr_ty_adjusted(bcx, expr);
     let t_out = node_id_type(bcx, id);
@@ -2080,7 +2079,9 @@ fn float_cast(bcx: Block,
         } else {
             // Return the address
             return immediate_rvalue_bcx(bcx,
-                                        Load(bcx, get_dataptr(bcx, datum.val)),
+                                        PointerCast(bcx,
+                                                    Load(bcx, get_dataptr(bcx, datum.val)),
+                                                    ll_t_out),
                                         t_out).to_expr_datumblock();
         }
     }
index d3cf9ae6dff87d8df5ab918fa6287acef32a5e4a..d5e3139016f211e0ebdc1ba5102f389fdc57f6a3 100644 (file)
@@ -528,6 +528,9 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             upvar::closure_analyze_fn(&fcx, fn_id, decl, body);
             fcx.select_all_obligations_or_error();
             fcx.check_casts();
+
+            fcx.select_all_obligations_or_error(); // Casts can introduce new obligations.
+
             regionck::regionck_fn(&fcx, fn_id, fn_span, decl, body);
             writeback::resolve_type_vars_in_fn(&fcx, decl, body);
         }
index 3aa866677a80edc8d4528ee69765d449a56b91d5..69ef5421377a321d18278b5d7a8107f96a1adf2b 100644 (file)
@@ -56,7 +56,8 @@ fn main()
 
     let _ = 42usize as *const [u8]; //~ ERROR illegal cast
     let _ = v as *const [u8]; //~ ERROR illegal cast
-    let _ = fat_v as *const Foo; //~ ERROR illegal cast
+    let _ = fat_v as *const Foo;
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `[u8]`
     let _ = foo as *const str; //~ ERROR illegal cast
     let _ = foo as *mut str; //~ ERROR illegal cast
     let _ = main as *mut str; //~ ERROR illegal cast
index f6633547a7b5b6f20e5a8b53d41df2f84ba953a2..25cab09b7cb497ff59f9b933ecb13b69e2b53a53 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+trait Trait {}
+
 // Make sure casts between thin-pointer <-> fat pointer obey RFC401
 fn main() {
     let a: &[i32] = &[1, 2, 3];
@@ -17,7 +19,7 @@ fn main() {
 
     a as usize; //~ ERROR illegal cast
     b as usize; //~ ERROR non-scalar cast
-    p as usize; //~ ERROR illegal cast
+    p as usize; //~ ERROR illegal cast; cast through a raw pointer
 
     // #22955
     q as *const [i32]; //~ ERROR illegal cast
index 92fc2f846ba857dadf14707c44d53d03cb100746..ec4c84a1a6b5edecf7d6f7d44c2c45c290ecb272 100644 (file)
@@ -85,7 +85,9 @@ fn main()
     assert_eq!(w as usize, lsz);
 
     // ptr-ptr-cast (fat->thin)
-    let u: *const [u8] = unsafe{&*p};    assert_eq!(u as *const u8, p as *const u8);
+    let u: *const [u8] = unsafe{&*p};
+    assert_eq!(u as *const u8, p as *const u8);
+    assert_eq!(u as *const u16, p as *const u16);
 
     // ptr-ptr-cast (both vk=Length)
     let mut l : [u8; 2] = [0,1];
index b7513da99c806eb26372abe6a77c6d1ae1e419f0..91637d111fe4f41d43e1399315ef32ca2a162b4a 100644 (file)
@@ -32,13 +32,12 @@ fn main() {
     // Test conversion to an address (usize).
     let a: *const [i32; 3] = &[1, 2, 3];
     let b: *const [i32] = a;
-    assert!(a as usize == b as usize);
+    assert!(a as usize == b as *const () as usize);
 
     // And conversion to a void pointer/address for trait objects too.
     let a: *mut Foo = &mut Bar;
     let b = a as *mut ();
-    let c = a as usize;
-
+    let c = a as *const () as usize;
     let d = unsafe {
         let r: raw::TraitObject = mem::transmute(a);
         r.data
@@ -46,4 +45,5 @@ fn main() {
 
     assert!(b == d);
     assert!(c == d as usize);
+
 }