1
Fork 0

Restrict access to crate_name.

Also remove original_crate_name, which had the exact same implementation
This commit is contained in:
Camille GILLOT 2021-05-10 18:23:32 +02:00
parent 2f601ef527
commit 0e71283495
19 changed files with 23 additions and 30 deletions

View file

@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode<DepKind>;
// required that their size stay the same, but we don't want to change
// it inadvertently. This assert just ensures we're aware of any change.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
static_assert_size!(DepNode, 18);
static_assert_size!(DepNode, 17);
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
static_assert_size!(DepNode, 24);

View file

@ -49,7 +49,7 @@ impl<'tcx> ExportedSymbol<'tcx> {
pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String {
format!(
"rust_metadata_{}_{:08x}",
tcx.original_crate_name(LOCAL_CRATE),
tcx.crate_name(LOCAL_CRATE),
tcx.sess.local_stable_crate_id().to_u64(),
)
}

View file

@ -1247,10 +1247,6 @@ rustc_queries! {
eval_always
desc { "looking up the hash of a host version of a crate" }
}
query original_crate_name(_: CrateNum) -> Symbol {
eval_always
desc { "looking up the original name a crate" }
}
query extra_filename(_: CrateNum) -> String {
eval_always
desc { "looking up the extra filename for a crate" }

View file

@ -1005,7 +1005,7 @@ pub struct GlobalCtxt<'tcx> {
/// The definite name of the current crate after taking into account
/// attributes, commandline parameters, etc.
pub crate_name: Symbol,
crate_name: Symbol,
/// Data layout specification for the current target.
pub data_layout: TargetDataLayout,

View file

@ -1621,7 +1621,7 @@ impl<'tcx> TyCtxt<'tcx> {
fn item_name_from_def_id(self, def_id: DefId) -> Option<Symbol> {
if def_id.index == CRATE_DEF_INDEX {
Some(self.original_crate_name(def_id.krate))
Some(self.crate_name(def_id.krate))
} else {
let def_key = self.def_key(def_id);
match def_key.disambiguated_data.data {

View file

@ -452,7 +452,7 @@ pub trait PrettyPrinter<'tcx>:
}
// Re-exported `extern crate` (#43189).
DefPathData::CrateRoot => {
data = DefPathData::TypeNs(self.tcx().original_crate_name(def_id.krate));
data = DefPathData::TypeNs(self.tcx().crate_name(def_id.krate));
}
_ => {}
}