diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-11-07 08:51:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-07 08:51:57 +0100 |
| commit | e19cb40fda70ea3f75bc1927c114ea53d231b288 (patch) | |
| tree | cf0891bcc1fca581981d14c7ae6c550fc20f26da /src/libsyntax/parse/parser/generics.rs | |
| parent | 883fe10da2f0651540fd5824898b7d7476969c41 (diff) | |
| parent | bceaba86b92325f807351426bfd93ba0513225a4 (diff) | |
| download | rust-e19cb40fda70ea3f75bc1927c114ea53d231b288.tar.gz rust-e19cb40fda70ea3f75bc1927c114ea53d231b288.zip | |
Rollup merge of #65974 - Centril:matcher-friendly-gating, r=petrochenkov
A scheme for more macro-matcher friendly pre-expansion gating
Pre-expansion gating will now avoid gating macro matchers that did not result in `Success(...)`. That is, the following is now OK despite `box 42` being a valid `expr` and that form being pre-expansion gated:
```rust
macro_rules! m {
($e:expr) => { 0 }; // This fails on the input below due to `, foo`.
(box $e:expr, foo) => { 1 }; // Successful matcher, we should get `2`.
}
fn main() {
assert_eq!(1, m!(box 42, foo));
}
```
Closes https://github.com/rust-lang/rust/issues/65846.
r? @petrochenkov
cc @Mark-Simulacrum
Diffstat (limited to 'src/libsyntax/parse/parser/generics.rs')
| -rw-r--r-- | src/libsyntax/parse/parser/generics.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser/generics.rs b/src/libsyntax/parse/parser/generics.rs index 51caae69c86..3c094750b4d 100644 --- a/src/libsyntax/parse/parser/generics.rs +++ b/src/libsyntax/parse/parser/generics.rs @@ -3,7 +3,8 @@ use super::{Parser, PResult}; use crate::ast::{self, WhereClause, GenericParam, GenericParamKind, GenericBounds, Attribute}; use crate::parse::token; use crate::source_map::DUMMY_SP; -use crate::symbol::kw; + +use syntax_pos::symbol::{kw, sym}; impl<'a> Parser<'a> { /// Parses bounds of a lifetime parameter `BOUND + BOUND + BOUND`, possibly with trailing `+`. @@ -62,7 +63,7 @@ impl<'a> Parser<'a> { self.expect(&token::Colon)?; let ty = self.parse_ty()?; - self.sess.gated_spans.const_generics.borrow_mut().push(lo.to(self.prev_span)); + self.sess.gated_spans.gate(sym::const_generics, lo.to(self.prev_span)); Ok(GenericParam { ident, |
