Skip to content

Commit b981741

Browse files
committed
fix conflicts
1 parent 360b894 commit b981741

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

src/liballoc/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ impl<T: ?Sized> Drop for Rc<T> {
543543
unsafe {
544544
let ptr = *self._ptr;
545545
if !(*(&ptr as *const _ as *const *const ())).is_null() &&
546-
ptr as usize != mem::POST_DROP_USIZE {
546+
ptr as *const () as usize != mem::POST_DROP_USIZE {
547547
self.dec_strong();
548548
if self.strong() == 0 {
549549
// destroy the contained object
@@ -1008,7 +1008,7 @@ impl<T: ?Sized> Drop for Weak<T> {
10081008
unsafe {
10091009
let ptr = *self._ptr;
10101010
if !(*(&ptr as *const _ as *const *const ())).is_null() &&
1011-
ptr as usize != mem::POST_DROP_USIZE {
1011+
ptr as *const () as usize != mem::POST_DROP_USIZE {
10121012
self.dec_weak();
10131013
// the weak count starts at 1, and will only go to zero if all
10141014
// the strong pointers have disappeared.

src/librustc_trans/trans/expr.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2048,9 +2048,8 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
20482048
} else { llsrc };
20492049
}
20502050

2051-
let _icx = push_ctxt("trans_cast");
2052-
let mut bcx = bcx;
2053-
let ccx = bcx.ccx();
2051+
let _icx = push_ctxt("trans_cast"); let mut bcx = bcx; let ccx =
2052+
bcx.ccx();
20542053

20552054
let t_in = expr_ty_adjusted(bcx, expr);
20562055
let t_out = node_id_type(bcx, id);
@@ -2080,7 +2079,9 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
20802079
} else {
20812080
// Return the address
20822081
return immediate_rvalue_bcx(bcx,
2083-
Load(bcx, get_dataptr(bcx, datum.val)),
2082+
PointerCast(bcx,
2083+
Load(bcx, get_dataptr(bcx, datum.val)),
2084+
ll_t_out),
20842085
t_out).to_expr_datumblock();
20852086
}
20862087
}

src/librustc_typeck/check/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
528528
upvar::closure_analyze_fn(&fcx, fn_id, decl, body);
529529
fcx.select_all_obligations_or_error();
530530
fcx.check_casts();
531+
532+
fcx.select_all_obligations_or_error(); // Casts can introduce new obligations.
533+
531534
regionck::regionck_fn(&fcx, fn_id, fn_span, decl, body);
532535
writeback::resolve_type_vars_in_fn(&fcx, decl, body);
533536
}

src/test/compile-fail/cast-rfc0401.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ fn main()
5656

5757
let _ = 42usize as *const [u8]; //~ ERROR illegal cast
5858
let _ = v as *const [u8]; //~ ERROR illegal cast
59-
let _ = fat_v as *const Foo; //~ ERROR illegal cast
59+
let _ = fat_v as *const Foo;
60+
//~^ ERROR `core::marker::Sized` is not implemented for the type `[u8]`
6061
let _ = foo as *const str; //~ ERROR illegal cast
6162
let _ = foo as *mut str; //~ ERROR illegal cast
6263
let _ = main as *mut str; //~ ERROR illegal cast

src/test/compile-fail/fat-ptr-cast.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
trait Trait {}
12+
1113
// Make sure casts between thin-pointer <-> fat pointer obey RFC401
1214
fn main() {
1315
let a: &[i32] = &[1, 2, 3];
@@ -17,7 +19,7 @@ fn main() {
1719

1820
a as usize; //~ ERROR illegal cast
1921
b as usize; //~ ERROR non-scalar cast
20-
p as usize; //~ ERROR illegal cast
22+
p as usize; //~ ERROR illegal cast; cast through a raw pointer
2123

2224
// #22955
2325
q as *const [i32]; //~ ERROR illegal cast

src/test/run-pass/cast-rfc0401.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ fn main()
8585
assert_eq!(w as usize, lsz);
8686

8787
// ptr-ptr-cast (fat->thin)
88-
let u: *const [u8] = unsafe{&*p}; assert_eq!(u as *const u8, p as *const u8);
88+
let u: *const [u8] = unsafe{&*p};
89+
assert_eq!(u as *const u8, p as *const u8);
90+
assert_eq!(u as *const u16, p as *const u16);
8991

9092
// ptr-ptr-cast (both vk=Length)
9193
let mut l : [u8; 2] = [0,1];

src/test/run-pass/fat-ptr-cast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ fn main() {
3232
// Test conversion to an address (usize).
3333
let a: *const [i32; 3] = &[1, 2, 3];
3434
let b: *const [i32] = a;
35-
assert!(a as usize == b as usize);
35+
assert!(a as usize == b as *const () as usize);
3636

3737
// And conversion to a void pointer/address for trait objects too.
3838
let a: *mut Foo = &mut Bar;
3939
let b = a as *mut ();
40-
let c = a as usize;
41-
40+
let c = a as *const () as usize;
4241
let d = unsafe {
4342
let r: raw::TraitObject = mem::transmute(a);
4443
r.data
4544
};
4645

4746
assert!(b == d);
4847
assert!(c == d as usize);
48+
4949
}

0 commit comments

Comments
 (0)