Skip to content

Commit 3ed1028

Browse files
committed
---
yaml --- r: 225055 b: refs/heads/stable c: d9b9f4e h: refs/heads/master i: 225053: 24d81c3 225051: 5127f3c 225047: 3189cb5 225039: b3d9487 225023: 33d095d v: v3
1 parent 6699f49 commit 3ed1028

File tree

8 files changed

+22
-13
lines changed

8 files changed

+22
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ refs/heads/tmp: e5d90d98402475b6e154ce216f9efcb80da1a747
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: 1fe32ca12c51afcd761d9962f51a74ff0d07a591
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 9ee2335bfcc6974e73b344b948b71cacc1fc5ea4
32+
refs/heads/stable: d9b9f4ee7de2b5a05547085382a7fc6e196f7c0d
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b

branches/stable/src/liballoc/rc.rs

Lines changed: 2 additions & 2 deletions
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
@@ -1051,7 +1051,7 @@ impl<T: ?Sized> Drop for Weak<T> {
10511051
unsafe {
10521052
let ptr = *self._ptr;
10531053
if !(*(&ptr as *const _ as *const *const ())).is_null() &&
1054-
ptr as usize != mem::POST_DROP_USIZE {
1054+
ptr as *const () as usize != mem::POST_DROP_USIZE {
10551055
self.dec_weak();
10561056
// the weak count starts at 1, and will only go to zero if all
10571057
// the strong pointers have disappeared.

branches/stable/src/librustc_trans/trans/expr.rs

Lines changed: 5 additions & 4 deletions
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
}

branches/stable/src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 0 deletions
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
}

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

Lines changed: 2 additions & 1 deletion
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

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

Lines changed: 3 additions & 1 deletion
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

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

Lines changed: 3 additions & 1 deletion
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];

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

Lines changed: 3 additions & 3 deletions
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)