diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 26 |
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] | ||
2421 | fn infer_macros_expanded() { | ||
2422 | assert_snapshot_matches!( | ||
2423 | infer(r#" | ||
2424 | struct Foo(Vec<i32>); | ||
2425 | |||
2426 | macro_rules! foo { | ||
2427 | ($($item:expr),*) => { | ||
2428 | { | ||
2429 | Foo(vec![$($item,)*]) | ||
2430 | } | ||
2431 | }; | ||
2432 | } | ||
2433 | |||
2434 | fn 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] |
2422 | fn method_resolution_trait_before_autoref() { | 2446 | fn method_resolution_trait_before_autoref() { |
@@ -2510,6 +2534,7 @@ fn type_at(content: &str) -> String { | |||
2510 | fn infer(content: &str) -> String { | 2534 | fn 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 { |