diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-15 12:15:09 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-15 12:15:09 +0000 |
commit | efa72c899d0c1e628d2e944cac91ac3266da2c59 (patch) | |
tree | 5ddbf69ebecbba36403358829ba63c22a3046dd1 /crates/ra_hir_ty | |
parent | 5429e6831c7a59425b37dec475f153848254a87d (diff) | |
parent | fe78a14bbb9769c8ccd5cc41415702f5176a8e88 (diff) |
Merge #3591
3591: Support local macro_rules r=matklad a=edwin0cheng
This PR implement local `macro_rules` in function body, by adding following things:
1. While lowering, add a `MacroDefId` in body's `ItemScope` as a textual legacy macro.
2. Make `Expander::enter_expand` search with given `ItemScope`.
3. Make `Resolver::resolve_path_as_macro` search with `LocalItemScope`.
Fix #2181
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/tests/macros.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 32457bbf7..3b7022ad5 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs | |||
@@ -363,6 +363,26 @@ fn main() { | |||
363 | } | 363 | } |
364 | 364 | ||
365 | #[test] | 365 | #[test] |
366 | fn infer_local_macro() { | ||
367 | assert_snapshot!( | ||
368 | infer(r#" | ||
369 | fn main() { | ||
370 | macro_rules! foo { | ||
371 | () => { 1usize } | ||
372 | } | ||
373 | let _a = foo!(); | ||
374 | } | ||
375 | "#), | ||
376 | @r###" | ||
377 | ![0; 6) '1usize': usize | ||
378 | [11; 90) '{ ...!(); }': () | ||
379 | [17; 66) 'macro_... }': {unknown} | ||
380 | [75; 77) '_a': usize | ||
381 | "### | ||
382 | ); | ||
383 | } | ||
384 | |||
385 | #[test] | ||
366 | fn infer_builtin_macros_line() { | 386 | fn infer_builtin_macros_line() { |
367 | assert_snapshot!( | 387 | assert_snapshot!( |
368 | infer(r#" | 388 | infer(r#" |