Skip to content

Commit 13475a0

Browse files
committed
auto merge of #17182 : luqmana/rust/rnp, r=alexcrichton
Fixes #17120.
2 parents 90304ed + a152d5f commit 13475a0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/librustc/middle/trans/adt.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ impl Case {
298298

299299
for (i, &ty) in self.tys.iter().enumerate() {
300300
match ty::get(ty).sty {
301-
// &T/&mut T/*T could either be a thin or fat pointer depending on T
302-
ty::ty_rptr(_, ty::mt { ty, .. })
303-
| ty::ty_ptr(ty::mt { ty, .. }) => match ty::get(ty).sty {
301+
// &T/&mut T could either be a thin or fat pointer depending on T
302+
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
304303
// &[T] and &str are a pointer and length pair
305304
ty::ty_vec(_, None) | ty::ty_str => return Some(FatPointer(i, slice_elt_base)),
306305

src/test/run-pass/enum-null-pointer-opt.rs

+5
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ fn main() {
3737
assert_eq!(size_of::<Box<int>>(), size_of::<Option<Box<int>>>());
3838
assert_eq!(size_of::<Gc<int>>(), size_of::<Option<Gc<int>>>());
3939

40+
41+
// The optimization can't apply to raw pointers
42+
assert!(size_of::<Option<*const int>>() != size_of::<*const int>());
43+
assert!(Some(0 as *const int).is_some()); // Can't collapse None to null
44+
4045
}

0 commit comments

Comments
 (0)