Add test for autoderef infinite recursion

This commit is contained in:
Florian Diebold 2019-06-16 12:21:39 +02:00
parent 96c2b9c41d
commit ad3673d8d8

View file

@ -2796,6 +2796,31 @@ fn test() {
assert_eq!(t, "S");
}
#[test]
fn deref_trait_infinite_recursion() {
let t = type_at(
r#"
//- /main.rs
#[lang = "deref"]
trait Deref {
type Target;
fn deref(&self) -> &Self::Target;
}
struct S;
impl Deref for S {
type Target = S;
}
fn test(s: S) {
s.foo()<|>;
}
"#,
);
assert_eq!(t, "{unknown}");
}
fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
let file = db.parse(pos.file_id).ok().unwrap();
let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();