-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make Parser::parse_foreign_item()
return a foreign item or error
#54833
Conversation
@petrochenkov As a bugcheck I think it might be a good idea to add a check for duplicates in |
1be986b
to
b3426aa
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Eh, nevermind. |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@petrochenkov Is this error pattern change okay (expecting closing brace later on, not in this error msg)?
It's actually more correct, isn't it, since a |
ca6f20c
to
48ed783
Compare
src/test/compile-fail/issue-54441.rs
Outdated
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits:
- new tests are no longer added to the
compile-fail
directory (they go intoui
now) - the license section is no longer necessary
The error change looks ok, r=me with nits addressed. |
--> $DIR/issue-54441.rs:5:9 | ||
| | ||
LL | #![feature(macros_in_extern)] | ||
| - expected one of `crate`, `fn`, `pub`, `static`, or `type` here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is the "expected" line pointing to line 1 of the source. However, it looks to be an existing bug in Parser::expect_one_of()
WRT macros: https://play.rust-lang.org/?gist=1865a38a912b5aaed3e9a23931ace87c&version=stable&mode=debug&edition=2015
I can fix it here or in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can fix it here or in a different PR.
Whatever is more convenient for you.
@petrochenkov Nits fixed, though look at that comment I left on |
@bors r+ |
📌 Commit 9da428d has been approved by |
I'll open an issue so this can be merged. |
make `Parser::parse_foreign_item()` return a foreign item or error Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter. This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`. closes rust-lang#54441 r? @petrochenkov cc @dtolnay
Rollup of 11 pull requests Successful merges: - #54078 (Expand the documentation for the `std::sync` module) - #54717 (Cleanup rustc/ty part 1) - #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs) - #54787 (Only warn about unused `mut` in user-written code) - #54804 (add suggestion for inverted function parameters) - #54812 (Regression test for #32382.) - #54833 (make `Parser::parse_foreign_item()` return a foreign item or error) - #54834 (rustdoc: overflow:auto doesn't work nicely on small screens) - #54838 (Fix typo in src/libsyntax/parse/parser.rs) - #54851 (Fix a regression in 1.30 by reverting #53564) - #54853 (Remove unneccessary error from test, revealing NLL error.) Failed merges: r? @ghost
Fixes
Parser::parse_foreign_item()
to follow the convention ofparse_trait_item()
andparse_impl_item()
in that it must parse an item or return an error, and then the caller is responsible for detecting the closing delimiter.This prevents it from looping endlessly on an unexpected token in
ext/expand.rs
where it was also leaking memory by continually pushing toParser::expected_tokens
viaParser::check_keyword()
.closes #54441
r? @petrochenkov
cc @dtolnay