Skip to content

Commit cd3c932

Browse files
committed
Fix control flow in assert_default_hashing_controls.
Calling `match` on a struct is a really weird thing to do. As the name suggests, it's an assert, so let's write it as one. Also clarify the comment a little.
1 parent c9f8277 commit cd3c932

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

compiler/rustc_span/src/hygiene.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,21 @@ impl !PartialOrd for LocalExpnId {}
132132
/// to maintain separate versions of `ExpnData` hashes for each permutation
133133
/// of `HashingControls` settings.
134134
fn assert_default_hashing_controls(ctx: &impl HashStableContext, msg: &str) {
135-
match ctx.hashing_controls() {
136-
// Note that we require that `hash_spans` be set according to the global
137-
// `-Z incremental-ignore-spans` option. Normally, this option is disabled,
138-
// which will cause us to require that this method always be called with `Span` hashing
139-
// enabled.
140-
//
141-
// Span hashing can also be disabled without `-Z incremental-ignore-spans`.
142-
// This is the case for instance when building a hash for name mangling.
143-
// Such configuration must not be used for metadata.
144-
HashingControls { hash_spans }
145-
if hash_spans != ctx.unstable_opts_incremental_ignore_spans() => {}
146-
other => panic!("Attempted hashing of {msg} with non-default HashingControls: {other:?}"),
147-
}
135+
let hashing_controls = ctx.hashing_controls();
136+
let HashingControls { hash_spans } = hashing_controls;
137+
138+
// Note that we require that `hash_spans` be the inverse of the global
139+
// `-Z incremental-ignore-spans` option. Normally, this option is disabled,
140+
// in which case `hash_spans` must be true.
141+
//
142+
// Span hashing can also be disabled without `-Z incremental-ignore-spans`.
143+
// This is the case for instance when building a hash for name mangling.
144+
// Such configuration must not be used for metadata.
145+
assert_eq!(
146+
hash_spans,
147+
!ctx.unstable_opts_incremental_ignore_spans(),
148+
"Attempted hashing of {msg} with non-default HashingControls: {hashing_controls:?}"
149+
);
148150
}
149151

150152
/// A unique hash value associated to an expansion.

0 commit comments

Comments
 (0)