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