diff options
author | Florian Diebold <[email protected]> | 2019-06-15 17:20:59 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-06-15 17:21:23 +0100 |
commit | 3e78a6e3e0dbe5ad2ae712ec5c94a3792745f26c (patch) | |
tree | a6f46e5b38ab632474dd6f87734d9ddfa8b83757 /crates/ra_hir/src/ty/tests.rs | |
parent | ca5ed2307c6dd8396f58460652c77a6a63704e0b (diff) |
Somewhat handle variables in the derefed type, and add another test
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e587dca31..059a73900 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2766,6 +2766,37 @@ fn test(s: Arc<S>) { | |||
2766 | assert_eq!(t, "(S, u128)"); | 2766 | assert_eq!(t, "(S, u128)"); |
2767 | } | 2767 | } |
2768 | 2768 | ||
2769 | #[test] | ||
2770 | fn deref_trait_with_inference_var() { | ||
2771 | // std::env::set_var("RUST_BACKTRACE", "1"); | ||
2772 | let t = type_at( | ||
2773 | r#" | ||
2774 | //- /main.rs | ||
2775 | #[lang = "deref"] | ||
2776 | trait Deref { | ||
2777 | type Target; | ||
2778 | fn deref(&self) -> &Self::Target; | ||
2779 | } | ||
2780 | |||
2781 | struct Arc<T>; | ||
2782 | fn new_arc<T>() -> Arc<T> {} | ||
2783 | impl<T> Deref for Arc<T> { | ||
2784 | type Target = T; | ||
2785 | } | ||
2786 | |||
2787 | struct S; | ||
2788 | fn foo(a: Arc<S>) {} | ||
2789 | |||
2790 | fn test() { | ||
2791 | let a = new_arc(); | ||
2792 | let b = (*a)<|>; | ||
2793 | foo(a); | ||
2794 | } | ||
2795 | "#, | ||
2796 | ); | ||
2797 | assert_eq!(t, "S"); | ||
2798 | } | ||
2799 | |||
2769 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { | 2800 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { |
2770 | let file = db.parse(pos.file_id).ok().unwrap(); | 2801 | let file = db.parse(pos.file_id).ok().unwrap(); |
2771 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); | 2802 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); |