Skip to content

FIX #21475: Parsing interval match patterns with path #21521

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

Merged
merged 3 commits into from
Feb 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3539,6 +3539,19 @@ impl<'a> Parser<'a> {
self.bump();
pat = PatStruct(enum_path, fields, etc);
}
token::DotDotDot => {
let hi = self.last_span.hi;
let start = self.mk_expr(lo, hi, ExprPath(None, enum_path));
self.eat(&token::DotDotDot);
let end = if self.token.is_ident() || self.token.is_path() {
let path = self.parse_path(LifetimeAndTypesWithColons);
let hi = self.span.hi;
self.mk_expr(lo, hi, ExprPath(None, path))
} else {
self.parse_literal_maybe_minus()
};
pat = PatRange(start, end);
}
_ => {
let mut args: Vec<P<Pat>> = Vec::new();
match self.token {
Expand Down
25 changes: 25 additions & 0 deletions src/test/run-pass/issue-21475.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// 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.

use m::{START, END};

fn main() {
match 42u32 {
m::START...m::END => {},
0u32...m::END => {},
m::START...59u32 => {},
_ => {},
}
}

mod m {
pub const START: u32 = 4;
pub const END: u32 = 14;
}