Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_metadata: Privatize more things #66496

Merged
merged 10 commits into from
Nov 20, 2019
Prev Previous commit
Next Next commit
rustc_metadata: Remove CrateMetadata::is_proc_macro_crate
  • Loading branch information
petrochenkov committed Nov 17, 2019
commit 26f113e5b670a37678750b81d8ad3e5ca2a789a0
18 changes: 7 additions & 11 deletions src/librustc_metadata/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,6 @@ impl<'a, 'tcx> CrateMetadata {
}
}

fn is_proc_macro_crate(&self) -> bool {
self.root.is_proc_macro_crate()
}

fn is_proc_macro(&self, id: DefIndex) -> bool {
self.root.proc_macro_data.and_then(|data| data.decode(self).find(|x| *x == id)).is_some()
}
Expand Down Expand Up @@ -895,7 +891,7 @@ impl<'a, 'tcx> CrateMetadata {

/// Iterates over the language items in the given crate.
fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// Proc macro crates do not export any lang-items to the target.
&[]
} else {
Expand All @@ -911,7 +907,7 @@ impl<'a, 'tcx> CrateMetadata {
&self,
tcx: TyCtxt<'tcx>,
) -> &'tcx FxHashMap<Symbol, DefId> {
tcx.arena.alloc(if self.is_proc_macro_crate() {
tcx.arena.alloc(if self.root.is_proc_macro_crate() {
// Proc macro crates do not export any diagnostic-items to the target.
Default::default()
} else {
Expand Down Expand Up @@ -1219,7 +1215,7 @@ impl<'a, 'tcx> CrateMetadata {
tcx: TyCtxt<'tcx>,
filter: Option<DefId>,
) -> &'tcx [DefId] {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// proc-macro crates export no trait impls.
return &[]
}
Expand Down Expand Up @@ -1263,7 +1259,7 @@ impl<'a, 'tcx> CrateMetadata {


fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// Proc macro crates do not have any *target* native libraries.
vec![]
} else {
Expand All @@ -1272,7 +1268,7 @@ impl<'a, 'tcx> CrateMetadata {
}

fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// Proc macro crates do not have any *target* foreign modules.
&[]
} else {
Expand All @@ -1295,7 +1291,7 @@ impl<'a, 'tcx> CrateMetadata {
}

fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// Proc macro crates do not depend on any target weak lang-items.
&[]
} else {
Expand All @@ -1319,7 +1315,7 @@ impl<'a, 'tcx> CrateMetadata {
&self,
tcx: TyCtxt<'tcx>,
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
if self.is_proc_macro_crate() {
if self.root.is_proc_macro_crate() {
// If this crate is a custom derive crate, then we're not even going to
// link those in so we skip those crates.
vec![]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl cstore::CStore {
let _prof_timer = sess.prof.generic_activity("metadata_load_macro");

let data = self.get_crate_data(id.krate);
if data.is_proc_macro_crate() {
if data.root.is_proc_macro_crate() {
return LoadedMacro::ProcMacro(data.load_proc_macro(id.index, sess));
}

Expand Down