Fix handling of parse errors when using include!().
Makes the compilation abort when a parse error is encountered while trying to parse an item in an included file. The previous behaviour was to stop processing the file when a token that can't start an item was encountered, without producing any error. Fixes #21146.
This commit is contained in:
@@ -111,10 +111,14 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree
|
||||
fn make_items(mut self: Box<ExpandResult<'a>>)
|
||||
-> Option<SmallVector<P<ast::Item>>> {
|
||||
let mut ret = SmallVector::zero();
|
||||
loop {
|
||||
while self.p.token != token::Eof {
|
||||
match self.p.parse_item_with_outer_attributes() {
|
||||
Some(item) => ret.push(item),
|
||||
None => break
|
||||
None => self.p.span_fatal(
|
||||
self.p.span,
|
||||
&format!("expected item, found `{}`",
|
||||
self.p.this_token_to_string())[]
|
||||
)
|
||||
}
|
||||
}
|
||||
Some(ret)
|
||||
|
||||
Reference in New Issue
Block a user