Change:
let body_hir_id = self.tcx.local_def_id_to_hir_id(self.body_id); let (ident, def_scope) = self.tcx.adjust_ident_and_get_scope(field, base_def.did(), body_hir_id); <del> let mut adt_def = *base_def; let mut last_ty = None; let mut nested_fields = Vec::new(); let mut index = None; </del> // we don't care to report errors for a struct if the struct itself is tainted <del> if let Err(guar) = adt_def.non_enum_variant().has_errors() { </del> <ins> if let Err(guar) = base_def.non_enum_variant().has_errors() { </ins> return Ty::new_error(self.tcx(), guar); } <del> while let Some(idx) = self.tcx.find_field((adt_def.did(), ident)) { let &mut first_idx = index.get_or_insert(idx); let field = &adt_def.non_enum_variant().fields[idx]; let field_ty = self.field_ty(expr.span, field, args); if let Some(ty) = last_ty { nested_fields.push((ty, idx)); } if field.ident(self.tcx).normalize_to_macros_2_0() == ident { // Save the index of all fields regardless of their visibility in case // of error recovery. self.write_field_index(expr.hir_id, first_idx, nested_fields); let adjustments = self.adjust_steps(&autoderef); if field.vis.is_accessible_from(def_scope, self.tcx) { self.apply_adjustments(base, adjustments); self.register_predicates(autoderef.into_obligations()); self.tcx.check_stability( field.did, Some(expr.hir_id), expr.span, None, ); return field_ty; } private_candidate = Some((adjustments, base_def.did())); break; </del> <ins> let mut field_path = SmallVec::new(); if self.find_adt_field(*base_def, ident, &mut field_path) { let (first_idx, _) = field_path[0]; let (_, last_field) = field_path.last().unwrap(); // Save the index of all fields regardless of their visibility in case // of error recovery. let nested_fields = field_path[..] .array_windows() .map(|[(_, outer), (inner_idx, _)]| { let outer_ty = self.field_ty(expr.span, outer, args); (outer_ty, *inner_idx) }) .collect(); self.write_field_index(expr.hir_id, first_idx, nested_fields); let adjustments = self.adjust_steps(&autoderef); if last_field.vis.is_accessible_from(def_scope, self.tcx) { self.apply_adjustments(base, adjustments); self.register_predicates(autoderef.into_obligations()); self.tcx.check_stability( last_field.did, Some(expr.hir_id), expr.span, None, ); return self.field_ty(expr.span, last_field, args); </ins> } <del> last_ty = Some(field_ty); adt_def = field_ty.ty_adt_def().expect("expect Adt for unnamed field"); </del> <ins> // The field is not accessible, fall through to error reporting. private_candidate = Some((adjustments, base_def.did())); </ins> } } ty::Tuple(tys) => {

Discussion:
<!-- [31mICE[0m: Rustc '-Zincremental-verify-ich=yes -Cincremental=<dir-Cdebuginfo=2' 'thread 'rustc' panicked at 'forcing query with already existing '', 'thread 'rustc' panicked at 'forcing query with already existing '' File: --auto-reduced (treereduce-rust): &lt;details&lt;summary&lt;strongoriginal code&lt;/strong&lt;/summary&lt;poriginal: </p</detailsVersion information ` Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 [findfield] find the index of maybe nested field in [typeck] type-checking [analysis] running analysis passes on this crate --
This bisects to :thinking:
WG-prioritization assigning priority (). cc: + for label -I-prioritize +P-medium
I'm going to fix it in (still WIP), where the query will be removed.
Testing out on this issue:
I seems like does not have proper or impls, possibly due to the differing . Are you familiar with that part of spans?