libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.#61321
Merged
bors merged 1 commit intorust-lang:masterfrom May 30, 2019
Merged
libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.#61321bors merged 1 commit intorust-lang:masterfrom
bors merged 1 commit intorust-lang:masterfrom
Conversation
oli-obk
reviewed
May 29, 2019
| self.check_keyword(kw::Unsafe) && | ||
| self.look_ahead(1, |t| t.is_keyword(kw::Impl)) || | ||
| self.check_keyword(kw::Default) && | ||
| self.look_ahead(1, |t| t.is_keyword(kw::Impl)) || |
Contributor
There was a problem hiding this comment.
side-note (pre existing): default unsafe fn is eaten by this if and will error?
Contributor
Author
Centril
commented
May 29, 2019
| } | ||
|
|
||
| /// Returns whether any of the given keywords are `dist` tokens ahead of the current one. | ||
| fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool { |
Contributor
Author
There was a problem hiding this comment.
We could possibly reduce this to just one keyword... that is one option... :)
Contributor
There was a problem hiding this comment.
18 single keyword vs 5 multiple keywords.
+ look_ahead is a single array lookup and a match, more or less, so not much reason to optimize.
Might be reasonable to reduce to one keyword.
Contributor
|
r=me with or without addressing #61321 (comment) |
Contributor
Author
|
Tricky choice... can't decide one way or the other... but I'll go with what is convenient ;) @bors r=petrochenkov rollup |
Collaborator
|
📌 Commit 5d72ac3 has been approved by |
Centril
added a commit
to Centril/rust
that referenced
this pull request
May 30, 2019
…enkov
libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.
Introduces:
```rust
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
fn is_keyword_ahead(&self, dist: usize, kws: &[Symbol]) -> bool {
self.look_ahead(dist, |t| kws.iter().any(|&kw| t.is_keyword(kw)))
}
```
r? @oli-obk
bors
added a commit
that referenced
this pull request
May 30, 2019
Rollup of 11 pull requests Successful merges: - #60802 (upgrade rustdoc's `pulldown-cmark` to 0.5.2) - #60839 (Fix ICE with struct ctors and const generics.) - #60850 (Stabilize RefCell::try_borrow_unguarded) - #61231 (Fix linkage diagnostic so it doesn't ICE for external crates) - #61244 (Box::into_vec: use Box::into_raw instead of mem::forget) - #61279 (implicit `Option`-returning doctests) - #61280 (Revert "Disable solaris target since toolchain no longer builds") - #61284 (Update all s3 URLs used on CI with subdomains) - #61321 (libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.) - #61322 (ci: display more debug information in the init_repo script) - #61333 (Fix ICE with APIT in a function with a const parameter) Failed merges: - #61304 (Speed up Azure CI installing Windows dependencies) r? @ghost
bors
added a commit
that referenced
this pull request
May 30, 2019
Rollup of 11 pull requests Successful merges: - #60802 (upgrade rustdoc's `pulldown-cmark` to 0.5.2) - #60839 (Fix ICE with struct ctors and const generics.) - #60850 (Stabilize RefCell::try_borrow_unguarded) - #61231 (Fix linkage diagnostic so it doesn't ICE for external crates) - #61244 (Box::into_vec: use Box::into_raw instead of mem::forget) - #61279 (implicit `Option`-returning doctests) - #61280 (Revert "Disable solaris target since toolchain no longer builds") - #61284 (Update all s3 URLs used on CI with subdomains) - #61321 (libsyntax: introduce 'fn is_keyword_ahead(dist, keywords)'.) - #61322 (ci: display more debug information in the init_repo script) - #61333 (Fix ICE with APIT in a function with a const parameter) Failed merges: - #61304 (Speed up Azure CI installing Windows dependencies) r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces:
r? @oli-obk