Skip to content

Commit 1aece72

Browse files
committed
Add test for autoderef infinite recursion
1 parent 08c2ee2 commit 1aece72

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

crates/ra_hir/src/ty/tests.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,6 +2796,31 @@ fn test() {
27962796
assert_eq!(t, "S");
27972797
}
27982798

2799+
#[test]
2800+
fn deref_trait_infinite_recursion() {
2801+
let t = type_at(
2802+
r#"
2803+
//- /main.rs
2804+
#[lang = "deref"]
2805+
trait Deref {
2806+
type Target;
2807+
fn deref(&self) -> &Self::Target;
2808+
}
2809+
2810+
struct S;
2811+
2812+
impl Deref for S {
2813+
type Target = S;
2814+
}
2815+
2816+
fn test(s: S) {
2817+
s.foo()<|>;
2818+
}
2819+
"#,
2820+
);
2821+
assert_eq!(t, "{unknown}");
2822+
}
2823+
27992824
fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
28002825
let file = db.parse(pos.file_id).ok().unwrap();
28012826
let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();

0 commit comments

Comments
 (0)