aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 54b2a8c16..e587dca31 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2737,6 +2737,35 @@ fn main() {
2737 assert_eq!(t, "Foo"); 2737 assert_eq!(t, "Foo");
2738} 2738}
2739 2739
2740#[test]
2741fn deref_trait() {
2742 let t = type_at(
2743 r#"
2744//- /main.rs
2745#[lang = "deref"]
2746trait Deref {
2747 type Target;
2748 fn deref(&self) -> &Self::Target;
2749}
2750
2751struct Arc<T>;
2752impl<T> Deref for Arc<T> {
2753 type Target = T;
2754}
2755
2756struct S;
2757impl S {
2758 fn foo(&self) -> u128 {}
2759}
2760
2761fn test(s: Arc<S>) {
2762 (*s, s.foo())<|>
2763}
2764"#,
2765 );
2766 assert_eq!(t, "(S, u128)");
2767}
2768
2740fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 2769fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
2741 let file = db.parse(pos.file_id).ok().unwrap(); 2770 let file = db.parse(pos.file_id).ok().unwrap();
2742 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 2771 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();