From 94a6aff9f86de0b670670baf36b95bc881d87ccc Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 15 Jun 2019 18:33:30 +0200 Subject: Check that Deref has the right number of parameters --- crates/ra_hir/src/ty/autoderef.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src') 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; use log::{info, warn}; -use crate::{HirDatabase, Name, Resolver}; +use crate::{HirDatabase, Name, Resolver, HasGenericParams}; use super::{traits::Solution, Ty, Canonical}; pub(crate) fn autoderef<'a>( @@ -42,7 +42,12 @@ fn deref_by_trait( }; let target = deref_trait.associated_type_by_name(db, Name::target())?; - // FIXME we should check that Deref has no type parameters, because we assume it below + if target.generic_params(db).count_params_including_parent() != 1 { + // the Target type + Deref trait should only have one generic parameter, + // namely Deref's Self type + return None; + } + // FIXME make the Canonical handling nicer let projection = super::traits::ProjectionPredicate { -- cgit v1.2.3