aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-06-16 11:21:39 +0100
committerFlorian Diebold <[email protected]>2019-06-16 11:25:04 +0100
commitad3673d8d86a9b8f1a8dba858abd7cabaa1d5776 (patch)
tree54d8ed2bf12a4c21c44fb9bec45e8c8734b25980
parent96c2b9c41d85a8bd781e2b734cac1224eb7c4694 (diff)
Add test for autoderef infinite recursion
-rw-r--r--crates/ra_hir/src/ty/tests.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 7a101d981..0fe7805e2 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2796,6 +2796,31 @@ fn test() {
2796 assert_eq!(t, "S"); 2796 assert_eq!(t, "S");
2797} 2797}
2798 2798
2799#[test]
2800fn deref_trait_infinite_recursion() {
2801 let t = type_at(
2802 r#"
2803//- /main.rs
2804#[lang = "deref"]
2805trait Deref {
2806 type Target;
2807 fn deref(&self) -> &Self::Target;
2808}
2809
2810struct S;
2811
2812impl Deref for S {
2813 type Target = S;
2814}
2815
2816fn test(s: S) {
2817 s.foo()<|>;
2818}
2819"#,
2820 );
2821 assert_eq!(t, "{unknown}");
2822}
2823
2799fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 2824fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
2800 let file = db.parse(pos.file_id).ok().unwrap(); 2825 let file = db.parse(pos.file_id).ok().unwrap();
2801 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 2826 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();