6195: Shorten iterators in associated params r=matklad a=SomeoneToIgnore

Applies the same iterator-shortening logic to the iterator associated types, recursively.

Before: 
![image](https://user-images.githubusercontent.com/2690773/95662735-e6ecf200-0b41-11eb-8e54-28493ad4e644.png)

After:
<img width="1192" alt="image" src="https://user-images.githubusercontent.com/2690773/95662894-e9038080-0b42-11eb-897d-527571ccac58.png">


Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
bors[bot] 2020-10-12 15:06:45 +00:00 committed by GitHub
commit fac59f4f28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 30 deletions

View file

@ -1389,7 +1389,7 @@ impl Type {
r#trait: Trait,
args: &[Type],
alias: TypeAlias,
) -> Option<Ty> {
) -> Option<Type> {
let subst = Substs::build_for_def(db, r#trait.id)
.push(self.ty.value.clone())
.fill(args.iter().map(|t| t.ty.value.clone()))
@ -1410,6 +1410,10 @@ impl Type {
Solution::Unique(SolutionVariables(subst)) => subst.value.first().cloned(),
Solution::Ambig(_) => None,
}
.map(|ty| Type {
krate: self.krate,
ty: InEnvironment { value: ty, environment: Arc::clone(&self.ty.environment) },
})
}
pub fn is_copy(&self, db: &dyn HirDatabase) -> bool {