diff options
| author | bors <bors@rust-lang.org> | 2015-02-08 14:41:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-08 14:41:02 +0000 |
| commit | bfdcd34e82fca5186f0565c28c5c9b6a9f9b6c76 (patch) | |
| tree | fac01ba25394767610ca5cb624d091154a773609 /src/libsyntax | |
| parent | 725cc06464abda7a657780f12feaefb7f10333c6 (diff) | |
| parent | 8f2ab66ab631a11113ac2fbb66384ce7c2fc34d5 (diff) | |
| download | rust-bfdcd34e82fca5186f0565c28c5c9b6a9f9b6c76.tar.gz rust-bfdcd34e82fca5186f0565c28c5c9b6a9f9b6c76.zip | |
Auto merge of #22054 - LeoTestard:include-parse-errors, r=alexcrichton
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index be02ba5ddc2..7a3a3562bdf 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -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) |
