@@ -411,7 +411,7 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
411
411
push_to_s ( & mut info. crate_attrs , source, attr. span , & mut prev_span_hi) ;
412
412
}
413
413
}
414
- let mut has_non_module_items = false ;
414
+ let mut has_non_items = false ;
415
415
for stmt in & body. stmts {
416
416
let mut is_extern_crate = false ;
417
417
match stmt. kind {
@@ -423,8 +423,11 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
423
423
reset_error_count ( & psess) ;
424
424
return Err ( ( ) ) ;
425
425
}
426
- has_non_module_items = true ;
426
+ has_non_items = true ;
427
427
}
428
+ // We assume that the macro calls will expand to item(s) even though they could
429
+ // expand to statements and expressions. And the simple fact that we're trying
430
+ // to retrieve a `main` function inside it is a terrible idea.
428
431
StmtKind :: MacCall ( ref mac_call) if !info. has_main_fn => {
429
432
let mut iter = mac_call. mac . args . tokens . iter ( ) ;
430
433
@@ -448,7 +451,7 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
448
451
// We do nothing in this case. Not marking it as `non_module_items` either.
449
452
StmtKind :: Empty => { }
450
453
_ => {
451
- has_non_module_items = true ;
454
+ has_non_items = true ;
452
455
}
453
456
}
454
457
@@ -474,7 +477,7 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
474
477
push_to_s ( & mut info. crates , source, span, & mut prev_span_hi) ;
475
478
}
476
479
}
477
- if has_non_module_items {
480
+ if has_non_items {
478
481
// FIXME: if `info.has_main_fn` is `true`, emit a warning here to mention that
479
482
// this code will not be called.
480
483
info. has_main_fn = false ;
0 commit comments