Add regression test

This commit is contained in:
flip1995 2018-11-15 17:03:41 +01:00
parent 1000fc5120
commit 655a2b4709
No known key found for this signature in database
GPG Key ID: E8E897A5870E41C2
2 changed files with 48 additions and 0 deletions

32
tests/ui/ice-2636.rs Normal file
View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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);
}

16
tests/ui/ice-2636.stderr Normal file
View File

@ -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