diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-03 05:55:39 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-03 05:55:39 +0100 |
commit | 327f3a0a3017e047be58b8312f8bf3ac690db3fd (patch) | |
tree | 69585b1cd0b39294bb6f08b392957a4037214b1d /crates/hir_def/src | |
parent | b5804296ddceec7694d4787cec8ede726d64b8d2 (diff) | |
parent | 20d55ce44d4260b6dce220ba64ce81f55299d2ce (diff) |
Merge #8307
8307: Allow include! an empty content file r=edwin0cheng a=edwin0cheng
fixes #8306
bors r+
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/nameres/tests/diagnostics.rs | 20 | ||||
-rw-r--r-- | crates/hir_def/src/test_db.rs | 13 |
2 files changed, 33 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs index a89061c2e..fefdadb22 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#" |
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index 10977761c..dd36106f8 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs | |||
@@ -265,4 +265,17 @@ impl TestDB { | |||
265 | 265 | ||
266 | assert_eq!(annotations, actual); | 266 | assert_eq!(annotations, actual); |
267 | } | 267 | } |
268 | |||
269 | pub(crate) fn check_no_diagnostics(&self) { | ||
270 | let db: &TestDB = self; | ||
271 | let annotations = db.extract_annotations(); | ||
272 | assert!(annotations.is_empty()); | ||
273 | |||
274 | let mut has_diagnostics = false; | ||
275 | db.diagnostics(|_| { | ||
276 | has_diagnostics = true; | ||
277 | }); | ||
278 | |||
279 | assert!(!has_diagnostics); | ||
280 | } | ||
268 | } | 281 | } |