diff options
Diffstat (limited to 'crates/hir_def/src/nameres/tests')
-rw-r--r-- | crates/hir_def/src/nameres/tests/diagnostics.rs | 22 | ||||
-rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 18 |
2 files changed, 39 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index a89061c2e..1ac88fc89 100644 --- a/crates/hir_def/src/nameres/tests/diagnostics.rs +++ b/crates/hir_def/src/nameres/tests/diagnostics.rs | |||
@@ -7,6 +7,11 @@ fn check_diagnostics(ra_fixture: &str) { | |||
7 | db.check_diagnostics(); | 7 | db.check_diagnostics(); |
8 | } | 8 | } |
9 | 9 | ||
10 | fn check_no_diagnostics(ra_fixture: &str) { | ||
11 | let db: TestDB = TestDB::with_files(ra_fixture); | ||
12 | db.check_no_diagnostics(); | ||
13 | } | ||
14 | |||
10 | #[test] | 15 | #[test] |
11 | fn unresolved_import() { | 16 | fn unresolved_import() { |
12 | check_diagnostics( | 17 | check_diagnostics( |
@@ -202,6 +207,21 @@ fn builtin_macro_fails_expansion() { | |||
202 | } | 207 | } |
203 | 208 | ||
204 | #[test] | 209 | #[test] |
210 | fn include_macro_should_allow_empty_content() { | ||
211 | check_no_diagnostics( | ||
212 | r#" | ||
213 | //- /lib.rs | ||
214 | #[rustc_builtin_macro] | ||
215 | macro_rules! include { () => {} } | ||
216 | |||
217 | include!("bar.rs"); | ||
218 | //- /bar.rs | ||
219 | // empty | ||
220 | "#, | ||
221 | ); | ||
222 | } | ||
223 | |||
224 | #[test] | ||
205 | fn good_out_dir_diagnostic() { | 225 | fn good_out_dir_diagnostic() { |
206 | check_diagnostics( | 226 | check_diagnostics( |
207 | r#" | 227 | r#" |
@@ -213,7 +233,7 @@ fn good_out_dir_diagnostic() { | |||
213 | macro_rules! concat { () => {} } | 233 | macro_rules! concat { () => {} } |
214 | 234 | ||
215 | include!(concat!(env!("OUT_DIR"), "/out.rs")); | 235 | include!(concat!(env!("OUT_DIR"), "/out.rs")); |
216 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "load out dirs from check" to fix | 236 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `OUT_DIR` not set, enable "run build scripts" to fix |
217 | "#, | 237 | "#, |
218 | ); | 238 | ); |
219 | } | 239 | } |
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index 6d3cb8d7a..c37f915ab 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs | |||
@@ -837,3 +837,21 @@ fn collects_derive_helpers() { | |||
837 | _ => unreachable!(), | 837 | _ => unreachable!(), |
838 | } | 838 | } |
839 | } | 839 | } |
840 | |||
841 | #[test] | ||
842 | fn resolve_macro_def() { | ||
843 | check( | ||
844 | r#" | ||
845 | //- /lib.rs | ||
846 | pub macro structs($($i:ident),*) { | ||
847 | $(struct $i { field: u32 } )* | ||
848 | } | ||
849 | structs!(Foo); | ||
850 | "#, | ||
851 | expect![[r#" | ||
852 | crate | ||
853 | Foo: t | ||
854 | structs: m | ||
855 | "#]], | ||
856 | ); | ||
857 | } | ||