diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 9fb808a7d2d93..ec6823e762255 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 dd88dc11ea70e..e296aff2782c5 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 Mirror for T { type Image = T; } +struct ParamTypeStruct(T); +struct AssocTypeStruct(::Image); fn main() { // Functions @@ -66,4 +70,7 @@ fn main() { // Should apply to types that have NonZero transitively assert_eq!(size_of::(), size_of::>()); + // Should apply to types where the pointer is substituted + assert_eq!(size_of::<&u8>(), size_of::>>()); + assert_eq!(size_of::<&u8>(), size_of::>>()); }