about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-23 12:44:13 +0000
committerbors <bors@rust-lang.org>2024-05-23 12:44:13 +0000
commited172dbbaf1c702b99da54554b33b3fe65021da9 (patch)
tree52b83635b29ced282013c7e8aa1088e57dab397e /compiler/rustc_middle/src/query
parent39d2f2affdd6b2856ab4b91359cc0d32b90bd26f (diff)
parentcf92f4c52f6160b90bf119b59d89c20dd107378c (diff)
downloadrust-ed172dbbaf1c702b99da54554b33b3fe65021da9.tar.gz
rust-ed172dbbaf1c702b99da54554b33b3fe65021da9.zip
Auto merge of #125448 - matthiaskrgr:rollup-vn6nleh, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #124297 (Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type)
 - #124516 (Allow monomorphization time const eval failures if the cause is a type layout issue)
 - #124976 (rustc: Use `tcx.used_crates(())` more)
 - #125210 (Cleanup: Fix up some diagnostics)
 - #125409 (Rename `FrameworkOnlyWindows` to `RawDylibOnlyWindows`)
 - #125416 (Use correct param-env in `MissingCopyImplementations`)
 - #125421 (Rewrite `core-no-oom-handling`, `issue-24445` and `issue-38237` `run-make` tests to new `rmake.rs` format)
 - #125438 (Remove unneeded string conversion)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_middle/src/query')
-rw-r--r--compiler/rustc_middle/src/query/mod.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index c2f7a227f66..0654d82838c 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -1860,13 +1860,22 @@ rustc_queries! {
         eval_always
         desc { "calculating the stability index for the local crate" }
     }
-    query crates(_: ()) -> &'tcx [CrateNum] {
+    /// All loaded crates, including those loaded purely for doc links or diagnostics.
+    /// (Diagnostics include lints, so speculatively loaded crates may occur in successful
+    /// compilation even without doc links.)
+    /// Should be used when encoding crate metadata (and therefore when generating crate hash,
+    /// depinfo and similar things), to avoid dangling crate references in other encoded data,
+    /// like source maps.
+    /// May also be used for diagnostics - if we are loading a crate anyway we can suggest some
+    /// items from it as well.
+    /// But otherwise, `used_crates` should generally be used.
+    query crates_including_speculative(_: ()) -> &'tcx [CrateNum] {
         eval_always
         desc { "fetching all foreign CrateNum instances" }
     }
-    // Crates that are loaded non-speculatively (not for diagnostics or doc links).
-    // FIXME: This is currently only used for collecting lang items, but should be used instead of
-    // `crates` in most other cases too.
+    /// Crates that are loaded non-speculatively (not for diagnostics or doc links).
+    /// Should be used to maintain observable language behavior, for example when collecting lang
+    /// items or impls from all crates, or collecting libraries to link.
     query used_crates(_: ()) -> &'tcx [CrateNum] {
         eval_always
         desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }