diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-03 14:41:13 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-03 14:41:13 +0000 |
commit | fd84df9e1bb231f7aa4bcf760e0aff0a6bd10e9f (patch) | |
tree | 57fbfe241dcd571b9376b23260299160e0312246 /crates/hir_def/src/nameres/tests/block.rs | |
parent | 93ecef53a370703a67f87b90c4640d3e8bf73934 (diff) | |
parent | 63744fe128193464eb0ce63fbe6c30c4f98b6135 (diff) |
Merge #7541
7541: Use block_def_map in body lowering (third time's the charm) r=jonas-schievink a=jonas-schievink
After https://github.com/rust-analyzer/rust-analyzer/pull/7380 and https://github.com/rust-analyzer/rust-analyzer/pull/7506 both had to be reverted, this should have finally resolved all remaining bugs.
Most importantly, the optimization to skip `block_def_map` computation when the block contains no inner items was fixed (which fortunately was simpler than expected).
I've ran `analysis-stats` on libstd locally, which works fine, and also ran this PR locally for a short while without issues.
Note that this *still* has no (or almost no) user-facing impact, because the rest of r-a still relies on some local item support hacks.
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/nameres/tests/block.rs')
-rw-r--r-- | crates/hir_def/src/nameres/tests/block.rs | 186 |
1 files changed, 0 insertions, 186 deletions
diff --git a/crates/hir_def/src/nameres/tests/block.rs b/crates/hir_def/src/nameres/tests/block.rs deleted file mode 100644 index 6cc659513..000000000 --- a/crates/hir_def/src/nameres/tests/block.rs +++ /dev/null | |||
@@ -1,186 +0,0 @@ | |||
1 | use super::*; | ||
2 | |||
3 | #[test] | ||
4 | fn inner_item_smoke() { | ||
5 | check_at( | ||
6 | r#" | ||
7 | struct inner {} | ||
8 | fn outer() { | ||
9 | $0 | ||
10 | fn inner() {} | ||
11 | } | ||
12 | "#, | ||
13 | expect![[r#" | ||
14 | block scope | ||
15 | inner: v | ||
16 | crate | ||
17 | inner: t | ||
18 | outer: v | ||
19 | "#]], | ||
20 | ); | ||
21 | } | ||
22 | |||
23 | #[test] | ||
24 | fn use_from_crate() { | ||
25 | check_at( | ||
26 | r#" | ||
27 | struct Struct; | ||
28 | fn outer() { | ||
29 | use Struct; | ||
30 | use crate::Struct as CrateStruct; | ||
31 | use self::Struct as SelfStruct; | ||
32 | $0 | ||
33 | } | ||
34 | "#, | ||
35 | expect![[r#" | ||
36 | block scope | ||
37 | CrateStruct: t v | ||
38 | SelfStruct: t v | ||
39 | Struct: t v | ||
40 | crate | ||
41 | Struct: t v | ||
42 | outer: v | ||
43 | "#]], | ||
44 | ); | ||
45 | } | ||
46 | |||
47 | #[test] | ||
48 | fn merge_namespaces() { | ||
49 | check_at( | ||
50 | r#" | ||
51 | struct name {} | ||
52 | fn outer() { | ||
53 | fn name() {} | ||
54 | |||
55 | use name as imported; // should import both `name`s | ||
56 | |||
57 | $0 | ||
58 | } | ||
59 | "#, | ||
60 | expect![[r#" | ||
61 | block scope | ||
62 | imported: t v | ||
63 | name: v | ||
64 | crate | ||
65 | name: t | ||
66 | outer: v | ||
67 | "#]], | ||
68 | ); | ||
69 | } | ||
70 | |||
71 | #[test] | ||
72 | fn nested_blocks() { | ||
73 | check_at( | ||
74 | r#" | ||
75 | fn outer() { | ||
76 | struct inner1 {} | ||
77 | fn inner() { | ||
78 | use inner1; | ||
79 | use outer; | ||
80 | fn inner2() {} | ||
81 | $0 | ||
82 | } | ||
83 | } | ||
84 | "#, | ||
85 | expect![[r#" | ||
86 | block scope | ||
87 | inner1: t | ||
88 | inner2: v | ||
89 | outer: v | ||
90 | block scope | ||
91 | inner: v | ||
92 | inner1: t | ||
93 | crate | ||
94 | outer: v | ||
95 | "#]], | ||
96 | ); | ||
97 | } | ||
98 | |||
99 | #[test] | ||
100 | fn super_imports() { | ||
101 | check_at( | ||
102 | r#" | ||
103 | mod module { | ||
104 | fn f() { | ||
105 | use super::Struct; | ||
106 | $0 | ||
107 | } | ||
108 | } | ||
109 | |||
110 | struct Struct {} | ||
111 | "#, | ||
112 | expect![[r#" | ||
113 | block scope | ||
114 | Struct: t | ||
115 | crate | ||
116 | Struct: t | ||
117 | module: t | ||
118 | |||
119 | crate::module | ||
120 | f: v | ||
121 | "#]], | ||
122 | ); | ||
123 | } | ||
124 | |||
125 | #[test] | ||
126 | fn legacy_macro_items() { | ||
127 | // Checks that legacy-scoped `macro_rules!` from parent namespaces are resolved and expanded | ||
128 | // correctly. | ||
129 | check_at( | ||
130 | r#" | ||
131 | macro_rules! hit { | ||
132 | () => { | ||
133 | struct Hit {} | ||
134 | } | ||
135 | } | ||
136 | |||
137 | fn f() { | ||
138 | hit!(); | ||
139 | $0 | ||
140 | } | ||
141 | "#, | ||
142 | expect![[r#" | ||
143 | block scope | ||
144 | Hit: t | ||
145 | crate | ||
146 | f: v | ||
147 | "#]], | ||
148 | ); | ||
149 | } | ||
150 | |||
151 | #[test] | ||
152 | fn macro_resolve() { | ||
153 | check_at( | ||
154 | r#" | ||
155 | //- /lib.rs crate:lib deps:core | ||
156 | use core::mark; | ||
157 | |||
158 | fn f() { | ||
159 | fn nested() { | ||
160 | mark::hit!(Hit); | ||
161 | $0 | ||
162 | } | ||
163 | } | ||
164 | //- /core.rs crate:core | ||
165 | pub mod mark { | ||
166 | #[macro_export] | ||
167 | macro_rules! _hit { | ||
168 | ($name:ident) => { | ||
169 | struct $name {} | ||
170 | } | ||
171 | } | ||
172 | |||
173 | pub use crate::_hit as hit; | ||
174 | } | ||
175 | "#, | ||
176 | expect![[r#" | ||
177 | block scope | ||
178 | Hit: t | ||
179 | block scope | ||
180 | nested: v | ||
181 | crate | ||
182 | f: v | ||
183 | mark: t | ||
184 | "#]], | ||
185 | ); | ||
186 | } | ||