Skip to content

Commit 2da7a9c

Browse files
committed
Use Symbol for codegen unit names.
This is a straightforward replacement except for two places where we have to convert to `LocalInternedString` to get a stable sort.
1 parent dddacf1 commit 2da7a9c

File tree

11 files changed

+46
-51
lines changed

11 files changed

+46
-51
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use crate::ich::{Fingerprint, StableHashingContext};
5959
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
6060
use std::fmt;
6161
use std::hash::Hash;
62-
use syntax_pos::symbol::InternedString;
62+
use syntax_pos::symbol::Symbol;
6363
use crate::traits;
6464
use crate::traits::query::{
6565
CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
@@ -426,7 +426,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
426426

427427
[anon] TraitSelect,
428428

429-
[] CompileCodegenUnit(InternedString),
429+
[] CompileCodegenUnit(Symbol),
430430

431431
[eval_always] Analysis(CrateNum),
432432
]);

src/librustc/mir/mono.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
22
use crate::hir::HirId;
3-
use syntax::symbol::{InternedString, Symbol};
3+
use syntax::symbol::Symbol;
44
use syntax::attr::InlineAttr;
55
use syntax::source_map::Span;
66
use crate::ty::{Instance, InstanceDef, TyCtxt, SymbolName, subst::InternalSubsts};
@@ -246,7 +246,7 @@ pub struct CodegenUnit<'tcx> {
246246
/// name be unique amongst **all** crates. Therefore, it should
247247
/// contain something unique to this crate (e.g., a module path)
248248
/// as well as the crate name and disambiguator.
249-
name: InternedString,
249+
name: Symbol,
250250
items: FxHashMap<MonoItem<'tcx>, (Linkage, Visibility)>,
251251
size_estimate: Option<usize>,
252252
}
@@ -294,19 +294,19 @@ impl_stable_hash_for!(enum self::Visibility {
294294
});
295295

296296
impl<'tcx> CodegenUnit<'tcx> {
297-
pub fn new(name: InternedString) -> CodegenUnit<'tcx> {
297+
pub fn new(name: Symbol) -> CodegenUnit<'tcx> {
298298
CodegenUnit {
299299
name: name,
300300
items: Default::default(),
301301
size_estimate: None,
302302
}
303303
}
304304

305-
pub fn name(&self) -> &InternedString {
306-
&self.name
305+
pub fn name(&self) -> Symbol {
306+
self.name
307307
}
308308

309-
pub fn set_name(&mut self, name: InternedString) {
309+
pub fn set_name(&mut self, name: Symbol) {
310310
self.name = name;
311311
}
312312

@@ -474,7 +474,7 @@ impl CodegenUnitNameBuilder<'tcx> {
474474
cnum: CrateNum,
475475
components: I,
476476
special_suffix: Option<S>)
477-
-> InternedString
477+
-> Symbol
478478
where I: IntoIterator<Item=C>,
479479
C: fmt::Display,
480480
S: fmt::Display,
@@ -487,7 +487,7 @@ impl CodegenUnitNameBuilder<'tcx> {
487487
cgu_name
488488
} else {
489489
let cgu_name = &cgu_name.as_str()[..];
490-
InternedString::intern(&CodegenUnit::mangle_name(cgu_name))
490+
Symbol::intern(&CodegenUnit::mangle_name(cgu_name))
491491
}
492492
}
493493

@@ -497,7 +497,7 @@ impl CodegenUnitNameBuilder<'tcx> {
497497
cnum: CrateNum,
498498
components: I,
499499
special_suffix: Option<S>)
500-
-> InternedString
500+
-> Symbol
501501
where I: IntoIterator<Item=C>,
502502
C: fmt::Display,
503503
S: fmt::Display,
@@ -543,6 +543,6 @@ impl CodegenUnitNameBuilder<'tcx> {
543543
write!(cgu_name, ".{}", special_suffix).unwrap();
544544
}
545545

546-
InternedString::intern(&cgu_name[..])
546+
Symbol::intern(&cgu_name[..])
547547
}
548548
}

src/librustc/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::traits::query::{
1515
};
1616

1717
use std::borrow::Cow;
18-
use syntax_pos::symbol::InternedString;
18+
use syntax_pos::symbol::Symbol;
1919

2020
// Each of these queries corresponds to a function pointer field in the
2121
// `Providers` struct for requesting a value of that type, and a method
@@ -924,7 +924,7 @@ rustc_queries! {
924924
desc { "collect_and_partition_mono_items" }
925925
}
926926
query is_codegened_item(_: DefId) -> bool {}
927-
query codegen_unit(_: InternedString) -> Arc<CodegenUnit<'tcx>> {
927+
query codegen_unit(_: Symbol) -> Arc<CodegenUnit<'tcx>> {
928928
no_force
929929
desc { "codegen_unit" }
930930
}

src/librustc/ty/query/keys.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::mir;
1111
use std::fmt::Debug;
1212
use std::hash::Hash;
1313
use syntax_pos::{Span, DUMMY_SP};
14-
use syntax_pos::symbol::InternedString;
14+
use syntax_pos::symbol::Symbol;
1515

1616
/// The `Key` trait controls what types can legally be used as the key
1717
/// for a query.
@@ -190,7 +190,7 @@ impl<'tcx> Key for traits::Environment<'tcx> {
190190
}
191191
}
192192

193-
impl Key for InternedString {
193+
impl Key for Symbol {
194194
fn query_crate(&self) -> CrateNum {
195195
LOCAL_CRATE
196196
}

src/librustc/ty/query/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ use std::ops::Deref;
5555
use std::sync::Arc;
5656
use std::any::type_name;
5757
use syntax_pos::{Span, DUMMY_SP};
58-
use syntax_pos::symbol::InternedString;
5958
use syntax::attr;
6059
use syntax::ast;
6160
use syntax::feature_gate;

src/librustc_codegen_llvm/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_codegen_ssa::back::write::submit_codegened_module_to_llvm;
3636

3737
use std::ffi::CString;
3838
use std::time::Instant;
39-
use syntax_pos::symbol::InternedString;
39+
use syntax_pos::symbol::Symbol;
4040
use rustc::hir::CodegenFnAttrs;
4141

4242
use crate::value::Value;
@@ -105,7 +105,7 @@ pub fn iter_globals(llmod: &'ll llvm::Module) -> ValueIter<'ll> {
105105

106106
pub fn compile_codegen_unit(
107107
tcx: TyCtxt<'tcx>,
108-
cgu_name: InternedString,
108+
cgu_name: Symbol,
109109
tx_to_llvm_workers: &std::sync::mpsc::Sender<Box<dyn std::any::Any + Send>>,
110110
) {
111111
let prof_timer = tcx.prof.generic_activity("codegen_module");
@@ -131,7 +131,7 @@ pub fn compile_codegen_unit(
131131

132132
fn module_codegen(
133133
tcx: TyCtxt<'_>,
134-
cgu_name: InternedString,
134+
cgu_name: Symbol,
135135
) -> ModuleCodegen<ModuleLlvm> {
136136
let cgu = tcx.codegen_unit(cgu_name);
137137
// Instantiate monomorphizations without filling out definitions yet...

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use rustc_codegen_ssa::CompiledModule;
5050
use errors::{FatalError, Handler};
5151
use rustc::dep_graph::WorkProduct;
5252
use syntax_expand::allocator::AllocatorKind;
53-
use syntax_pos::symbol::InternedString;
5453
pub use llvm_util::target_features;
5554
use std::any::Any;
5655
use std::sync::Arc;
@@ -123,7 +122,7 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
123122
}
124123
fn compile_codegen_unit(
125124
&self, tcx: TyCtxt<'_>,
126-
cgu_name: InternedString,
125+
cgu_name: Symbol,
127126
tx: &std::sync::mpsc::Sender<Box<dyn Any + Send>>,
128127
) {
129128
base::compile_codegen_unit(tcx, cgu_name, tx);

src/librustc_codegen_ssa/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
515515
// unnecessarily.
516516
if tcx.dep_graph.is_fully_enabled() {
517517
for cgu in &codegen_units {
518-
tcx.codegen_unit(cgu.name().clone());
518+
tcx.codegen_unit(cgu.name());
519519
}
520520
}
521521

@@ -603,7 +603,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
603603
match cgu_reuse {
604604
CguReuse::No => {
605605
let start_time = Instant::now();
606-
backend.compile_codegen_unit(tcx, *cgu.name(), &ongoing_codegen.coordinator_send);
606+
backend.compile_codegen_unit(tcx, cgu.name(), &ongoing_codegen.coordinator_send);
607607
total_codegen_time += start_time.elapsed();
608608
false
609609
}

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
1010
use std::sync::Arc;
1111
use std::sync::mpsc;
1212
use syntax_expand::allocator::AllocatorKind;
13-
use syntax_pos::symbol::InternedString;
13+
use syntax_pos::symbol::Symbol;
1414

1515
pub trait BackendTypes {
1616
type Value: CodegenObject;
@@ -50,7 +50,7 @@ pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Se
5050
fn compile_codegen_unit(
5151
&self,
5252
tcx: TyCtxt<'_>,
53-
cgu_name: InternedString,
53+
cgu_name: Symbol,
5454
tx_to_llvm_workers: &mpsc::Sender<Box<dyn std::any::Any + Send>>,
5555
);
5656
// If find_features is true this won't access `sess.crate_types` by assuming

src/librustc_incremental/assert_module_sources.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc::mir::mono::CodegenUnitNameBuilder;
2727
use rustc::ty::TyCtxt;
2828
use std::collections::BTreeSet;
2929
use syntax::ast;
30-
use syntax::symbol::{InternedString, Symbol, sym};
30+
use syntax::symbol::{Symbol, sym};
3131
use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED,
3232
ATTR_EXPECTED_CGU_REUSE};
3333

@@ -45,8 +45,8 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
4545
.collect_and_partition_mono_items(LOCAL_CRATE)
4646
.1
4747
.iter()
48-
.map(|cgu| *cgu.name())
49-
.collect::<BTreeSet<InternedString>>();
48+
.map(|cgu| cgu.name())
49+
.collect::<BTreeSet<Symbol>>();
5050

5151
let ams = AssertModuleSource {
5252
tcx,
@@ -61,7 +61,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) {
6161

6262
struct AssertModuleSource<'tcx> {
6363
tcx: TyCtxt<'tcx>,
64-
available_cgus: BTreeSet<InternedString>,
64+
available_cgus: BTreeSet<Symbol>,
6565
}
6666

6767
impl AssertModuleSource<'tcx> {

0 commit comments

Comments
 (0)