From 3e78a6e3e0dbe5ad2ae712ec5c94a3792745f26c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 15 Jun 2019 18:20:59 +0200 Subject: Somewhat handle variables in the derefed type, and add another test --- crates/ra_hir/src/ty/tests.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'crates/ra_hir/src/ty/tests.rs') 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) { assert_eq!(t, "(S, u128)"); } +#[test] +fn deref_trait_with_inference_var() { + // std::env::set_var("RUST_BACKTRACE", "1"); + let t = type_at( + r#" +//- /main.rs +#[lang = "deref"] +trait Deref { + type Target; + fn deref(&self) -> &Self::Target; +} + +struct Arc; +fn new_arc() -> Arc {} +impl Deref for Arc { + type Target = T; +} + +struct S; +fn foo(a: Arc) {} + +fn test() { + let a = new_arc(); + let b = (*a)<|>; + foo(a); +} +"#, + ); + assert_eq!(t, "S"); +} + 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::(file.syntax(), pos.offset).unwrap(); -- cgit v1.2.3