about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser/path.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-11-07 08:51:57 +0100
committerGitHub <noreply@github.com>2019-11-07 08:51:57 +0100
commite19cb40fda70ea3f75bc1927c114ea53d231b288 (patch)
treecf0891bcc1fca581981d14c7ae6c550fc20f26da /src/libsyntax/parse/parser/path.rs
parent883fe10da2f0651540fd5824898b7d7476969c41 (diff)
parentbceaba86b92325f807351426bfd93ba0513225a4 (diff)
downloadrust-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/path.rs')
-rw-r--r--src/libsyntax/parse/parser/path.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser/path.rs b/src/libsyntax/parse/parser/path.rs
index f9944e36e2f..4438d61d9ee 100644
--- a/src/libsyntax/parse/parser/path.rs
+++ b/src/libsyntax/parse/parser/path.rs
@@ -5,7 +5,7 @@ use crate::ast::{self, QSelf, Path, PathSegment, Ident, ParenthesizedArgs, Angle
 use crate::ast::{AnonConst, GenericArg, AssocTyConstraint, AssocTyConstraintKind, BlockCheckMode};
 use crate::parse::token::{self, Token};
 use crate::source_map::{Span, BytePos};
-use crate::symbol::kw;
+use syntax_pos::symbol::{kw, sym};
 
 use std::mem;
 use log::debug;
@@ -426,7 +426,7 @@ impl<'a> Parser<'a> {
 
                 // Gate associated type bounds, e.g., `Iterator<Item: Ord>`.
                 if let AssocTyConstraintKind::Bound { .. } = kind {
-                    self.sess.gated_spans.associated_type_bounds.borrow_mut().push(span);
+                    self.sess.gated_spans.gate(sym::associated_type_bounds, span);
                 }
 
                 constraints.push(AssocTyConstraint {