1
Fork 0

Use Symbol for the crate name instead of String/str

This commit is contained in:
Oli Scherer 2022-12-06 12:46:10 +00:00
parent e60fbaf4ce
commit d30848b30a
18 changed files with 103 additions and 92 deletions

View file

@ -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: