Skip to content

Commit 13e62be

Browse files
authored
Rollup merge of #104016 - Nilstrieb:query-descs-more, r=compiler-errors
Add internal descriptions to a few queries helps with #104008
2 parents ef0d79f + 27e0f03 commit 13e62be

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

Diff for: compiler/rustc_interface/src/proc_macro_decls.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ use rustc_middle::ty::TyCtxt;
44
use rustc_span::symbol::sym;
55

66
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
7-
let mut finder = Finder { tcx, decls: None };
7+
let mut decls = None;
88

99
for id in tcx.hir().items() {
10-
let attrs = finder.tcx.hir().attrs(id.hir_id());
11-
if finder.tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
12-
finder.decls = Some(id.owner_id.def_id);
10+
let attrs = tcx.hir().attrs(id.hir_id());
11+
if tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
12+
decls = Some(id.owner_id.def_id);
1313
}
1414
}
1515

16-
finder.decls
17-
}
18-
19-
struct Finder<'tcx> {
20-
tcx: TyCtxt<'tcx>,
21-
decls: Option<LocalDefId>,
16+
decls
2217
}
2318

2419
pub(crate) fn provide(providers: &mut Providers) {

Diff for: compiler/rustc_middle/src/query/mod.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ rustc_queries! {
271271
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
272272
}
273273

274+
/// Look up all native libraries this crate depends on.
275+
/// These are assembled from the following places:
276+
/// - `extern` blocks (depending on their `link` attributes)
277+
/// - the `libs` (`-l`) option
274278
query native_libraries(_: CrateNum) -> Vec<NativeLib> {
275279
arena_cache
276280
desc { "looking up the native libraries of a linked crate" }
@@ -1539,6 +1543,7 @@ rustc_queries! {
15391543
desc { "available upstream drop-glue for `{:?}`", substs }
15401544
}
15411545

1546+
/// Returns a list of all `extern` blocks of a crate.
15421547
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
15431548
arena_cache
15441549
desc { "looking up the foreign modules of a linked crate" }
@@ -1550,27 +1555,37 @@ rustc_queries! {
15501555
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
15511556
desc { "looking up the entry function of a crate" }
15521557
}
1558+
1559+
/// Finds the `rustc_proc_macro_decls` item of a crate.
15531560
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1554-
desc { "looking up the derive registrar for a crate" }
1561+
desc { "looking up the proc macro declarations for a crate" }
15551562
}
1563+
15561564
// The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
15571565
// Changing the name should cause a compiler error, but in case that changes, be aware.
15581566
query crate_hash(_: CrateNum) -> Svh {
15591567
eval_always
15601568
desc { "looking up the hash a crate" }
15611569
separate_provide_extern
15621570
}
1571+
1572+
/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
15631573
query crate_host_hash(_: CrateNum) -> Option<Svh> {
15641574
eval_always
15651575
desc { "looking up the hash of a host version of a crate" }
15661576
separate_provide_extern
15671577
}
1578+
1579+
/// Gets the extra data to put in each output filename for a crate.
1580+
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
15681581
query extra_filename(_: CrateNum) -> String {
15691582
arena_cache
15701583
eval_always
15711584
desc { "looking up the extra filename for a crate" }
15721585
separate_provide_extern
15731586
}
1587+
1588+
/// Gets the paths where the crate came from in the file system.
15741589
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
15751590
arena_cache
15761591
eval_always
@@ -1594,6 +1609,7 @@ rustc_queries! {
15941609
separate_provide_extern
15951610
}
15961611

1612+
/// Get the corresponding native library from the `native_libraries` query
15971613
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
15981614
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
15991615
}

0 commit comments

Comments
 (0)