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

@ -111,7 +111,7 @@ impl<'tcx> DumpVisitor<'tcx> {
self.save_ctxt.lookup_def_id(ref_id)
}
pub fn dump_crate_info(&mut self, name: &str) {
pub fn dump_crate_info(&mut self, name: Symbol) {
let source_file = self.tcx.sess.local_crate_source_file.as_ref();
let crate_root = source_file.map(|source_file| {
let source_file = Path::new(source_file);
@ -124,7 +124,7 @@ impl<'tcx> DumpVisitor<'tcx> {
let data = CratePreludeData {
crate_id: GlobalCrateId {
name: name.into(),
name: name.to_string(),
disambiguator: (self.tcx.sess.local_stable_crate_id().to_u64(), 0),
},
crate_root: crate_root.unwrap_or_else(|| "<no source>".to_owned()),
@ -135,7 +135,7 @@ impl<'tcx> DumpVisitor<'tcx> {
self.dumper.crate_prelude(data);
}
pub fn dump_compilation_options(&mut self, input: &Input, crate_name: &str) {
pub fn dump_compilation_options(&mut self, input: &Input, crate_name: Symbol) {
// Apply possible `remap-path-prefix` remapping to the input source file
// (and don't include remapping args anymore)
let (program, arguments) = {

View file

@ -95,7 +95,7 @@ impl<'tcx> SaveContext<'tcx> {
}
/// Returns path to the compilation output (e.g., libfoo-12345678.rmeta)
pub fn compilation_output(&self, crate_name: &str) -> PathBuf {
pub fn compilation_output(&self, crate_name: Symbol) -> PathBuf {
let sess = &self.tcx.sess;
// Save-analysis is emitted per whole session, not per each crate type
let crate_type = sess.crate_types()[0];
@ -894,8 +894,8 @@ pub struct DumpHandler<'a> {
}
impl<'a> DumpHandler<'a> {
pub fn new(odir: Option<&'a Path>, cratename: &str) -> DumpHandler<'a> {
DumpHandler { odir, cratename: cratename.to_owned() }
pub fn new(odir: Option<&'a Path>, cratename: Symbol) -> DumpHandler<'a> {
DumpHandler { odir, cratename: cratename.to_string() }
}
fn output_file(&self, ctx: &SaveContext<'_>) -> (BufWriter<File>, PathBuf) {
@ -960,7 +960,7 @@ impl SaveHandler for CallbackHandler<'_> {
pub fn process_crate<'l, 'tcx, H: SaveHandler>(
tcx: TyCtxt<'tcx>,
cratename: &str,
cratename: Symbol,
input: &'l Input,
config: Option<Config>,
mut handler: H,