]> git.lizzy.rs Git - rust.git/commitdiff
Add test for self type inference
authorFlorian Diebold <flodiebold@gmail.com>
Wed, 26 Dec 2018 20:28:05 +0000 (21:28 +0100)
committerFlorian Diebold <flodiebold@gmail.com>
Fri, 4 Jan 2019 17:28:43 +0000 (18:28 +0100)
crates/ra_hir/src/ty/tests.rs
crates/ra_hir/src/ty/tests/data/0007_self.txt [new file with mode: 0644]

index 93bf431c4d5763dc295168bb5841d6f32085476c..fb53fcf0be965fee00458bf159c3499a50af4a92 100644 (file)
@@ -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 (file)
index 0000000..18cd796
--- /dev/null
@@ -0,0 +1,4 @@
+[50; 54) 'self': [unknown]
+[40; 61) '{     ...     }': ()
+[88; 109) '{     ...     }': ()
+[98; 102) 'self': [unknown]