mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
Fix #2427
This commit is contained in:
@@ -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};
|
||||
@@ -64,7 +64,7 @@ pub fn eq_expr(&self, left: &Expr, right: &Expr) -> bool {
|
||||
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;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ pub fn hash_block(&mut self, b: &Block) {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {}
|
||||
Reference in New Issue
Block a user