about summary refs log tree commit diff
path: root/compiler/rustc_session
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2021-06-05 15:43:12 -0700
committerJeremy Fitzhardinge <jsgf@fb.com>2021-06-21 17:22:35 -0700
commita26d99f348de873e7a7b2b9ab6e78506278c0fee (patch)
treec50432ea04c7ffddfc2974f3ea8ccec972310507 /compiler/rustc_session
parentcef3ab75b12155e0582dd8b7710b7b901215fdd6 (diff)
downloadrust-a26d99f348de873e7a7b2b9ab6e78506278c0fee.tar.gz
rust-a26d99f348de873e7a7b2b9ab6e78506278c0fee.zip
In --emit KIND=PATH options, only hash KIND
The PATH has no material effect on the emitted artifact, and setting
the patch via `-o` or `--out-dir` does not affect the hash.

Closes https://github.com/rust-lang/rust/issues/86044
Diffstat (limited to 'compiler/rustc_session')
-rw-r--r--compiler/rustc_session/src/config.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index 5afa8e6a09a..331817ad2d0 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -31,6 +31,7 @@ use std::collections::btree_map::{
 };
 use std::collections::{BTreeMap, BTreeSet};
 use std::fmt;
+use std::hash::{Hash, Hasher};
 use std::iter::{self, FromIterator};
 use std::path::{Path, PathBuf};
 use std::str::{self, FromStr};
@@ -325,10 +326,19 @@ impl Default for TrimmedDefPaths {
 
 /// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
 /// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
-/// dependency tracking for command-line arguments.
-#[derive(Clone, Hash, Debug)]
+/// dependency tracking for command-line arguments. Also only hash keys, since tracking
+/// should only depend on the output types, not the paths they're written to.
+#[derive(Clone, Debug)]
 pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
 
+impl Hash for OutputTypes {
+    fn hash<H: Hasher>(&self, hasher: &mut H) {
+        for k in self.keys() {
+            k.hash(hasher);
+        }
+    }
+}
+
 impl_stable_hash_via_hash!(OutputTypes);
 
 impl OutputTypes {