Skip to content

Commit 39be76e

Browse files
committed
librustc: Try looking in fixed sized arrays for nullable enum opt.
1 parent 054a256 commit 39be76e

File tree

1 file changed

+13
-0
lines changed
  • src/librustc_trans/trans

1 file changed

+13
-0
lines changed

src/librustc_trans/trans/adt.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
338338
None
339339
},
340340

341+
// Is this a fixed-size array of something non-zero
342+
// with at least one element?
343+
ty::ty_vec(ety, Some(d)) if d > 0 => {
344+
match find_discr_field_candidate(tcx, ety) {
345+
Some(v) => {
346+
let mut discrfield = vec![0];
347+
discrfield.extend(v.into_iter());
348+
return Some(discrfield);
349+
}
350+
None => None
351+
}
352+
},
353+
341354
// Anything else is not a pointer
342355
_ => None
343356
}

0 commit comments

Comments
 (0)