Skip to content

Commit 9e6f0e8

Browse files
committed
Auto merge of #84234 - jyn514:blanket-hash, r=Aaron1011
Implement DepTrackingHash for `Option` through blanket impls instead of macros This avoids having to add a new macro call for both the `Option` and the type itself. Noticed this while working on #84233. r? `@Aaron1011`
2 parents 704934d + 76502de commit 9e6f0e8

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

compiler/rustc_session/src/config.rs

+22-20
Original file line numberDiff line numberDiff line change
@@ -2449,30 +2449,32 @@ crate mod dep_tracking {
24492449
)+};
24502450
}
24512451

2452+
impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
2453+
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
2454+
match self {
2455+
Some(x) => {
2456+
Hash::hash(&1, hasher);
2457+
DepTrackingHash::hash(x, hasher, error_format);
2458+
}
2459+
None => Hash::hash(&0, hasher),
2460+
}
2461+
}
2462+
}
2463+
24522464
impl_dep_tracking_hash_via_hash!(
24532465
bool,
24542466
usize,
2467+
NonZeroUsize,
24552468
u64,
24562469
String,
24572470
PathBuf,
24582471
lint::Level,
2459-
Option<bool>,
2460-
Option<u32>,
2461-
Option<usize>,
2462-
Option<NonZeroUsize>,
2463-
Option<String>,
2464-
Option<(String, u64)>,
2465-
Option<Vec<String>>,
2466-
Option<MergeFunctions>,
2467-
Option<RelocModel>,
2468-
Option<CodeModel>,
2469-
Option<TlsModel>,
2470-
Option<WasiExecModel>,
2471-
Option<PanicStrategy>,
2472-
Option<RelroLevel>,
2473-
Option<InstrumentCoverage>,
2474-
Option<lint::Level>,
2475-
Option<PathBuf>,
2472+
WasiExecModel,
2473+
u32,
2474+
RelocModel,
2475+
CodeModel,
2476+
TlsModel,
2477+
InstrumentCoverage,
24762478
CrateType,
24772479
MergeFunctions,
24782480
PanicStrategy,
@@ -2490,10 +2492,10 @@ crate mod dep_tracking {
24902492
TargetTriple,
24912493
Edition,
24922494
LinkerPluginLto,
2493-
Option<SplitDebuginfo>,
2495+
SplitDebuginfo,
24942496
SwitchWithOptPath,
2495-
Option<SymbolManglingVersion>,
2496-
Option<SourceFileHashAlgorithm>,
2497+
SymbolManglingVersion,
2498+
SourceFileHashAlgorithm,
24972499
TrimmedDefPaths,
24982500
);
24992501

0 commit comments

Comments
 (0)