1
Fork 0

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
This commit is contained in:
Matthias Krüger 2022-12-08 12:57:32 +01:00 committed by GitHub
commit fbfc5ada02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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: