about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-08 12:57:32 +0100
committerGitHub <noreply@github.com>2022-12-08 12:57:32 +0100
commitfbfc5ada029dd7892cbdb64a7f6cffee7f898385 (patch)
tree6d0c14a26a4b1c031f34dd2341d690520f00e00e /compiler/rustc_span/src
parent2fbde2b028126f20fbf4dbca58a7cdbd7f93a456 (diff)
parentd30848b30a4ba328b482e2e601de7517be2e5397 (diff)
downloadrust-fbfc5ada029dd7892cbdb64a7f6cffee7f898385.tar.gz
rust-fbfc5ada029dd7892cbdb64a7f6cffee7f898385.zip
Rollup merge of #105423 - oli-obk:symbols, r=jackh726
Use `Symbol` for the crate name instead of `String`/`str`

It always got converted to a symbol anyway
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/def_id.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs
index 0ad1f1a0da7..e62ce2c266a 100644
--- a/compiler/rustc_span/src/def_id.rs
+++ b/compiler/rustc_span/src/def_id.rs
@@ -1,4 +1,4 @@
-use crate::HashStableContext;
+use crate::{HashStableContext, Symbol};
 use rustc_data_structures::fingerprint::Fingerprint;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
 use rustc_data_structures::AtomicRef;
@@ -149,9 +149,11 @@ impl StableCrateId {
 
     /// Computes the stable ID for a crate with the given name and
     /// `-Cmetadata` arguments.
-    pub fn new(crate_name: &str, is_exe: bool, mut metadata: Vec<String>) -> StableCrateId {
+    pub fn new(crate_name: Symbol, is_exe: bool, mut metadata: Vec<String>) -> StableCrateId {
         let mut hasher = StableHasher::new();
-        crate_name.hash(&mut hasher);
+        // We must hash the string text of the crate name, not the id, as the id is not stable
+        // across builds.
+        crate_name.as_str().hash(&mut hasher);
 
         // We don't want the stable crate ID to depend on the order of
         // -C metadata arguments, so sort them: