Skip to content

Commit 76502de

Browse files
committed
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.
1 parent c4c2ab5 commit 76502de

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
@@ -2427,30 +2427,32 @@ crate mod dep_tracking {
24272427
)+};
24282428
}
24292429

2430+
impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
2431+
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
2432+
match self {
2433+
Some(x) => {
2434+
Hash::hash(&1, hasher);
2435+
DepTrackingHash::hash(x, hasher, error_format);
2436+
}
2437+
None => Hash::hash(&0, hasher),
2438+
}
2439+
}
2440+
}
2441+
24302442
impl_dep_tracking_hash_via_hash!(
24312443
bool,
24322444
usize,
2445+
NonZeroUsize,
24332446
u64,
24342447
String,
24352448
PathBuf,
24362449
lint::Level,
2437-
Option<bool>,
2438-
Option<u32>,
2439-
Option<usize>,
2440-
Option<NonZeroUsize>,
2441-
Option<String>,
2442-
Option<(String, u64)>,
2443-
Option<Vec<String>>,
2444-
Option<MergeFunctions>,
2445-
Option<RelocModel>,
2446-
Option<CodeModel>,
2447-
Option<TlsModel>,
2448-
Option<WasiExecModel>,
2449-
Option<PanicStrategy>,
2450-
Option<RelroLevel>,
2451-
Option<InstrumentCoverage>,
2452-
Option<lint::Level>,
2453-
Option<PathBuf>,
2450+
WasiExecModel,
2451+
u32,
2452+
RelocModel,
2453+
CodeModel,
2454+
TlsModel,
2455+
InstrumentCoverage,
24542456
CrateType,
24552457
MergeFunctions,
24562458
PanicStrategy,
@@ -2468,10 +2470,10 @@ crate mod dep_tracking {
24682470
TargetTriple,
24692471
Edition,
24702472
LinkerPluginLto,
2471-
Option<SplitDebuginfo>,
2473+
SplitDebuginfo,
24722474
SwitchWithOptPath,
2473-
Option<SymbolManglingVersion>,
2474-
Option<SourceFileHashAlgorithm>,
2475+
SymbolManglingVersion,
2476+
SourceFileHashAlgorithm,
24752477
TrimmedDefPaths,
24762478
);
24772479

0 commit comments

Comments
 (0)