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:
parent
6302e41ccb
commit
9a3f53dee6
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user