Skip to content

Commit 40f587a

Browse files
committed
Flatten hash_owner_nodes with an early-return
1 parent 63f6845 commit 40f587a

File tree

1 file changed

+21
-21
lines changed
  • compiler/rustc_middle/src/hir

1 file changed

+21
-21
lines changed

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,32 +175,32 @@ impl<'tcx> TyCtxt<'tcx> {
175175
delayed_lints: &[DelayedLint],
176176
define_opaque: Option<&[(Span, LocalDefId)]>,
177177
) -> (Option<Fingerprint>, Option<Fingerprint>, Option<Fingerprint>) {
178-
if self.needs_crate_hash() {
179-
self.with_stable_hashing_context(|mut hcx| {
180-
let mut stable_hasher = StableHasher::new();
181-
node.hash_stable(&mut hcx, &mut stable_hasher);
182-
// Bodies are stored out of line, so we need to pull them explicitly in the hash.
183-
bodies.hash_stable(&mut hcx, &mut stable_hasher);
184-
let h1 = stable_hasher.finish();
178+
if !self.needs_crate_hash() {
179+
return (None, None, None);
180+
}
185181

186-
let mut stable_hasher = StableHasher::new();
187-
attrs.hash_stable(&mut hcx, &mut stable_hasher);
182+
self.with_stable_hashing_context(|mut hcx| {
183+
let mut stable_hasher = StableHasher::new();
184+
node.hash_stable(&mut hcx, &mut stable_hasher);
185+
// Bodies are stored out of line, so we need to pull them explicitly in the hash.
186+
bodies.hash_stable(&mut hcx, &mut stable_hasher);
187+
let h1 = stable_hasher.finish();
188188

189-
// Hash the defined opaque types, which are not present in the attrs.
190-
define_opaque.hash_stable(&mut hcx, &mut stable_hasher);
189+
let mut stable_hasher = StableHasher::new();
190+
attrs.hash_stable(&mut hcx, &mut stable_hasher);
191191

192-
let h2 = stable_hasher.finish();
192+
// Hash the defined opaque types, which are not present in the attrs.
193+
define_opaque.hash_stable(&mut hcx, &mut stable_hasher);
193194

194-
// hash lints emitted during ast lowering
195-
let mut stable_hasher = StableHasher::new();
196-
delayed_lints.hash_stable(&mut hcx, &mut stable_hasher);
197-
let h3 = stable_hasher.finish();
195+
let h2 = stable_hasher.finish();
198196

199-
(Some(h1), Some(h2), Some(h3))
200-
})
201-
} else {
202-
(None, None, None)
203-
}
197+
// hash lints emitted during ast lowering
198+
let mut stable_hasher = StableHasher::new();
199+
delayed_lints.hash_stable(&mut hcx, &mut stable_hasher);
200+
let h3 = stable_hasher.finish();
201+
202+
(Some(h1), Some(h2), Some(h3))
203+
})
204204
}
205205
}
206206

0 commit comments

Comments
 (0)