aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits/chalk.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-22 12:31:30 +0000
committerGitHub <[email protected]>2020-02-22 12:31:30 +0000
commit2cbe8a4c4be2a69b27c248ab96341c2336f983cd (patch)
treeee1a32b47f889ed132a314286cd90a07f3700216 /crates/ra_hir_ty/src/traits/chalk.rs
parent7836720f2e9a7fa01ae09ff9d51413ecd5877139 (diff)
parent5a6e770f99d1549432c1e8a1abb1aada09ad2590 (diff)
Merge #3263
3263: Implement unsizing coercions using Chalk r=matklad a=flodiebold These are coercions like `&[T; n] -> &[T]`, which are handled by the `Unsize` and `CoerceUnsized` traits. The impls for `Unsize` are all built in to the compiler and require special handling, so we need to provide them to Chalk. This adds the following `Unsize` impls: - `Unsize<[T]> for [T; _]` - `Unsize<dyn Trait> for T where T: Trait` - `Unsize<dyn SuperTrait> for dyn SubTrait` Hence we are still missing the 'unsizing the last field of a generic struct' case. Co-authored-by: Florian Diebold <[email protected]> Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk.rs')
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 1bdf13e48..e1e430aeb 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -572,8 +572,10 @@ where
572 .collect(); 572 .collect();
573 573
574 let ty: Ty = from_chalk(self.db, parameters[0].assert_ty_ref().clone()); 574 let ty: Ty = from_chalk(self.db, parameters[0].assert_ty_ref().clone());
575 let arg: Option<Ty> =
576 parameters.get(1).map(|p| from_chalk(self.db, p.assert_ty_ref().clone()));
575 577
576 builtin::get_builtin_impls(self.db, self.krate, &ty, trait_, |i| { 578 builtin::get_builtin_impls(self.db, self.krate, &ty, &arg, trait_, |i| {
577 result.push(i.to_chalk(self.db)) 579 result.push(i.to_chalk(self.db))
578 }); 580 });
579 581