Make variant_fields inner an IndexVec
This commit is contained in:
parent
9ef2c30a1a
commit
f7c2f2475a
@ -2997,7 +2997,7 @@ pub struct UnsafetyCheckResult {
|
||||
/// The layout of generator state
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub struct GeneratorLayout<'tcx> {
|
||||
pub variant_fields: IndexVec<VariantIdx, Vec<LocalDecl<'tcx>>>,
|
||||
pub variant_fields: IndexVec<VariantIdx, IndexVec<Field, LocalDecl<'tcx>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
|
||||
|
@ -1598,7 +1598,7 @@ impl<'tcx> VariantInfo<'tcx> {
|
||||
Some(variant.fields[i].ident.to_string()),
|
||||
VariantInfo::Generator(_, generator_layout, variant_index) => {
|
||||
let variant_decls = &generator_layout.variant_fields[*variant_index];
|
||||
variant_decls[i].name.map(|name| name.to_string())
|
||||
variant_decls[i.into()].name.map(|name| name.to_string())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ use rustc::ty::GeneratorSubsts;
|
||||
use rustc::ty::layout::VariantIdx;
|
||||
use rustc::ty::subst::SubstsRef;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
|
||||
use rustc_data_structures::bit_set::BitSet;
|
||||
use std::borrow::Cow;
|
||||
use std::iter;
|
||||
@ -560,7 +560,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}).unzip();
|
||||
|
||||
// Put every var in each variant, for now.
|
||||
let empty_variants = iter::repeat(vec![]).take(3);
|
||||
let empty_variants = iter::repeat(IndexVec::new()).take(3);
|
||||
let state_variants = iter::repeat(vars).take(suspending_blocks.count());
|
||||
let layout = GeneratorLayout {
|
||||
variant_fields: empty_variants.chain(state_variants).collect()
|
||||
|
Loading…
Reference in New Issue
Block a user