aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-23 13:49:31 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-23 13:49:31 +0100
commita094d5c621e44ff78dce953c0cae7cfba4b2840e (patch)
tree93d12337483968512db038b0b89aff7b9ef4eb20 /crates/ra_hir/src/ty
parente2835b46f6928eda21b7edb44f305f20473a3a98 (diff)
parent1ab7066e32ab482c70ea5c9bba7585eba275476a (diff)
Merge #1147
1147: Handle macros in type checking / HIR r=matklad a=Lapz An other attempt at #1102. I will need to flatten the nested if statements and im also not sure if the way that i get the resolver and module will always work Co-authored-by: Lenard Pratt <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index a4c99528d..c76a5012f 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2417,6 +2417,30 @@ fn test() -> u64 {
2417 ); 2417 );
2418} 2418}
2419 2419
2420#[test]
2421fn infer_macros_expanded() {
2422 assert_snapshot_matches!(
2423 infer(r#"
2424struct Foo(Vec<i32>);
2425
2426macro_rules! foo {
2427 ($($item:expr),*) => {
2428 {
2429 Foo(vec![$($item,)*])
2430 }
2431 };
2432}
2433
2434fn main() {
2435 let x = foo!(1,2);
2436}
2437"#),
2438 @r###"
2439[156; 182) '{ ...,2); }': ()
2440[166; 167) 'x': Foo"###
2441 );
2442}
2443
2420#[ignore] 2444#[ignore]
2421#[test] 2445#[test]
2422fn method_resolution_trait_before_autoref() { 2446fn method_resolution_trait_before_autoref() {
@@ -2510,6 +2534,7 @@ fn type_at(content: &str) -> String {
2510fn infer(content: &str) -> String { 2534fn infer(content: &str) -> String {
2511 let (db, _, file_id) = MockDatabase::with_single_file(content); 2535 let (db, _, file_id) = MockDatabase::with_single_file(content);
2512 let source_file = db.parse(file_id); 2536 let source_file = db.parse(file_id);
2537
2513 let mut acc = String::new(); 2538 let mut acc = String::new();
2514 acc.push_str("\n"); 2539 acc.push_str("\n");
2515 2540
@@ -2532,6 +2557,7 @@ fn infer(content: &str) -> String {
2532 }; 2557 };
2533 types.push((syntax_ptr, ty)); 2558 types.push((syntax_ptr, ty));
2534 } 2559 }
2560
2535 // sort ranges for consistency 2561 // sort ranges for consistency
2536 types.sort_by_key(|(ptr, _)| (ptr.range().start(), ptr.range().end())); 2562 types.sort_by_key(|(ptr, _)| (ptr.range().start(), ptr.range().end()));
2537 for (syntax_ptr, ty) in &types { 2563 for (syntax_ptr, ty) in &types {