Skip to content

Commit 054a256

Browse files
committed
librustc: Try looking in tuple fields for nullable enum opt.
1 parent 3d7a446 commit 054a256

File tree

1 file changed

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

1 file changed

+15
-0
lines changed

src/librustc_trans/trans/adt.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,21 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
323323
None
324324
},
325325

326+
// Can we use one of the fields in this tuple?
327+
ty::ty_tup(ref tys) => {
328+
for (j, &ty) in tys.iter().enumerate() {
329+
match find_discr_field_candidate(tcx, ty) {
330+
Some(v) => {
331+
let mut discrfield = vec![j];
332+
discrfield.extend(v.into_iter());
333+
return Some(discrfield);
334+
}
335+
None => continue
336+
}
337+
}
338+
None
339+
},
340+
326341
// Anything else is not a pointer
327342
_ => None
328343
}

0 commit comments

Comments
 (0)