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

@ -245,7 +245,7 @@ impl<'a> CrateLoader<'a> {
pub fn new(
sess: &'a Session,
metadata_loader: Box<MetadataLoaderDyn>,
local_crate_name: &str,
local_crate_name: Symbol,
) -> Self {
let mut stable_crate_ids = FxHashMap::default();
stable_crate_ids.insert(sess.local_stable_crate_id(), LOCAL_CRATE);
@ -253,7 +253,7 @@ impl<'a> CrateLoader<'a> {
CrateLoader {
sess,
metadata_loader,
local_crate_name: Symbol::intern(local_crate_name),
local_crate_name,
cstore: CStore {
// We add an empty entry for LOCAL_CRATE (which maps to zero) in
// order to make array indices in `metas` match with the
@ -1000,7 +1000,7 @@ impl<'a> CrateLoader<'a> {
);
let name = match orig_name {
Some(orig_name) => {
validate_crate_name(self.sess, orig_name.as_str(), Some(item.span));
validate_crate_name(self.sess, orig_name, Some(item.span));
orig_name
}
None => item.ident.name,

View file

@ -61,8 +61,7 @@ pub fn encode_and_write_metadata(tcx: TyCtxt<'_>) -> (EncodedMetadata, bool) {
.unwrap_or(MetadataKind::None);
let crate_name = tcx.crate_name(LOCAL_CRATE);
let out_filename =
filename_for_metadata(tcx.sess, crate_name.as_str(), tcx.output_filenames(()));
let out_filename = filename_for_metadata(tcx.sess, crate_name, tcx.output_filenames(()));
// To avoid races with another rustc process scanning the output directory,
// we need to write the file somewhere else and atomically move it to its
// final destination, with an `fs::rename` call. In order for the rename to