diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-06 12:46:10 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-07 20:30:02 +0000 |
| commit | d30848b30a4ba328b482e2e601de7517be2e5397 (patch) | |
| tree | be88050d57283774710d336c54c0e9961209ba39 /compiler/rustc_span/src | |
| parent | e60fbaf4ce768d13a6abc048bd34ee12995d18dc (diff) | |
| download | rust-d30848b30a4ba328b482e2e601de7517be2e5397.tar.gz rust-d30848b30a4ba328b482e2e601de7517be2e5397.zip | |
Use `Symbol` for the crate name instead of `String`/`str`
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/def_id.rs | 8 |
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 f5555846d20..b122bd0722d 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: |
