Skip to content

Commit 487c378

Browse files
committed
rustc_metadata: Load metadata for indirect macro-only dependencies
1 parent d9a328a commit 487c378

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

src/librustc/middle/cstore.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ impl CrateSource {
5353
HashStable
5454
)]
5555
pub enum DepKind {
56-
/// A dependency that is only used for its macros, none of which are visible from other crates.
57-
/// These are included in the metadata only as placeholders and are ignored when decoding.
58-
UnexportedMacrosOnly,
5956
/// A dependency that is only used for its macros.
6057
MacrosOnly,
6158
/// A dependency that is always injected into the dependency list and so
@@ -69,7 +66,7 @@ pub enum DepKind {
6966
impl DepKind {
7067
pub fn macros_only(self) -> bool {
7168
match self {
72-
DepKind::UnexportedMacrosOnly | DepKind::MacrosOnly => true,
69+
DepKind::MacrosOnly => true,
7370
DepKind::Implicit | DepKind::Explicit => false,
7471
}
7572
}

src/librustc_metadata/creader.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl<'a> CrateLoader<'a> {
463463
self.load(&mut locator)
464464
.map(|r| (r, None))
465465
.or_else(|| {
466-
dep_kind = DepKind::UnexportedMacrosOnly;
466+
dep_kind = DepKind::MacrosOnly;
467467
self.load_proc_macro(&mut locator, path_kind)
468468
})
469469
.ok_or_else(move || LoadError::LocatorError(locator))?
@@ -473,7 +473,7 @@ impl<'a> CrateLoader<'a> {
473473
(LoadResult::Previous(cnum), None) => {
474474
let data = self.cstore.get_crate_data(cnum);
475475
if data.is_proc_macro_crate() {
476-
dep_kind = DepKind::UnexportedMacrosOnly;
476+
dep_kind = DepKind::MacrosOnly;
477477
}
478478
data.update_dep_kind(|data_dep_kind| cmp::max(data_dep_kind, dep_kind));
479479
Ok(cnum)
@@ -547,9 +547,6 @@ impl<'a> CrateLoader<'a> {
547547
"resolving dep crate {} hash: `{}` extra filename: `{}`",
548548
dep.name, dep.hash, dep.extra_filename
549549
);
550-
if dep.kind == DepKind::UnexportedMacrosOnly {
551-
return krate;
552-
}
553550
let dep_kind = match dep_kind {
554551
DepKind::MacrosOnly => DepKind::MacrosOnly,
555552
_ => dep.kind,
@@ -853,7 +850,7 @@ impl<'a> CrateLoader<'a> {
853850
None => item.ident.name,
854851
};
855852
let dep_kind = if attr::contains_name(&item.attrs, sym::no_link) {
856-
DepKind::UnexportedMacrosOnly
853+
DepKind::MacrosOnly
857854
} else {
858855
DepKind::Explicit
859856
};

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::rmeta::{self, encoder};
77
use rustc::hir::exports::Export;
88
use rustc::hir::map::definitions::DefPathTable;
99
use rustc::hir::map::{DefKey, DefPath, DefPathHash};
10-
use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind};
10+
use rustc::middle::cstore::{CrateSource, CrateStore, EncodedMetadata, NativeLibraryKind};
1111
use rustc::middle::exported_symbols::ExportedSymbol;
1212
use rustc::middle::stability::DeprecationEntry;
1313
use rustc::session::{CrateDisambiguator, Session};
@@ -392,14 +392,6 @@ pub fn provide(providers: &mut Providers<'_>) {
392392
}
393393

394394
impl CStore {
395-
pub fn export_macros_untracked(&self, cnum: CrateNum) {
396-
let data = self.get_crate_data(cnum);
397-
let mut dep_kind = data.dep_kind.lock();
398-
if *dep_kind == DepKind::UnexportedMacrosOnly {
399-
*dep_kind = DepKind::MacrosOnly;
400-
}
401-
}
402-
403395
pub fn struct_field_names_untracked(&self, def: DefId, sess: &Session) -> Vec<Spanned<Symbol>> {
404396
self.get_crate_data(def.krate).get_struct_field_names(def.index, sess)
405397
}

src/librustc_resolve/imports.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,6 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14031403
if is_good_import || binding.is_macro_def() {
14041404
let res = binding.res();
14051405
if res != Res::Err {
1406-
if let Some(def_id) = res.opt_def_id() {
1407-
if !def_id.is_local() {
1408-
this.cstore().export_macros_untracked(def_id.krate);
1409-
}
1410-
}
14111406
reexports.push(Export { ident, res, span: binding.span, vis: binding.vis });
14121407
}
14131408
}

0 commit comments

Comments
 (0)