aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/body/tests')
-rw-r--r--crates/hir_def/src/body/tests/block.rs187
1 files changed, 0 insertions, 187 deletions
diff --git a/crates/hir_def/src/body/tests/block.rs b/crates/hir_def/src/body/tests/block.rs
deleted file mode 100644
index 6b1ed2555..000000000
--- a/crates/hir_def/src/body/tests/block.rs
+++ /dev/null
@@ -1,187 +0,0 @@
1use super::*;
2use expect_test::expect;
3
4#[test]
5fn inner_item_smoke() {
6 check_at(
7 r#"
8struct inner {}
9fn outer() {
10 $0
11 fn inner() {}
12}
13"#,
14 expect![[r#"
15 block scope
16 inner: v
17 crate
18 inner: t
19 outer: v
20 "#]],
21 );
22}
23
24#[test]
25fn use_from_crate() {
26 check_at(
27 r#"
28struct Struct;
29fn outer() {
30 use Struct;
31 use crate::Struct as CrateStruct;
32 use self::Struct as SelfStruct;
33 $0
34}
35"#,
36 expect![[r#"
37 block scope
38 CrateStruct: t v
39 SelfStruct: t v
40 Struct: t v
41 crate
42 Struct: t v
43 outer: v
44 "#]],
45 );
46}
47
48#[test]
49fn merge_namespaces() {
50 check_at(
51 r#"
52struct name {}
53fn outer() {
54 fn name() {}
55
56 use name as imported; // should import both `name`s
57
58 $0
59}
60"#,
61 expect![[r#"
62 block scope
63 imported: t v
64 name: v
65 crate
66 name: t
67 outer: v
68 "#]],
69 );
70}
71
72#[test]
73fn nested_blocks() {
74 check_at(
75 r#"
76fn outer() {
77 struct inner1 {}
78 fn inner() {
79 use inner1;
80 use outer;
81 fn inner2() {}
82 $0
83 }
84}
85"#,
86 expect![[r#"
87 block scope
88 inner1: t
89 inner2: v
90 outer: v
91 block scope
92 inner: v
93 inner1: t
94 crate
95 outer: v
96 "#]],
97 );
98}
99
100#[test]
101fn super_imports() {
102 check_at(
103 r#"
104mod module {
105 fn f() {
106 use super::Struct;
107 $0
108 }
109}
110
111struct Struct {}
112"#,
113 expect![[r#"
114 block scope
115 Struct: t
116 crate
117 Struct: t
118 module: t
119
120 crate::module
121 f: v
122 "#]],
123 );
124}
125
126#[test]
127fn legacy_macro_items() {
128 // Checks that legacy-scoped `macro_rules!` from parent namespaces are resolved and expanded
129 // correctly.
130 check_at(
131 r#"
132macro_rules! hit {
133 () => {
134 struct Hit {}
135 }
136}
137
138fn f() {
139 hit!();
140 $0
141}
142"#,
143 expect![[r#"
144 block scope
145 Hit: t
146 crate
147 f: v
148 "#]],
149 );
150}
151
152#[test]
153fn macro_resolve() {
154 check_at(
155 r#"
156//- /lib.rs crate:lib deps:core
157use core::mark;
158
159fn f() {
160 fn nested() {
161 mark::hit!(Hit);
162 $0
163 }
164}
165//- /core.rs crate:core
166pub mod mark {
167 #[macro_export]
168 macro_rules! _hit {
169 ($name:ident) => {
170 struct $name {}
171 }
172 }
173
174 pub use crate::_hit as hit;
175}
176"#,
177 expect![[r#"
178 block scope
179 Hit: t
180 block scope
181 nested: v
182 crate
183 f: v
184 mark: t
185 "#]],
186 );
187}