File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ fn check_diagnostics(ra_fixture: &str) {
7
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
15
#[ test]
11
16
fn unresolved_import ( ) {
12
17
check_diagnostics (
@@ -201,6 +206,21 @@ fn builtin_macro_fails_expansion() {
201
206
) ;
202
207
}
203
208
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
+
204
224
#[ test]
205
225
fn good_out_dir_diagnostic ( ) {
206
226
check_diagnostics (
Original file line number Diff line number Diff line change @@ -265,4 +265,17 @@ impl TestDB {
265
265
266
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
}
Original file line number Diff line number Diff line change @@ -325,9 +325,6 @@ trait TokenConvertor {
325
325
while self . peek ( ) . is_some ( ) {
326
326
self . collect_leaf ( & mut subtree. token_trees ) ;
327
327
}
328
- if subtree. token_trees . is_empty ( ) {
329
- return None ;
330
- }
331
328
if subtree. token_trees . len ( ) == 1 {
332
329
if let tt:: TokenTree :: Subtree ( first) = & subtree. token_trees [ 0 ] {
333
330
return Some ( first. clone ( ) ) ;
You can’t perform that action at this time.
0 commit comments