From 226e31dae94f2c72f5cf650564e521b792793629 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 26 Dec 2018 21:28:05 +0100 Subject: Add test for self type inference --- crates/ra_hir/src/ty/tests.rs | 19 +++++++++++++++++++ crates/ra_hir/src/ty/tests/data/0007_self.txt | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 crates/ra_hir/src/ty/tests/data/0007_self.txt (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 93bf431c4..fb53fcf0b 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -134,6 +134,25 @@ fn test() -> &mut &f64 { ); } +#[test] +fn infer_self() { + check_inference( + r#" +struct S; + +impl S { + fn test(&self) { + self; + } + fn test2(self: &Self) { + self; + } +} +"#, + "0007_self.txt", + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.source_file(file_id); diff --git a/crates/ra_hir/src/ty/tests/data/0007_self.txt b/crates/ra_hir/src/ty/tests/data/0007_self.txt new file mode 100644 index 000000000..18cd796c2 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/0007_self.txt @@ -0,0 +1,4 @@ +[50; 54) 'self': [unknown] +[40; 61) '{ ... }': () +[88; 109) '{ ... }': () +[98; 102) 'self': [unknown] -- cgit v1.2.3