Skip to content

Commit e6b6234

Browse files
committed
librustc: Try looking in tuple fields for nullable enum opt.
1 parent e954fc4 commit e6b6234

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
@@ -375,6 +375,21 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Optio
375375
None
376376
},
377377

378+
// Can we use one of the fields in this tuple?
379+
ty::ty_tup(ref tys) => {
380+
for (j, &ty) in tys.iter().enumerate() {
381+
match find_discr_field_candidate(tcx, ty) {
382+
Some(v) => {
383+
let mut discrfield = vec![j];
384+
discrfield.extend(v.into_iter());
385+
return Some(discrfield);
386+
}
387+
None => continue
388+
}
389+
}
390+
None
391+
},
392+
378393
// Anything else is not a pointer
379394
_ => None
380395
}

0 commit comments

Comments
 (0)