aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-06-15 17:33:30 +0100
committerFlorian Diebold <[email protected]>2019-06-15 17:33:30 +0100
commit94a6aff9f86de0b670670baf36b95bc881d87ccc (patch)
treeb799e017672ae1d3e168a56c272c9afbb8028f4c /crates/ra_hir/src/ty
parent3e78a6e3e0dbe5ad2ae712ec5c94a3792745f26c (diff)
Check that Deref has the right number of parameters
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs9
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
8use log::{info, warn}; 8use log::{info, warn};
9 9
10use crate::{HirDatabase, Name, Resolver}; 10use crate::{HirDatabase, Name, Resolver, HasGenericParams};
11use super::{traits::Solution, Ty, Canonical}; 11use super::{traits::Solution, Ty, Canonical};
12 12
13pub(crate) fn autoderef<'a>( 13pub(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 {