Skip to content

Commit

Permalink
Auto merge of #84234 - jyn514:blanket-hash, r=Aaron1011
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Jun 5, 2021
2 parents 704934d + 76502de commit 9e6f0e8
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
bool,
usize,
NonZeroUsize,
u64,
String,
PathBuf,
lint::Level,
Option<bool>,
Option<u32>,
Option<usize>,
Option<NonZeroUsize>,
Option<String>,
Option<(String, u64)>,
Option<Vec<String>>,
Option<MergeFunctions>,
Option<RelocModel>,
Option<CodeModel>,
Option<TlsModel>,
Option<WasiExecModel>,
Option<PanicStrategy>,
Option<RelroLevel>,
Option<InstrumentCoverage>,
Option<lint::Level>,
Option<PathBuf>,
WasiExecModel,
u32,
RelocModel,
CodeModel,
TlsModel,
InstrumentCoverage,
CrateType,
MergeFunctions,
PanicStrategy,
Expand All @@ -2490,10 +2492,10 @@ crate mod dep_tracking {
TargetTriple,
Edition,
LinkerPluginLto,
Option<SplitDebuginfo>,
SplitDebuginfo,
SwitchWithOptPath,
Option<SymbolManglingVersion>,
Option<SourceFileHashAlgorithm>,
SymbolManglingVersion,
SourceFileHashAlgorithm,
TrimmedDefPaths,
);

Expand Down

0 comments on commit 9e6f0e8

Please sign in to comment.