-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Macro causes panic #2636
Comments
oli-obk
added
the
I-ICE
Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
label
Apr 7, 2018
I extracted a minimal crashing example with the current Clippy and use std::hash::{Hash, Hasher};
fn main() {}
pub trait Fact: 'static + Eq + Hash { }
pub enum TestData<T: Fact> {
F32(fn(&T) -> &f32, Vec<u16>),
F64(fn(&T) -> &f64, Vec<u16>),
}
impl<T: Fact> TestData<T> {
fn hash_self() {}
}
macro_rules! test_hash {
($($t:ident => $ord:expr),+ ) => {
impl<T:Fact>Hash for TestData<T> {
fn hash < H: Hasher > ( & self, _state: & mut H) {
use self::TestData::*;
match self {
$ ( & $ t(_accessor, ref _test) => Self::hash_self(),
)*
}
}
}
};
}
test_hash!(F32 => 10, F64 => 11); The backtrace with the relevant linenumbers:
If someone wants to have a go at this crash, feel free! |
phansch
added a commit
to phansch/rust-clippy
that referenced
this issue
Sep 6, 2018
I'm not sure what exact change fixed the issue, but the minimal example doesn't crash anymore. Therefore this.. Closes rust-lang#2636
This panic is also triggered when checking |
Even more minimal example: Playground #![allow(dead_code)]
enum Foo {
A,
B,
C,
}
macro_rules! test_hash {
($foo:expr, $($t:ident => $ord:expr),+ ) => {
use self::Foo::*;
match $foo {
$ ( & $t => $ord,
)*
};
};
}
fn main() {
let a = Foo::A;
test_hash!(&a, A => 0, B => 1, C => 2);
} Relevant backtrace:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The macro in question from https://github.com/ambaxter/expert-rs/blob/master/src/network/node_cmp.rs#L514
Backtrace output:
The text was updated successfully, but these errors were encountered: