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 https://github.com/rust-lang/rust/pull/84233.
r? `@Aaron1011`
This commit is contained in:
bors 2021-06-05 01:08:51 +00:00
commit 9e6f0e878d

View File

@ -2449,30 +2449,32 @@ crate mod dep_tracking {
)+}; )+};
} }
impl<T: DepTrackingHash> DepTrackingHash for Option<T> {
fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) {
match self {
Some(x) => {
Hash::hash(&1, hasher);
DepTrackingHash::hash(x, hasher, error_format);
}
None => Hash::hash(&0, hasher),
}
}
}
impl_dep_tracking_hash_via_hash!( impl_dep_tracking_hash_via_hash!(
bool, bool,
usize, usize,
NonZeroUsize,
u64, u64,
String, String,
PathBuf, PathBuf,
lint::Level, lint::Level,
Option<bool>, WasiExecModel,
Option<u32>, u32,
Option<usize>, RelocModel,
Option<NonZeroUsize>, CodeModel,
Option<String>, TlsModel,
Option<(String, u64)>, InstrumentCoverage,
Option<Vec<String>>,
Option<MergeFunctions>,
Option<RelocModel>,
Option<CodeModel>,
Option<TlsModel>,
Option<WasiExecModel>,
Option<PanicStrategy>,
Option<RelroLevel>,
Option<InstrumentCoverage>,
Option<lint::Level>,
Option<PathBuf>,
CrateType, CrateType,
MergeFunctions, MergeFunctions,
PanicStrategy, PanicStrategy,
@ -2490,10 +2492,10 @@ crate mod dep_tracking {
TargetTriple, TargetTriple,
Edition, Edition,
LinkerPluginLto, LinkerPluginLto,
Option<SplitDebuginfo>, SplitDebuginfo,
SwitchWithOptPath, SwitchWithOptPath,
Option<SymbolManglingVersion>, SymbolManglingVersion,
Option<SourceFileHashAlgorithm>, SourceFileHashAlgorithm,
TrimmedDefPaths, TrimmedDefPaths,
); );