Skip to content
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

"X... range patterns are not supported" occurring in today's nightly #63115

Closed
wez opened this issue Jul 29, 2019 · 3 comments · Fixed by #63122
Closed

"X... range patterns are not supported" occurring in today's nightly #63115

wez opened this issue Jul 29, 2019 · 3 comments · Fixed by #63122
Assignees
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wez
Copy link

wez commented Jul 29, 2019

The CI for libssh2-sys started to fail today with this error:

error: `X...` range patterns are not supported
   --> C:\Users\wez\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.7.0\src\traits.rs:94:21
    |
94  |                     1 ... $e => u128::new(mantissa) << exp,
    |                     ^^^^^ help: try using the maximum value for the type: `1...MAX`
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
    | ------------------------------------------------------ in this macro invocation

It appears as though the compiler doesn't see 1 ... $e and only sees 1... as the range expression and then generates this error.

The expression is inside a macro_rules! expansion.

You can reproduce this by cloning the extprim repo and building it:

$ git clone git@github.com:kennytm/extprim.git
$ cd extprim
$ cargo +nightly build

The build succeeds on the stable channel and much older releases, so this appears to be a regression in the nightly.

Here's the version on my windows system, but note that this also fails on linux and macos too:

rustc 1.38.0-nightly (4560cb830 2019-07-28)
binary: rustc
commit-hash: 4560cb830fce63fcffdc4558f4281aaac6a3a1ba
commit-date: 2019-07-28
host: x86_64-pc-windows-msvc
release: 1.38.0-nightly
LLVM version: 9.0
@Centril Centril added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-parser Area: The parsing of Rust source code to an AST WG-compiler-front C-bug Category: This is a bug. labels Jul 29, 2019
@Centril
Copy link
Contributor

Centril commented Jul 29, 2019

Regression introduced in #62550.

@Centril
Copy link
Contributor

Centril commented Jul 29, 2019

More specifically the bug is in:

    fn is_pat_range_end_start(&self) -> bool {
        self.token.is_path_start() // e.g. `MY_CONST`;
            || self.token == token::Dot // e.g. `.5` for recovery;
            || self.token.can_begin_literal_or_bool() // e.g. `42`.
    }

which is called to see whether what follows ... is a valid start of a range pattern end expression.

This is strange tho... in the case of e.g.:

fn bar() {
    macro_rules! foo {
        ($e1:expr, $e2:expr) => {
            match 0 {
                $e1...A => {}
                _ => {}
            }
        }
    }

    foo!(0, 1);
}

the call to self.token.is_path_start() in https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/parser.rs#L3959 is used successfully to parse $e1 but somehow that doesn't work for $e1..$e2.

cc @petrochenkov

@Centril
Copy link
Contributor

Centril commented Jul 29, 2019

Similarly, with:

fn bar() {
    macro_rules! foo {
        ($e1:expr, $e2:expr) => {
            match 0 {
                ..$e2 => {}
                _ => {}
            }
        }
    }

    foo!(0, 1);
}

this does not trigger "error: ..X range patterns are not supported" but it should.

@Centril Centril self-assigned this Jul 29, 2019
Centril added a commit to Centril/rust that referenced this issue Jul 31, 2019
Account for `maybe_whole_expr` in range patterns

Fixes rust-lang#63115 (fallout from rust-lang#62550).

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this issue Jul 31, 2019
Account for `maybe_whole_expr` in range patterns

Fixes rust-lang#63115 (fallout from rust-lang#62550).

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this issue Aug 1, 2019
Account for `maybe_whole_expr` in range patterns

Fixes rust-lang#63115 (fallout from rust-lang#62550).

r? @petrochenkov
@nagisa nagisa added the P-high High priority label Aug 1, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 1, 2019
Account for `maybe_whole_expr` in range patterns

Fixes rust-lang#63115 (fallout from rust-lang#62550).

r? @petrochenkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants