Skip to content

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

Closed
@wez

Description

@wez

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.tiyicn.workers.dev-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

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-parserArea: The lexing & parsing of Rust source code to an AST
C-bugCategory: This is a bug.
on Jul 29, 2019
Centril

Centril commented on Jul 29, 2019

@Centril
Contributor

Regression introduced in #62550.

Centril

Centril commented on Jul 29, 2019

@Centril
Contributor

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

Centril commented on Jul 29, 2019

@Centril
Contributor

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.

self-assigned this
on Jul 29, 2019

9 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @wez@nagisa@Centril

    Issue actions

      "`X...` range patterns are not supported" occurring in today's nightly · Issue #63115 · rust-lang/rust