Skip to content

Commit dbe459d

Browse files
committed
Auto merge of #85904 - cjgillot:one-name, r=petrochenkov
Restrict access to crate_name. Also remove original_crate_name, which had the exact same implementation. Part of #85153
2 parents 2f601ef + 0e71283 commit dbe459d

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
@@ -188,7 +188,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
188188
foreign_modules => { cdata.get_foreign_modules(tcx) }
189189
crate_hash => { cdata.root.hash }
190190
crate_host_hash => { cdata.host_hash }
191-
original_crate_name => { cdata.root.name }
191+
crate_name => { cdata.root.name }
192192

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

@@ -205,7 +205,6 @@ provide! { <'tcx> tcx, def_id, other, cdata,
205205
let r = *cdata.dep_kind.lock();
206206
r
207207
}
208-
crate_name => { cdata.root.name }
209208
item_children => {
210209
let mut result = SmallVec::<[_; 8]>::new();
211210
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
@@ -1247,10 +1247,6 @@ rustc_queries! {
12471247
eval_always
12481248
desc { "looking up the hash of a host version of a crate" }
12491249
}
1250-
query original_crate_name(_: CrateNum) -> Symbol {
1251-
eval_always
1252-
desc { "looking up the original name a crate" }
1253-
}
12541250
query extra_filename(_: CrateNum) -> String {
12551251
eval_always
12561252
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
@@ -1005,7 +1005,7 @@ pub struct GlobalCtxt<'tcx> {
10051005

10061006
/// The definite name of the current crate after taking into account
10071007
/// attributes, commandline parameters, etc.
1008-
pub crate_name: Symbol,
1008+
crate_name: Symbol,
10091009

10101010
/// Data layout specification for the current target.
10111011
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
@@ -1621,7 +1621,7 @@ impl<'tcx> TyCtxt<'tcx> {
16211621

16221622
fn item_name_from_def_id(self, def_id: DefId) -> Option<Symbol> {
16231623
if def_id.index == CRATE_DEF_INDEX {
1624-
Some(self.original_crate_name(def_id.krate))
1624+
Some(self.crate_name(def_id.krate))
16251625
} else {
16261626
let def_key = self.def_key(def_id);
16271627
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)