aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-09 09:04:00 +0100
committerGitHub <[email protected]>2019-09-09 09:04:00 +0100
commit1db08a54c20c244718e2378272c72ae5c6651f06 (patch)
tree90fe99eb39d045d9bac34cc200a74d0410d51763 /crates/ra_hir/src/ty
parent72259b67bf2393bec1faf6a9f95a575d6fe9cfea (diff)
parent9ed21d65fb6727f6de4961dfa440981864451af6 (diff)
Merge #1784
1784: Support textual scoped macros r=matklad a=uHOOCCOOHu Refactor the old simulation with `global_macro_scope`. Now it is quite accurate to resolve textual scoped macros. - Expand textual scoped macros in item and non-item place. - Support `#[macro_use]` on `mod`. - Textual scoped macros are collected into `nameres::ModuleScope`, so I think it makes #1727 easier to fix. - It is implemented in a simple way to `clone()` current scoped macro ids into sub-modules. Though only indices are cloned, it will still increase some resolving time. Well, I've not bench-marked yet. In my test with vscode extension, it can now successfully expand `dbg!` from `std` without `std::` prefix. "Goto definition" also works. Screenshot here: <img width="281" alt="Screenshot_20190907_043442" src="https://user-images.githubusercontent.com/14816024/64458794-ddb47900-d128-11e9-95e3-1c8569978825.png"> Co-authored-by: uHOOCCOOHu <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index c4bddde85..25716fe8c 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2803,6 +2803,41 @@ fn main() {
2803 ); 2803 );
2804} 2804}
2805 2805
2806#[test]
2807fn infer_legacy_textual_scoped_macros_expanded() {
2808 assert_snapshot!(
2809 infer(r#"
2810struct Foo(Vec<i32>);
2811
2812#[macro_use]
2813mod m {
2814 macro_rules! foo {
2815 ($($item:expr),*) => {
2816 {
2817 Foo(vec![$($item,)*])
2818 }
2819 };
2820 }
2821}
2822
2823fn main() {
2824 let x = foo!(1,2);
2825 let y = crate::foo!(1,2);
2826}
2827"#),
2828 @r###"
2829 ![0; 17) '{Foo(v...,2,])}': Foo
2830 ![1; 4) 'Foo': Foo({unknown}) -> Foo
2831 ![1; 16) 'Foo(vec![1,2,])': Foo
2832 ![5; 15) 'vec![1,2,]': {unknown}
2833 [195; 251) '{ ...,2); }': ()
2834 [205; 206) 'x': Foo
2835 [228; 229) 'y': {unknown}
2836 [232; 248) 'crate:...!(1,2)': {unknown}
2837 "###
2838 );
2839}
2840
2806#[ignore] 2841#[ignore]
2807#[test] 2842#[test]
2808fn method_resolution_trait_before_autoref() { 2843fn method_resolution_trait_before_autoref() {