From 665a876e307933c6480a6c55a3e38e88937aff2c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 21 Sep 2019 20:11:00 +0200 Subject: pre-expansion gate exclusive_range_pattern --- src/libsyntax/parse/parser/pat.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse/parser') diff --git a/src/libsyntax/parse/parser/pat.rs b/src/libsyntax/parse/parser/pat.rs index 5374671d4b8..969d5dd8374 100644 --- a/src/libsyntax/parse/parser/pat.rs +++ b/src/libsyntax/parse/parser/pat.rs @@ -611,6 +611,11 @@ impl<'a> Parser<'a> { Ok(PatKind::Mac(mac)) } + fn excluded_range_end(&self, span: Span) -> RangeEnd { + self.sess.gated_spans.exclusive_range_pattern.borrow_mut().push(span); + RangeEnd::Excluded + } + /// Parse a range pattern `$path $form $end?` where `$form = ".." | "..." | "..=" ;`. /// The `$path` has already been parsed and the next token is the `$form`. fn parse_pat_range_starting_with_path( @@ -620,7 +625,7 @@ impl<'a> Parser<'a> { path: Path ) -> PResult<'a, PatKind> { let (end_kind, form) = match self.token.kind { - token::DotDot => (RangeEnd::Excluded, ".."), + token::DotDot => (self.excluded_range_end(self.token.span), ".."), token::DotDotDot => (RangeEnd::Included(RangeSyntax::DotDotDot), "..."), token::DotDotEq => (RangeEnd::Included(RangeSyntax::DotDotEq), "..="), _ => panic!("can only parse `..`/`...`/`..=` for ranges (checked above)"), @@ -643,7 +648,7 @@ impl<'a> Parser<'a> { } else if self.eat(&token::DotDotEq) { (RangeEnd::Included(RangeSyntax::DotDotEq), "..=") } else if self.eat(&token::DotDot) { - (RangeEnd::Excluded, "..") + (self.excluded_range_end(op_span), "..") } else { panic!("impossible case: we already matched on a range-operator token") }; -- cgit 1.4.1-3-g733a5