Change:
No crash in stable 1.62.1, crashes with nightly 2022-07-24 and 2022-08-03 : <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
label -E-needs-mcve
Was this at least on a project you can share the source to, or was it closed source? If it's a big project that you can't minimise, then it would be good to share/link to that, so someone else can do the minimisation. an example is better than no example, even if it's not minimal.
Managed to find something. The bound seems crucially important.
searched nightlies: from nightly-2022-01-01 to nightly-2022-08-02 regressed nightly: nightly-2022-06-23 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.4</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </detailsLooks like

Discussion:
fn make_final_bounds( &self, ty_to_bounds: FxHashMap<Type, FxHashSet<GenericBound>>, <del> ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)>, </del> <ins> ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)>, </ins> lifetime_to_bounds: FxHashMap<Lifetime, FxHashSet<GenericBound>>, ) -> Vec<WherePredicate> { ty_to_bounds .into_iter() .flat_map(|(ty, mut bounds)| { <del> if let Some(data) = ty_to_fn.get(&ty) { let (poly_trait, output) = (data.0.as_ref().unwrap().clone(), data.1.as_ref().cloned().map(Box::new)); </del> <ins> if let Some((ref poly_trait, ref output)) = ty_to_fn.get(&ty) { </ins> let mut new_path = poly_trait.trait_.clone(); let last_segment = new_path.segments.pop().expect("segments were empty");

GenericArgs::Parenthesized { inputs, output } => (inputs, output), }; <ins> let output = output.as_ref().cloned().map(Box::new); </ins> if old_output.is_some() && old_output != output { <del> panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, data.1); </del> <ins> panic!("Output mismatch for {:?} {:?} {:?}", ty, old_output, output); </ins> } let new_params = GenericArgs::Parenthesized { inputs: old_input, output };

.push(PathSegment { name: last_segment.name, args: new_params }); bounds.insert(GenericBound::TraitBound( <del> PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params }, </del> <ins> PolyTrait { trait_: new_path, generic_params: poly_trait.generic_params.clone(), }, </ins> hir::TraitBoundModifier::None, )); }

let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); let mut ty_to_traits: FxHashMap<Type, FxHashSet<Path>> = Default::default(); <del> let mut ty_to_fn: FxHashMap<Type, (Option<PolyTrait>, Option<Type>)> = Default::default(); </del> <ins> let mut ty_to_fn: FxHashMap<Type, (PolyTrait, Option<Type>)> = Default::default(); </ins> for p in clean_where_predicates { let (orig_p, p) = (p, p.clean(self.cx));

if is_fn { ty_to_fn .entry(ty.clone()) <del> .and_modify(|e| *e = (Some(poly_trait.clone()), e.1.clone())) .or_insert(((Some(poly_trait.clone())), None)); </del> <ins> .and_modify(|e| *e = (poly_trait.clone(), e.1.clone())) .or_insert(((poly_trait.clone()), None)); </ins> ty_to_bounds.entry(ty.clone()).or_default(); } else {

.and_modify(|e| { *e = (e.0.clone(), Some(rhs.ty().unwrap().clone())) }) <del> .or_insert((None, Some(rhs.ty().unwrap().clone()))); </del> <ins> .or_insert(( PolyTrait { trait_: trait_.clone(), generic_params: Vec::new(), }, Some(rhs.ty().unwrap().clone()), )); </ins> continue; }

<ins> // Regression test for #100143 use std::iter::Peekable; pub struct Span<F: Fn(&i32)> { inner: Peekable<ConditionalIterator<F>>, } pub struct ConditionalIterator<F> { f: F, } // @has 'fn_bound/struct.ConditionalIterator.html' '//h3[@class="code-header in-band"]' 'impl<F: Fn(&i32)> Iterator for ConditionalIterator<F>' impl<F: Fn(&i32)> Iterator for ConditionalIterator<F> { type Item = (); fn next(&mut self) -> Option<Self::Item> { todo!() } } </ins>