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.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index f74d6f5ea..cb8d6351d 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -166,10 +166,15 @@ fn test(x: SomeType) {
166 let d: i128 = -a; 166 let d: i128 = -a;
167 let e = -100; 167 let e = -100;
168 let f = !!!true; 168 let f = !!!true;
169 let g = !42;
170 let h = !10u32;
171 let j = !a;
169 -3.14; 172 -3.14;
173 !3;
170 -x; 174 -x;
171 !x; 175 !x;
172 -"hello"; 176 -"hello";
177 !"hello";
173} 178}
174"#, 179"#,
175 ); 180 );
@@ -366,6 +371,7 @@ fn test(x: &str, y: isize) {
366 371
367 let b = [a, ["b"]]; 372 let b = [a, ["b"]];
368 let x: [u8; 0] = []; 373 let x: [u8; 0] = [];
374 let z: &[u8] = &[1, 2, 3];
369} 375}
370"#, 376"#,
371 ); 377 );
@@ -421,7 +427,8 @@ fn test() {
421 427
422 match e { 428 match e {
423 E::A { x } => x, 429 E::A { x } => x,
424 E::B => 1, 430 E::B if foo => 1,
431 E::B => 10,
425 }; 432 };
426 433
427 let ref d @ E::A { .. } = e; 434 let ref d @ E::A { .. } = e;
@@ -594,6 +601,29 @@ fn test() {
594 ); 601 );
595} 602}
596 603
604#[test]
605fn infer_type_param() {
606 check_inference(
607 "infer_type_param",
608 r#"
609fn id<T>(x: T) -> T {
610 x
611}
612
613fn clone<T>(x: &T) -> T {
614 x
615}
616
617fn test() {
618 let y = 10u32;
619 id(y);
620 let x: bool = clone(z);
621 id::<i128>(1);
622}
623"#,
624 );
625}
626
597fn infer(content: &str) -> String { 627fn infer(content: &str) -> String {
598 let (db, _, file_id) = MockDatabase::with_single_file(content); 628 let (db, _, file_id) = MockDatabase::with_single_file(content);
599 let source_file = db.parse(file_id); 629 let source_file = db.parse(file_id);