Skip to content

Commit ff32d5f

Browse files
committed
Fix #2427
1 parent 88970ec commit ff32d5f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

clippy_lints/src/utils/hir_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use consts::{constant, constant_context};
1+
use consts::{constant_simple, constant_context};
22
use rustc::lint::*;
33
use rustc::hir::*;
44
use std::hash::{Hash, Hasher};
@@ -64,7 +64,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
6464
return false;
6565
}
6666

67-
if let (Some(l), Some(r)) = (constant(self.cx, left), constant(self.cx, right)) {
67+
if let (Some(l), Some(r)) = (constant_simple(self.cx, left), constant_simple(self.cx, right)) {
6868
if l == r {
6969
return true;
7070
}
@@ -317,7 +317,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
317317
}
318318

319319
pub fn hash_expr(&mut self, e: &Expr) {
320-
if let Some(e) = constant(self.cx, e) {
320+
if let Some(e) = constant_simple(self.cx, e) {
321321
return e.hash(&mut self.s);
322322
}
323323

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![deny(match_same_arms)]
2+
3+
const PRICE_OF_SWEETS: u32 = 5;
4+
const PRICE_OF_KINDNESS: u32 = 0;
5+
const PRICE_OF_DRINKS: u32 = 5;
6+
7+
pub fn price(thing: &str) -> u32 {
8+
match thing {
9+
"rolo" => PRICE_OF_SWEETS,
10+
"advice" => PRICE_OF_KINDNESS,
11+
"juice" => PRICE_OF_DRINKS,
12+
_ => panic!()
13+
}
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)