about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_trans/trans/adt.rs3
-rw-r--r--src/test/run-pass/enum-null-pointer-opt.rs7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs
index 9fb808a7d2d..ec6823e7622 100644
--- a/src/librustc_trans/trans/adt.rs
+++ b/src/librustc_trans/trans/adt.rs
@@ -462,8 +462,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
         // let's recurse and find out
         ty::TyStruct(def, substs) => {
             for (j, field) in def.struct_variant().fields.iter().enumerate() {
-                // TODO(#27532)
-                let field_ty = field.ty(tcx, substs);
+                let field_ty = monomorphize::field_ty(tcx, substs, field);
                 if let Some(mut fpath) = find_discr_field_candidate(tcx, field_ty, path.clone()) {
                     fpath.push(j);
                     return Some(fpath);
diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs
index dd88dc11ea7..e296aff2782 100644
--- a/src/test/run-pass/enum-null-pointer-opt.rs
+++ b/src/test/run-pass/enum-null-pointer-opt.rs
@@ -18,6 +18,10 @@ use std::rc::Rc;
 use std::sync::Arc;
 
 trait Trait { fn dummy(&self) { } }
+trait Mirror { type Image; }
+impl<T> Mirror for T { type Image = T; }
+struct ParamTypeStruct<T>(T);
+struct AssocTypeStruct<T>(<T as Mirror>::Image);
 
 fn main() {
     // Functions
@@ -66,4 +70,7 @@ fn main() {
     // Should apply to types that have NonZero transitively
     assert_eq!(size_of::<String>(), size_of::<Option<String>>());
 
+    // Should apply to types where the pointer is substituted
+    assert_eq!(size_of::<&u8>(), size_of::<Option<ParamTypeStruct<&u8>>>());
+    assert_eq!(size_of::<&u8>(), size_of::<Option<AssocTypeStruct<&u8>>>());
 }