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.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 25dad81eb..c12326643 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -3,7 +3,6 @@ use std::sync::Arc;
3 3
4use insta::assert_snapshot; 4use insta::assert_snapshot;
5 5
6use ra_cfg::CfgOptions;
7use ra_db::{salsa::Database, FilePosition, SourceDatabase}; 6use ra_db::{salsa::Database, FilePosition, SourceDatabase};
8use ra_syntax::{ 7use ra_syntax::{
9 algo, 8 algo,
@@ -62,7 +61,7 @@ impl S {
62"#, 61"#,
63 ); 62 );
64 db.set_crate_graph_from_fixture(crate_graph! { 63 db.set_crate_graph_from_fixture(crate_graph! {
65 "main": ("/main.rs", ["foo"], CfgOptions::default().atom("test".into())), 64 "main": ("/main.rs", ["foo"], cfg = { "test" }),
66 "foo": ("/foo.rs", []), 65 "foo": ("/foo.rs", []),
67 }); 66 });
68 assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos)); 67 assert_eq!("(i32, {unknown}, i32, {unknown})", type_at_pos(&db, pos));
@@ -135,6 +134,25 @@ mod boxed {
135} 134}
136 135
137#[test] 136#[test]
137fn infer_adt_self() {
138 let (db, pos) = MockDatabase::with_position(
139 r#"
140//- /main.rs
141enum Nat { Succ(Self), Demo(Nat), Zero }
142
143fn test() {
144 let foo: Nat = Nat::Zero;
145 if let Nat::Succ(x) = foo {
146 x<|>
147 }
148}
149
150"#,
151 );
152 assert_eq!("Nat", type_at_pos(&db, pos));
153}
154
155#[test]
138fn infer_try() { 156fn infer_try() {
139 let (mut db, pos) = MockDatabase::with_position( 157 let (mut db, pos) = MockDatabase::with_position(
140 r#" 158 r#"