Change:
: The bug seems to be present in the latest nightly at well as stable. <details<summary<strongBacktrace</strong</summary<p</p</details
It seems like this has something to do with appearing multiple times, once in 's bound, then again in 's. Switching the order of the two bounds seems to avoid the error.
Regression in nightly-2021-07-25 commit[0] 2021-07-23: Auto merge of - JohnTitor:rollup-dht22jk, r=JohnTitor commit[1] 2021-07-23: Auto merge of - JohnTitor:get-by-key-enum-part-2, r=oli-obk commit[2] 2021-07-24: Auto merge of - SparrowLii:MaybeTrait, r=wesleywiser commit[3] 2021-07-24: Auto merge of - Mark-Simulacrum:bump-version, r=Mark-Simulacrum commit[4] 2021-07-24: Auto merge of - In-line:zircon-thread-name, r=JohnTitor commit[5] 2021-07-24: Auto merge of - crlf0710:rich_vtable, r=nikomatsakis commit[6] 2021-07-24: Auto merge of - Aaron1011:inert-warn, r=petrochenkov commit[7] 2021-07-24: Auto merge of - Manishearth:rollup-b09njin, r=Manishearth commit[8] 2021-07-24: Auto merge of - BoxyUwU:cgd-subst-ice, r=nikomatsakis

Discussion:
result.flags } <ins> pub fn bound_var_flags(vars: &ty::List<ty::BoundVariableKind>) -> FlagComputation { let mut computation = FlagComputation::new(); for bv in vars { match bv { ty::BoundVariableKind::Ty(_) => { computation.flags |= TypeFlags::HAS_TY_LATE_BOUND; } ty::BoundVariableKind::Region(_) => { computation.flags |= TypeFlags::HAS_RE_LATE_BOUND; } ty::BoundVariableKind::Const => { computation.flags |= TypeFlags::HAS_CT_LATE_BOUND; } } } computation } </ins> fn add_flags(&mut self, flags: TypeFlags) { self.flags = self.flags | flags; }

where F: FnOnce(&mut Self, T), { <del> let mut computation = FlagComputation::new(); for bv in value.bound_vars() { match bv { ty::BoundVariableKind::Ty(_) => { computation.flags |= TypeFlags::HAS_TY_LATE_BOUND; } ty::BoundVariableKind::Region(_) => { computation.flags |= TypeFlags::HAS_RE_LATE_BOUND; } ty::BoundVariableKind::Const => { computation.flags |= TypeFlags::HAS_CT_LATE_BOUND; } } } </del> <ins> let mut computation = FlagComputation::bound_var_flags(value.bound_vars()); </ins> f(&mut computation, value.skip_binder());

// `Ty`/`Const`/`Predicate`, but not within those types. This is because the // type flags at the outer layer are enough. So it's faster than it first // looks, particular for `Ty`/`Predicate` where it's just a field access. <ins> // // N.B. The only case where this isn't totally true is binders, which also // add `HAS_{RE,TY,CT}_LATE_BOUND` flag depending on the *bound variables* that // are present, regardless of whether those bound variables are used. This // is important for anonymization of binders in `TyCtxt::erase_regions`. We // specifically detect this case in `visit_binder`. </ins> impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for HasTypeFlagsVisitor { type BreakTy = FoundFlags; <ins> fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow<Self::BreakTy> { // If we're looking for any of the HAS_*_LATE_BOUND flags, we need to // additionally consider the bound vars on the binder itself, even if // the contents of a the binder (e.g. a `TraitRef`) doesn't reference // the bound vars. if self.flags.intersects(TypeFlags::HAS_LATE_BOUND) { let bound_var_flags = FlagComputation::bound_var_flags(t.bound_vars()); if bound_var_flags.flags.intersects(self.flags) { return ControlFlow::Break(FoundFlags); } } t.super_visit_with(self) } </ins> #[inline] fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { // Note: no `super_visit_with` call.

<ins> // build-pass // issue: #115807 trait Chip: for<'a> TraitWithLifetime<'a> + SomeMarker { fn compute(&self); } trait SomeMarker {} trait TraitWithLifetime<'a>: SomeMarker {} trait Machine { fn run(); } struct BasicMachine; impl Machine for BasicMachine { fn run() { let chips: [&dyn Chip; 0] = []; let _ = chips.map(|chip| chip.compute()); } } fn main() { BasicMachine::run(); } </ins>