Skip to content

Commit 10fb4b2

Browse files
committed
Restrict access to crate_name.
Also remove original_crate_name, which had the exact same implementation
1 parent 5d9f96a commit 10fb4b2

File tree

19 files changed

+23
-30
lines changed

19 files changed

+23
-30
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
524524
}
525525

526526
fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
527-
Ok(vec![self.tcx.original_crate_name(cnum).to_string()])
527+
Ok(vec![self.tcx.crate_name(cnum).to_string()])
528528
}
529529
fn path_qualified(
530530
self,

compiler/rustc_lint/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ impl<'tcx> LateContext<'tcx> {
922922
}
923923

924924
fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
925-
Ok(vec![self.tcx.original_crate_name(cnum)])
925+
Ok(vec![self.tcx.crate_name(cnum)])
926926
}
927927

928928
fn path_qualified(

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
187187
foreign_modules => { cdata.get_foreign_modules(tcx) }
188188
crate_hash => { cdata.root.hash }
189189
crate_host_hash => { cdata.host_hash }
190-
original_crate_name => { cdata.root.name }
190+
crate_name => { cdata.root.name }
191191

192192
extra_filename => { cdata.root.extra_filename.clone() }
193193

@@ -204,7 +204,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
204204
let r = *cdata.dep_kind.lock();
205205
r
206206
}
207-
crate_name => { cdata.root.name }
208207
item_children => {
209208
let mut result = SmallVec::<[_; 8]>::new();
210209
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ impl EncodeContext<'a, 'tcx> {
16731673
.iter()
16741674
.map(|&cnum| {
16751675
let dep = CrateDep {
1676-
name: self.tcx.original_crate_name(cnum),
1676+
name: self.tcx.crate_name(cnum),
16771677
hash: self.tcx.crate_hash(cnum),
16781678
host_hash: self.tcx.crate_host_hash(cnum),
16791679
kind: self.tcx.dep_kind(cnum),

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
285285
// required that their size stay the same, but we don't want to change
286286
// it inadvertently. This assert just ensures we're aware of any change.
287287
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
288-
static_assert_size!(DepNode, 18);
288+
static_assert_size!(DepNode, 17);
289289

290290
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
291291
static_assert_size!(DepNode, 24);

compiler/rustc_middle/src/middle/exported_symbols.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> ExportedSymbol<'tcx> {
4949
pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String {
5050
format!(
5151
"rust_metadata_{}_{:08x}",
52-
tcx.original_crate_name(LOCAL_CRATE),
52+
tcx.crate_name(LOCAL_CRATE),
5353
tcx.sess.local_stable_crate_id().to_u64(),
5454
)
5555
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,6 @@ rustc_queries! {
12521252
eval_always
12531253
desc { "looking up the hash of a host version of a crate" }
12541254
}
1255-
query original_crate_name(_: CrateNum) -> Symbol {
1256-
eval_always
1257-
desc { "looking up the original name a crate" }
1258-
}
12591255
query extra_filename(_: CrateNum) -> String {
12601256
eval_always
12611257
desc { "looking up the extra filename for a crate" }

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ pub struct GlobalCtxt<'tcx> {
985985

986986
/// The definite name of the current crate after taking into account
987987
/// attributes, commandline parameters, etc.
988-
pub crate_name: Symbol,
988+
crate_name: Symbol,
989989

990990
/// Data layout specification for the current target.
991991
pub data_layout: TargetDataLayout,

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ impl<'tcx> TyCtxt<'tcx> {
16191619

16201620
fn item_name_from_def_id(self, def_id: DefId) -> Option<Symbol> {
16211621
if def_id.index == CRATE_DEF_INDEX {
1622-
Some(self.original_crate_name(def_id.krate))
1622+
Some(self.crate_name(def_id.krate))
16231623
} else {
16241624
let def_key = self.def_key(def_id);
16251625
match def_key.disambiguated_data.data {

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ pub trait PrettyPrinter<'tcx>:
452452
}
453453
// Re-exported `extern crate` (#43189).
454454
DefPathData::CrateRoot => {
455-
data = DefPathData::TypeNs(self.tcx().original_crate_name(def_id.krate));
455+
data = DefPathData::TypeNs(self.tcx().crate_name(def_id.krate));
456456
}
457457
_ => {}
458458
}

0 commit comments

Comments
 (0)