-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Destructuring irrefutable enums with ref inside match causes a panic #31872
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
Comments
Note that it's not actually expected to compile, because |
This looks to be the exact same compiler panic I encountered. I've made a branch with code that panics the compiler here. The specific line of code that is causing the panic is this one. Here's a minimal snippet that replicates the panic: enum MakePanic {
Panic(usize),
Calm,
Anxious,
}
#[test]
fn test_compile_panic() {
let mkpnc = MakePanic::Panic(3);
let MakePanic::Panic(val) = mkpnc;
println!("Use val {}", val);
} Note that it doesn't panic with fewer than 3 enum options. I tried Version beta: Version nightly: Backtrace beta:
Backtrace nightly:
|
I think this should be fixed (#31561) |
When destructuring an irrefutable enum inside a destructured match pattern with references, the compiler crashes. I tried replicating the case with as little code as possible, but it seems to only happen when I use the enum from the
irc
crate.This is the code I managed to narrow it down to:
Note that it is destructuring from the
command
argument to theprocess
function, and not the destructured referencecmd
.I expected
cmd
andargs
to both be references to the types in theEvent::Command
enum, and expectedtarget
andmsg
to be&str
s referencing theString
s defined in theCommand::PRIVMSG
enum type in theirc
crate.Instead, the compiler panics with the following error:
Meta
Rust version:
rustc 1.8.0-nightly (c8fc481 2016-02-22)
binary: rustc
commit-hash: c8fc481
commit-date: 2016-02-22
host: x86_64-unknown-linux-gnu
release: 1.8.0-nightly
Backtrace:
Repository
I uploaded the code as a repository, with
Cargo.lock
for easier replication.https://github.com/mkroman/compiler-crash
The text was updated successfully, but these errors were encountered: