Skip to content

ICE on if let inside a macro #3462

Closed
Closed
@snejugal

Description

@snejugal

This code causes Clippy to panic:

enum Foo {
    Bar,
    Baz,
}

fn bar(foo: Foo) {
    macro_rules! baz {
        () => {
            if let Foo::Bar = foo {}
        };
    }

    baz!();
    baz!();
}

Here is the output of cargo +nightly clippy:

    Checking foo v0.1.0 (C:\foo)
...
thread 'main' panicked at 'begin <= end (33 <= 30) when slicing `            if
`', src\libcore\str\mod.rs:2096:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.32.0-nightly (6bfb46e4a 2018-11-26) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `foo`.

To learn more, run the command again with --verbose.

I have clippy 0.0.212 (754b4c07 2018-11-23), but the bug is reproducible on clippy 0.0.212 (125907ad 2018-09-17) as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions