diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-12 16:06:45 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-12 16:06:45 +0100 |
commit | fac59f4f28e3ede6c88999aa43d28e7caa7df3a7 (patch) | |
tree | bbbc1905a320794c381fb7a488e40bcd2cabfbcc /crates/hir | |
parent | 44df0e2a9febc3caece861f2ddbbc6ff377ccb54 (diff) | |
parent | 2bb80a4f0350045503258518d354a4e63e4c68fd (diff) |
Merge #6195
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 <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/code_model.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 650b4fa40..a101d724e 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -1389,7 +1389,7 @@ impl Type { | |||
1389 | r#trait: Trait, | 1389 | r#trait: Trait, |
1390 | args: &[Type], | 1390 | args: &[Type], |
1391 | alias: TypeAlias, | 1391 | alias: TypeAlias, |
1392 | ) -> Option<Ty> { | 1392 | ) -> Option<Type> { |
1393 | let subst = Substs::build_for_def(db, r#trait.id) | 1393 | let subst = Substs::build_for_def(db, r#trait.id) |
1394 | .push(self.ty.value.clone()) | 1394 | .push(self.ty.value.clone()) |
1395 | .fill(args.iter().map(|t| t.ty.value.clone())) | 1395 | .fill(args.iter().map(|t| t.ty.value.clone())) |
@@ -1410,6 +1410,10 @@ impl Type { | |||
1410 | Solution::Unique(SolutionVariables(subst)) => subst.value.first().cloned(), | 1410 | Solution::Unique(SolutionVariables(subst)) => subst.value.first().cloned(), |
1411 | Solution::Ambig(_) => None, | 1411 | Solution::Ambig(_) => None, |
1412 | } | 1412 | } |
1413 | .map(|ty| Type { | ||
1414 | krate: self.krate, | ||
1415 | ty: InEnvironment { value: ty, environment: Arc::clone(&self.ty.environment) }, | ||
1416 | }) | ||
1413 | } | 1417 | } |
1414 | 1418 | ||
1415 | pub fn is_copy(&self, db: &dyn HirDatabase) -> bool { | 1419 | pub fn is_copy(&self, db: &dyn HirDatabase) -> bool { |