) -> Substs {
substs_from_path_segment(ctx, segment, Some(resolved.into()), false)
}
-
- pub(crate) fn from_type_bound(
- ctx: &TyLoweringContext<'_>,
- bound: &TypeBound,
- self_ty: Ty,
- ) -> Option<TraitRef> {
- match bound {
- TypeBound::Path(path) => TraitRef::from_path(ctx, path, Some(self_ty)),
- TypeBound::Lifetime(_) | TypeBound::Error => None,
- }
- }
}
impl GenericPredicate {
bound: &'a TypeBound,
self_ty: Ty,
) -> impl Iterator<Item = GenericPredicate> + 'a {
- let trait_ref = TraitRef::from_type_bound(ctx, bound, self_ty);
- iter::once(trait_ref.clone().map_or(GenericPredicate::Error, GenericPredicate::Implemented))
- .chain(
- trait_ref
- .into_iter()
- .flat_map(move |tr| assoc_type_bindings_from_type_bound(ctx, bound, tr)),
- )
+ let mut bindings = None;
+ let trait_ref = match bound {
+ TypeBound::Path(path) => {
+ bindings = TraitRef::from_path(ctx, path, Some(self_ty));
+ Some(
+ bindings.clone().map_or(GenericPredicate::Error, GenericPredicate::Implemented),
+ )
+ }
+ TypeBound::Lifetime(_) => None,
+ TypeBound::Error => Some(GenericPredicate::Error),
+ };
+ trait_ref.into_iter().chain(
+ bindings
+ .into_iter()
+ .flat_map(move |tr| assoc_type_bindings_from_type_bound(ctx, bound, tr)),
+ )
}
}
fn test(a: impl Trait + 'lifetime, b: impl 'lifetime, c: impl (Trait), d: impl ('lifetime), e: impl ?Sized, f: impl Trait + ?Sized) {}
"#,
expect![[r#"
- 23..24 'a': impl Trait + {error}
- 50..51 'b': impl {error}
+ 23..24 'a': impl Trait
+ 50..51 'b': impl
69..70 'c': impl Trait
- 86..87 'd': impl {error}
+ 86..87 'd': impl
107..108 'e': impl {error}
123..124 'f': impl Trait + {error}
147..149 '{}': ()