Skip to content

Commit

Permalink
Fix #2427
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 9, 2018
1 parent 88970ec commit ff32d5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/utils/hir_utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use consts::{constant, constant_context};
use consts::{constant_simple, constant_context};
use rustc::lint::*;
use rustc::hir::*;
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -64,7 +64,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
return false;
}

if let (Some(l), Some(r)) = (constant(self.cx, left), constant(self.cx, right)) {
if let (Some(l), Some(r)) = (constant_simple(self.cx, left), constant_simple(self.cx, right)) {
if l == r {
return true;
}
Expand Down Expand Up @@ -317,7 +317,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
}

pub fn hash_expr(&mut self, e: &Expr) {
if let Some(e) = constant(self.cx, e) {
if let Some(e) = constant_simple(self.cx, e) {
return e.hash(&mut self.s);
}

Expand Down
16 changes: 16 additions & 0 deletions tests/run-pass/match_same_arms_const.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![deny(match_same_arms)]

const PRICE_OF_SWEETS: u32 = 5;
const PRICE_OF_KINDNESS: u32 = 0;
const PRICE_OF_DRINKS: u32 = 5;

pub fn price(thing: &str) -> u32 {
match thing {
"rolo" => PRICE_OF_SWEETS,
"advice" => PRICE_OF_KINDNESS,
"juice" => PRICE_OF_DRINKS,
_ => panic!()
}
}

fn main() {}

0 comments on commit ff32d5f

Please sign in to comment.