diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/ty/autoderef.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs index 11f489489..e85e558b2 100644 --- a/crates/ra_hir/src/ty/autoderef.rs +++ b/crates/ra_hir/src/ty/autoderef.rs | |||
@@ -7,7 +7,7 @@ use std::iter::successors; | |||
7 | 7 | ||
8 | use log::{info, warn}; | 8 | use log::{info, warn}; |
9 | 9 | ||
10 | use crate::{HirDatabase, Name, Resolver}; | 10 | use crate::{HirDatabase, Name, Resolver, HasGenericParams}; |
11 | use super::{traits::Solution, Ty, Canonical}; | 11 | use super::{traits::Solution, Ty, Canonical}; |
12 | 12 | ||
13 | pub(crate) fn autoderef<'a>( | 13 | pub(crate) fn autoderef<'a>( |
@@ -42,7 +42,12 @@ fn deref_by_trait( | |||
42 | }; | 42 | }; |
43 | let target = deref_trait.associated_type_by_name(db, Name::target())?; | 43 | let target = deref_trait.associated_type_by_name(db, Name::target())?; |
44 | 44 | ||
45 | // FIXME we should check that Deref has no type parameters, because we assume it below | 45 | if target.generic_params(db).count_params_including_parent() != 1 { |
46 | // the Target type + Deref trait should only have one generic parameter, | ||
47 | // namely Deref's Self type | ||
48 | return None; | ||
49 | } | ||
50 | |||
46 | // FIXME make the Canonical handling nicer | 51 | // FIXME make the Canonical handling nicer |
47 | 52 | ||
48 | let projection = super::traits::ProjectionPredicate { | 53 | let projection = super::traits::ProjectionPredicate { |