mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
fix conflicts
This commit is contained in:
parent
9ee2335bfc
commit
d9b9f4ee7d
@ -543,7 +543,7 @@ impl<T: ?Sized> Drop for Rc<T> {
|
||||
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 @@ impl<T: ?Sized> Drop for Weak<T> {
|
||||
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.
|
||||
|
@ -2048,9 +2048,8 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
} 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 trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user