File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,23 @@ the code can be processed.
145
145
146
146
Therefore, the resolution is performed in multiple stages.
147
147
148
+ ## Speculative crate loading
149
+
150
+ To give useful errors, rustc suggests importing paths into scope if they're
151
+ not found. How does it do this? It looks through every module of every crate
152
+ and looks for possible matches. This even includes crates that haven't yet
153
+ been loaded!
154
+
155
+ Loading crates for import suggestions that haven't yet been loaded is called
156
+ _ speculative crate loading_ , because any errors it encounters shouldn't be
157
+ reported: resolve decided to load them, not the user. The function that does
158
+ this is ` lookup_import_candidates ` and lives in
159
+ ` rustc_resolve/src/diagnostics.rs ` .
160
+
161
+ To tell the difference between speculative loads and loads initiated by the
162
+ user, resolve passes around a ` record_used ` parameter, which is ` false ` when
163
+ the load is speculative.
164
+
148
165
## TODO:
149
166
150
167
This is a result of the first pass of learning the code. It is definitely
You can’t perform that action at this time.
0 commit comments