Skip to content

Commit

Permalink
librustc: Try looking in fixed sized arrays for nullable enum opt.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Dec 29, 2014
1 parent e6b6234 commit 5fb1e6b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/librustc_trans/trans/adt.rs
Expand Up @@ -390,6 +390,19 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
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
_ => None
}
Expand Down

0 comments on commit 5fb1e6b

Please sign in to comment.