Partially hash let declaration in SpanlessHash

The hash never needs to be good but before it was simply doing nothing
for these.
This commit is contained in:
mcarton 2016-10-02 02:17:04 +02:00
parent 6302e41ccb
commit 9a3f53dee6
No known key found for this signature in database
GPG Key ID: 5E427C794CBA45E8
2 changed files with 28 additions and 16 deletions

View File

@ -528,10 +528,15 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
pub fn hash_stmt(&mut self, b: &Stmt) {
match b.node {
StmtDecl(ref _decl, _) => {
StmtDecl(ref decl, _) => {
let c: fn(_, _) -> _ = StmtDecl;
c.hash(&mut self.s);
// TODO: decl
if let DeclLocal(ref local) = decl.node {
if let Some(ref init) = local.init {
self.hash_expr(init);
}
}
}
StmtExpr(ref expr, _) => {
let c: fn(_, _) -> _ = StmtExpr;

View File

@ -70,20 +70,27 @@ fn if_same_then_else() -> Result<&'static str, ()> {
foo();
}
let _ = if true {
//~^NOTE same as this
foo();
let mut a = 42 + [23].len() as i32;
a += 7;
a = -31-a;
a
}
else { //~ERROR this `if` has identical blocks
foo();
let mut a = 42 + [23].len() as i32;
a += 7;
a = -31-a;
a
let _ = match 42 {
42 => {
//~^ NOTE same as this
//~| NOTE refactoring
foo();
let mut a = 42 + [23].len() as i32;
if true {
a += 7;
}
a = -31-a;
a
}
_ => { //~ERROR this `match` has identical arm bodies
foo();
let mut a = 42 + [23].len() as i32;
if true {
a += 7;
}
a = -31-a;
a
}
};
if true {