aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorLenard Pratt <[email protected]>2019-04-18 19:35:47 +0100
committerLenard Pratt <[email protected]>2019-04-23 10:17:31 +0100
commit1ab7066e32ab482c70ea5c9bba7585eba275476a (patch)
treea754785d91783b713e54b70058f2f16984d25074 /crates/ra_hir/src/ty
parentce211434a6501e88cb83462f2443db085f1557d3 (diff)
Introduced resolve_macro_call on resolver
changed to manual expansion fix for nested macros
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 {