aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres/tests/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/nameres/tests/diagnostics.rs')
-rw-r--r--crates/hir_def/src/nameres/tests/diagnostics.rs26
1 files changed, 23 insertions, 3 deletions
diff --git a/crates/hir_def/src/nameres/tests/diagnostics.rs b/crates/hir_def/src/nameres/tests/diagnostics.rs
index a89061c2e..543975e07 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
10fn 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]
11fn unresolved_import() { 16fn unresolved_import() {
12 check_diagnostics( 17 check_diagnostics(
@@ -165,7 +170,7 @@ fn unresolved_legacy_scope_macro() {
165 170
166 m!(); 171 m!();
167 m2!(); 172 m2!();
168 //^^^^^^ unresolved macro call 173 //^^^^^^ unresolved macro `self::m2!`
169 "#, 174 "#,
170 ); 175 );
171} 176}
@@ -182,7 +187,7 @@ fn unresolved_module_scope_macro() {
182 187
183 self::m!(); 188 self::m!();
184 self::m2!(); 189 self::m2!();
185 //^^^^^^^^^^^^ unresolved macro call 190 //^^^^^^^^^^^^ unresolved macro `self::m2!`
186 "#, 191 "#,
187 ); 192 );
188} 193}
@@ -202,6 +207,21 @@ fn builtin_macro_fails_expansion() {
202} 207}
203 208
204#[test] 209#[test]
210fn 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]
205fn good_out_dir_diagnostic() { 225fn 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}