Skip to content

Commit 81d17d4

Browse files
committed
Add documentation for some queries
1 parent 7314873 commit 81d17d4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue
109109
// Queries marked with `fatal_cycle` do not need the latter implementation,
110110
// as they will raise an fatal error on query cycles instead.
111111
rustc_queries! {
112+
/// This exists purely for testing the interactions between delay_span_bug and incremental.
112113
query trigger_delay_span_bug(key: DefId) -> () {
113-
desc { "triggering a delay span bug" }
114+
desc { "triggering a delay span bug for testing incremental" }
114115
}
115116

117+
/// Collects the list of all tools registered using `#![register_tool]`.
116118
query registered_tools(_: ()) -> &'tcx ty::RegisteredTools {
117119
arena_cache
118120
desc { "compute registered tools for crate" }
@@ -286,6 +288,7 @@ rustc_queries! {
286288
}
287289
}
288290

291+
/// The root query triggering all analysis passes like typeck or borrowck.
289292
query analysis(key: ()) -> Result<(), ErrorGuaranteed> {
290293
eval_always
291294
desc { "running analysis passes on this crate" }
@@ -1785,10 +1788,17 @@ rustc_queries! {
17851788
desc { "calculating the missing lang items in a crate" }
17861789
separate_provide_extern
17871790
}
1791+
1792+
/// The visible parent map is a map from every item to a visible parent.
1793+
/// It prefers the shortest visible path to an item.
1794+
/// Used for diagnostics, for example path trimming.
1795+
/// The parents are modules, enums or traits.
17881796
query visible_parent_map(_: ()) -> &'tcx DefIdMap<DefId> {
17891797
arena_cache
17901798
desc { "calculating the visible parent map" }
17911799
}
1800+
/// Collects the "trimmed", shortest accessible paths to all items for diagnostics.
1801+
/// See the [provider docs](`rustc_middle::ty::print::trimmed_def_paths`) for more info.
17921802
query trimmed_def_paths(_: ()) -> &'tcx FxHashMap<DefId, Symbol> {
17931803
arena_cache
17941804
desc { "calculating trimmed def paths" }

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,8 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
30323032
/// The implementation uses similar import discovery logic to that of 'use' suggestions.
30333033
///
30343034
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths!`].
3035-
fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
3035+
// this is pub to be able to intra-doc-link it
3036+
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
30363037
let mut map: FxHashMap<DefId, Symbol> = FxHashMap::default();
30373038

30383039
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {

0 commit comments

Comments
 (0)