Change:
Unfortunately the error message is super thin and I can't provide the source of the project. Therefore it's also hard to provide a minimal reproducible example. Some hints: Yesterdays nightly (nightly-2019-06-11-x8664-apple-darwin) doesn't ICE The project makes heavy use of async/await. Therefore it might by related to that. I wondered whether it's about generator optimization from . However I also checked that out locally from their branch 2 days ago and built it myself, and it didn't crash. At that point I had all commits up to "Extract generatorlayout as a method" included, only the last commit which was later was missing.
Could you please test your code out with in (you'll need to build rustc yourself) and provide the more extensive backtrace?
I tried running that over the afternoon. Unfortunately something went wrong: Unfortunately that happened after around 1.5 hours of compilation. This machine here is definitely too slow for doing any reasonable rustc compilation :'(
Got it running by deleting enough libraries and rebuilding. Unfortunately it just prints exactly the same error message. I think the setting might already had been enabled as far as I can derive from the compiler output above:
I played around with my code and deleted stuff until I got a simple repro: It seems like the combination of the member function together with the closure parameter might be the culprit. A top level or a a "static" member function (without ) doesn't cause an ICE. This also crashes if is not an async function and thereby no is included at all:
Reduction of version: Reduction of non- version:
Note that you only need to get the backtrace ( is much more expensive). Maybe we even have builds with that enabled nowadays? Not sure though. EDIT: also, someone needs to do this on linux, the backtraces are probably broken on macOS.
triage: leaving unprioritized; assigning to with intent that they attach priority label as well as any Async-Await specific labels. Leaving nomination tag but hoping I'll remember to skip over it at this week's meeting.
Hi, any temporally way to check on this? My build for tests (just build, just tests) have been failed for days and I have no idea which part of my code caused this in a large code base.
I also see this in my project. I built my own compiler with enabled for now, In case anyone is interested, this is what I get when building the non- version :
I've been investigating, and I believe this is caused by a subtle bug in . (EDIT: In short, we weren't listing ZST fields at the beginning of the layout anymore.) The reason didn't reproduce in their checkout of the branch is likely that the bug didn't show up until one of the last changes I made to the branch, responding to final review feedback before merging. Working on a fix and will have it up soon with more details.
Opened .

Discussion:
Prefixed(Size, Align), } <ins> // Invert a bijective mapping, i.e. `invert(map)[y] = x` if `map[x] = y`. // This is used to go between `memory_index` (source field order to memory order) // and `inverse_memory_index` (memory order to source field order). // See also `FieldPlacement::Arbitrary::memory_index` for more details. // FIXME(eddyb) build a better abstraction for permutations, if possible. fn invert_mapping(map: &[u32]) -> Vec<u32> { let mut inverse = vec![0; map.len()]; for i in 0..map.len() { inverse[map[i] as usize] = i as u32; } inverse } </ins> impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { fn scalar_pair(&self, a: Scalar, b: Scalar) -> LayoutDetails { let dl = self.data_layout();

// That is, if field 5 has offset 0, the first element of inverse_memory_index is 5. // We now write field offsets to the corresponding offset slot; // field 5 with offset 0 puts 0 in offsets[5]. <del> // At the bottom of this function, we use inverse_memory_index to produce memory_index. </del> <ins> // At the bottom of this function, we invert `inverse_memory_index` to // produce `memory_index` (see `invert_mapping`). </ins> let mut offset = Size::ZERO;

// Field 5 would be the first element, so memory_index is i: // Note: if we didn't optimize, it's already right. <del> let mut memory_index; </del> <ins> let memory_index; </ins> if optimize { <del> memory_index = vec![0; inverse_memory_index.len()]; for i in 0..inverse_memory_index.len() { memory_index[inverse_memory_index[i] as usize]  = i as u32; } </del> <ins> memory_index = invert_mapping(&inverse_memory_index); </ins> } else { memory_index = inverse_memory_index; }

) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { use SavedLocalEligibility::*; let tcx = self.tcx; <del> let recompute_memory_index = |offsets: &[Size]| -> Vec<u32> { debug!("recompute_memory_index({:?})", offsets); let mut inverse_index = (0..offsets.len() as u32).collect::<Vec<_>>(); inverse_index.sort_unstable_by_key(|i| offsets[*i as usize]); let mut index = vec![0; offsets.len()]; for i in 0..index.len() { index[inverse_index[i] as usize] = i as u32; } debug!("recompute_memory_index() => {:?}", index); index }; </del> let subst_field = |ty: Ty<'tcx>| { ty.subst(tcx, substs.substs) }; let info = tcx.generator_layout(def_id);

// get included in each variant that requested them in // GeneratorLayout. debug!("prefix = {:#?}", prefix); <del> let (outer_fields, promoted_offsets) = match prefix.fields { FieldPlacement::Arbitrary { mut offsets, .. } => { let offsets_b = offsets.split_off(discr_index + 1); </del> <ins> let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields { FieldPlacement::Arbitrary { mut offsets, memory_index } => { let mut inverse_memory_index = invert_mapping(&memory_index); // "a" (`0..b_start`) and "b" (`b_start..`) correspond to // "outer" and "promoted" fields respectively. let b_start = (discr_index + 1) as u32; let offsets_b = offsets.split_off(b_start as usize); </ins> let offsets_a = offsets; <del> let memory_index = recompute_memory_index(&offsets_a); let outer_fields = FieldPlacement::Arbitrary { offsets: offsets_a, memory_index }; (outer_fields, offsets_b) </del> <ins> // Disentangle the "a" and "b" components of `inverse_memory_index` // by preserving the order but keeping only one disjoint "half" each. // FIXME(eddyb) build a better abstraction for permutations, if possible. let inverse_memory_index_b: Vec<_> = inverse_memory_index.iter().filter_map(|&i| i.checked_sub(b_start)).collect(); inverse_memory_index.retain(|&i| i < b_start); let inverse_memory_index_a = inverse_memory_index; // Since `inverse_memory_index_{a,b}` each only refer to their // respective fields, they can be safely inverted let memory_index_a = invert_mapping(&inverse_memory_index_a); let memory_index_b = invert_mapping(&inverse_memory_index_b); let outer_fields = FieldPlacement::Arbitrary { offsets: offsets_a, memory_index: memory_index_a, }; (outer_fields, offsets_b, memory_index_b) </ins> } _ => bug!(), };

StructKind::Prefixed(prefix_size, prefix_align.abi))?; variant.variants = Variants::Single { index }; <del> let offsets = match variant.fields { FieldPlacement::Arbitrary { offsets, .. } => offsets, </del> <ins> let (offsets, memory_index) = match variant.fields { FieldPlacement::Arbitrary { offsets, memory_index } => { (offsets, memory_index) } </ins> _ => bug!(), }; // Now, stitch the promoted and variant-only fields back together in // the order they are mentioned by our GeneratorLayout. <del> let mut next_variant_field = 0; let mut combined_offsets = Vec::new(); for local in variant_fields.iter() { match assignments[*local] { </del> <ins> // Because we only use some subset (that can differ between variants) // of the promoted fields, we can't just pick those elements of the // `promoted_memory_index` (as we'd end up with gaps). // So instead, we build an "inverse memory_index", as if all of the // promoted fields were being used, but leave the elements not in the // subset as `INVALID_FIELD_IDX`, which we can filter out later to // obtain a valid (bijective) mapping. const INVALID_FIELD_IDX: u32 = !0; let mut combined_inverse_memory_index = vec![INVALID_FIELD_IDX; promoted_memory_index.len() + memory_index.len()]; let mut offsets_and_memory_index = offsets.into_iter().zip(memory_index); let combined_offsets = variant_fields.iter().enumerate().map(|(i, local)| { let (offset, memory_index) = match assignments[*local] { </ins> Unassigned => bug!(), Assigned(_) => { <del> combined_offsets.push(offsets[next_variant_field]); next_variant_field += 1; </del> <ins> let (offset, memory_index) = offsets_and_memory_index.next().unwrap(); (offset, promoted_memory_index.len() as u32 + memory_index) </ins> } Ineligible(field_idx) => { let field_idx = field_idx.unwrap() as usize; <del> combined_offsets.push(promoted_offsets[field_idx]); </del> <ins> (promoted_offsets[field_idx], promoted_memory_index[field_idx]) </ins> } <del> } } let memory_index = recompute_memory_index(&combined_offsets); variant.fields = FieldPlacement::Arbitrary { offsets: combined_offsets, memory_index }; </del> <ins> }; combined_inverse_memory_index[memory_index as usize] = i as u32; offset }).collect(); // Remove the unused slots and invert the mapping to obtain the // combined `memory_index` (also see previous comment). combined_inverse_memory_index.retain(|&i| i != INVALID_FIELD_IDX); let combined_memory_index = invert_mapping(&combined_inverse_memory_index); variant.fields = FieldPlacement::Arbitrary { offsets: combined_offsets, memory_index: combined_memory_index, }; </ins> size = size.max(variant.size); align = align.max(variant.align);

offsets: Vec<Size>, /// Maps source order field indices to memory order indices, <del> /// depending how fields were permuted. </del> <ins> /// depending on how the fields were reordered (if at all). /// This is a permutation, with both the source order and the /// memory order using the same (0..n) index ranges. /// /// Note that during computation of `memory_index`, sometimes /// it is easier to operate on the inverse mapping (that is, /// from memory order to source order), and that is usually /// named `inverse_memory_index`. /// // FIXME(eddyb) build a better abstraction for permutations, if possible. </ins> // FIXME(camlorn) also consider small vector  optimization here. memory_index: Vec<u32> }

<ins> // This testcase used to ICE in codegen due to inconsistent field reordering // in the generator state, claiming a ZST field was after a non-ZST field, // while those two fields were at the same offset (which is impossible). // That is, memory ordering of `(X, ())`, but offsets of `((), X)`. // compile-pass // edition:2018 #![feature(async_await)] #![allow(unused)] async fn foo<F>(_: &(), _: F) {} fn main() { foo(&(), || {}); async { foo(&(), || {}).await; }; } </ins>