Skip to content

Commit 5fb1e6b

Browse files
committed
librustc: Try looking in fixed sized arrays for nullable enum opt.
1 parent e6b6234 commit 5fb1e6b

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
@@ -390,6 +390,19 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
390390
None
391391
},
392392

393+
// Is this a fixed-size array of something non-zero
394+
// with at least one element?
395+
ty::ty_vec(ety, Some(d)) if d > 0 => {
396+
match find_discr_field_candidate(tcx, ety) {
397+
Some(v) => {
398+
let mut discrfield = vec![0];
399+
discrfield.extend(v.into_iter());
400+
return Some(discrfield);
401+
}
402+
None => None
403+
}
404+
},
405+
393406
// Anything else is not a pointer
394407
_ => None
395408
}

0 commit comments

Comments
 (0)