diff --git a/tests/ui/ice-2636.rs b/tests/ui/ice-2636.rs new file mode 100644 index 00000000000..3ef9ea8f69f --- /dev/null +++ b/tests/ui/ice-2636.rs @@ -0,0 +1,32 @@ +// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![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); +} + diff --git a/tests/ui/ice-2636.stderr b/tests/ui/ice-2636.stderr new file mode 100644 index 00000000000..a0806af5da9 --- /dev/null +++ b/tests/ui/ice-2636.stderr @@ -0,0 +1,16 @@ +error: you don't need to add `&` to both the expression and the patterns + --> $DIR/ice-2636.rs:21:9 + | +21 | / match $foo { +22 | | $ ( & $t => $ord, +23 | | )* +24 | | }; + | |_________^ +... +30 | test_hash!(&a, A => 0, B => 1, C => 2); + | --------------------------------------- in this macro invocation + | + = note: `-D clippy::match-ref-pats` implied by `-D warnings` + +error: aborting due to previous error +