Skip to content

Commit 94a6aff

Browse files
committed
Check that Deref has the right number of parameters
1 parent 3e78a6e commit 94a6aff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/ra_hir/src/ty/autoderef.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::iter::successors;
77

88
use log::{info, warn};
99

10-
use crate::{HirDatabase, Name, Resolver};
10+
use crate::{HirDatabase, Name, Resolver, HasGenericParams};
1111
use super::{traits::Solution, Ty, Canonical};
1212

1313
pub(crate) fn autoderef<'a>(
@@ -42,7 +42,12 @@ fn deref_by_trait(
4242
};
4343
let target = deref_trait.associated_type_by_name(db, Name::target())?;
4444

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+
4651
// FIXME make the Canonical handling nicer
4752

4853
let projection = super::traits::ProjectionPredicate {

0 commit comments

Comments
 (0)