-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler crash when matching generic enum #23151
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
@bluecube just in case you are stuck because of this, this is how that code would normally be written, and it does work. Note the lack of type definitions: enum Foo<T> {
A(T),
B
}
fn main() {
let x = Foo::A(14);
let y = match x {
Foo::A(value) => value,
Foo::B => 7,
};
println!("{}", y);
} |
Thanks, @shepmaster. |
enum Foo<T> {
A(T),
B
}
fn main() {
let x = Foo::A::<u32>(14);
let y = match x {
Foo::A::<u32>(value) => value,
Foo::B::<u32> => 7,
};
println!("{}", y);
} This is also supported (for now, many people don't like this, let's see whether it will get removed in beta version). |
You are right, after update of rust it doesn't crash.. |
Fixes #22757 Fixes #22972 Fixes #23044 Fixes #23151 Fixes #23597 Fixes #23656 Fixes #23929 It also fixes some other corner cases in range patterns, like incorrect spans or not accepting global paths after `...`. It passes `make check` but needs some additional tests (then it will fix #22546 as well), I'll write them today or tomorrow.
Fixes rust-lang#22757 Fixes rust-lang#22972 Fixes rust-lang#23044 Fixes rust-lang#23151 Fixes rust-lang#23597 Fixes rust-lang#23656 Fixes rust-lang#23929 It also fixes some other corner cases in range patterns, like incorrect spans or not accepting global paths after `...`. It passes `make check` but needs some additional tests (then it will fix rust-lang#22546 as well), I'll write them today or tomorrow.
I tried this code:
and it gave me this message:
I have git version of rust from package in funtoo linux.
When I tried the code at play.rust-lang.org the example produced compiler error, but not a crash.
Meta
rustc --version-verbose
:Backtrace:
The text was updated successfully, but these errors were encountered: