diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-08-02 23:07:45 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-08-02 23:07:45 +1000 |
| commit | 40f587aa0d0a792b3f4e558e739c591534778eb3 (patch) | |
| tree | 5816a3c9e1d9c824107227d3c8b42e763e231731 | |
| parent | 63f6845e570305a92eaf855897768617366164d6 (diff) | |
| download | rust-40f587aa0d0a792b3f4e558e739c591534778eb3.tar.gz rust-40f587aa0d0a792b3f4e558e739c591534778eb3.zip | |
Flatten `hash_owner_nodes` with an early-return
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 6c07e49734a..a928703542f 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -175,32 +175,32 @@ impl<'tcx> TyCtxt<'tcx> { delayed_lints: &[DelayedLint], define_opaque: Option<&[(Span, LocalDefId)]>, ) -> (Option<Fingerprint>, Option<Fingerprint>, Option<Fingerprint>) { - if self.needs_crate_hash() { - self.with_stable_hashing_context(|mut hcx| { - let mut stable_hasher = StableHasher::new(); - node.hash_stable(&mut hcx, &mut stable_hasher); - // Bodies are stored out of line, so we need to pull them explicitly in the hash. - bodies.hash_stable(&mut hcx, &mut stable_hasher); - let h1 = stable_hasher.finish(); + if !self.needs_crate_hash() { + return (None, None, None); + } - let mut stable_hasher = StableHasher::new(); - attrs.hash_stable(&mut hcx, &mut stable_hasher); + self.with_stable_hashing_context(|mut hcx| { + let mut stable_hasher = StableHasher::new(); + node.hash_stable(&mut hcx, &mut stable_hasher); + // Bodies are stored out of line, so we need to pull them explicitly in the hash. + bodies.hash_stable(&mut hcx, &mut stable_hasher); + let h1 = stable_hasher.finish(); - // Hash the defined opaque types, which are not present in the attrs. - define_opaque.hash_stable(&mut hcx, &mut stable_hasher); + let mut stable_hasher = StableHasher::new(); + attrs.hash_stable(&mut hcx, &mut stable_hasher); - let h2 = stable_hasher.finish(); + // Hash the defined opaque types, which are not present in the attrs. + define_opaque.hash_stable(&mut hcx, &mut stable_hasher); - // hash lints emitted during ast lowering - let mut stable_hasher = StableHasher::new(); - delayed_lints.hash_stable(&mut hcx, &mut stable_hasher); - let h3 = stable_hasher.finish(); + let h2 = stable_hasher.finish(); - (Some(h1), Some(h2), Some(h3)) - }) - } else { - (None, None, None) - } + // hash lints emitted during ast lowering + let mut stable_hasher = StableHasher::new(); + delayed_lints.hash_stable(&mut hcx, &mut stable_hasher); + let h3 = stable_hasher.finish(); + + (Some(h1), Some(h2), Some(h3)) + }) } } |
