librustc: Try looking in fixed sized arrays for nullable enum opt.

This commit is contained in:
Luqman Aden 2014-12-04 16:56:26 -05:00
parent e6b6234e66
commit 5fb1e6b1e2

View File

@ -390,6 +390,19 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
None None
}, },
// Is this a fixed-size array of something non-zero
// with at least one element?
ty::ty_vec(ety, Some(d)) if d > 0 => {
match find_discr_field_candidate(tcx, ety) {
Some(v) => {
let mut discrfield = vec![0];
discrfield.extend(v.into_iter());
return Some(discrfield);
}
None => None
}
},
// Anything else is not a pointer // Anything else is not a pointer
_ => None _ => None
} }