Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandry

Don't ICE when computing a layout of a generator tainted by errors

Fixes #80998.
This commit is contained in:
Yuki Okushi 2021-01-15 18:26:16 +09:00 committed by GitHub
commit ce06df2e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 8 deletions

View file

@ -1832,8 +1832,9 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
fn source_info(&self, cx: &CodegenCx<'ll, 'tcx>) -> Option<SourceInfo<'ll>> {
match self {
VariantInfo::Generator { def_id, variant_index, .. } => {
let span =
cx.tcx.generator_layout(*def_id).variant_source_info[*variant_index].span;
let span = cx.tcx.generator_layout(*def_id).unwrap().variant_source_info
[*variant_index]
.span;
if !span.is_dummy() {
let loc = cx.lookup_debug_loc(span.lo());
return Some(SourceInfo {