@@ -16,6 +16,14 @@ use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
16
16
use rustc_span:: symbol:: Symbol ;
17
17
use std:: borrow:: Cow ;
18
18
19
+ fn describe_as_module ( def_id : DefId , tcx : TyCtxt < ' _ > ) -> String {
20
+ if def_id. is_top_level_module ( ) {
21
+ format ! ( "top-level module" )
22
+ } else {
23
+ format ! ( "module `{}`" , tcx. def_path_str( def_id) )
24
+ }
25
+ }
26
+
19
27
// Each of these queries corresponds to a function pointer field in the
20
28
// `Providers` struct for requesting a value of that type, and a method
21
29
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
@@ -332,50 +340,50 @@ rustc_queries! {
332
340
333
341
Other {
334
342
query lint_mod( key: DefId ) -> ( ) {
335
- desc { |tcx| "linting {}" , key . describe_as_module( tcx) }
343
+ desc { |tcx| "linting {}" , describe_as_module( key , tcx) }
336
344
}
337
345
338
346
/// Checks the attributes in the module.
339
347
query check_mod_attrs( key: DefId ) -> ( ) {
340
- desc { |tcx| "checking attributes in {}" , key . describe_as_module( tcx) }
348
+ desc { |tcx| "checking attributes in {}" , describe_as_module( key , tcx) }
341
349
}
342
350
343
351
query check_mod_unstable_api_usage( key: DefId ) -> ( ) {
344
- desc { |tcx| "checking for unstable API usage in {}" , key . describe_as_module( tcx) }
352
+ desc { |tcx| "checking for unstable API usage in {}" , describe_as_module( key , tcx) }
345
353
}
346
354
347
355
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
348
356
query check_mod_const_bodies( key: DefId ) -> ( ) {
349
- desc { |tcx| "checking consts in {}" , key . describe_as_module( tcx) }
357
+ desc { |tcx| "checking consts in {}" , describe_as_module( key , tcx) }
350
358
}
351
359
352
360
/// Checks the loops in the module.
353
361
query check_mod_loops( key: DefId ) -> ( ) {
354
- desc { |tcx| "checking loops in {}" , key . describe_as_module( tcx) }
362
+ desc { |tcx| "checking loops in {}" , describe_as_module( key , tcx) }
355
363
}
356
364
357
365
query check_mod_item_types( key: DefId ) -> ( ) {
358
- desc { |tcx| "checking item types in {}" , key . describe_as_module( tcx) }
366
+ desc { |tcx| "checking item types in {}" , describe_as_module( key , tcx) }
359
367
}
360
368
361
369
query check_mod_privacy( key: DefId ) -> ( ) {
362
- desc { |tcx| "checking privacy in {}" , key . describe_as_module( tcx) }
370
+ desc { |tcx| "checking privacy in {}" , describe_as_module( key , tcx) }
363
371
}
364
372
365
373
query check_mod_intrinsics( key: DefId ) -> ( ) {
366
- desc { |tcx| "checking intrinsics in {}" , key . describe_as_module( tcx) }
374
+ desc { |tcx| "checking intrinsics in {}" , describe_as_module( key , tcx) }
367
375
}
368
376
369
377
query check_mod_liveness( key: DefId ) -> ( ) {
370
- desc { |tcx| "checking liveness of variables in {}" , key . describe_as_module( tcx) }
378
+ desc { |tcx| "checking liveness of variables in {}" , describe_as_module( key , tcx) }
371
379
}
372
380
373
381
query check_mod_impl_wf( key: DefId ) -> ( ) {
374
- desc { |tcx| "checking that impls are well-formed in {}" , key . describe_as_module( tcx) }
382
+ desc { |tcx| "checking that impls are well-formed in {}" , describe_as_module( key , tcx) }
375
383
}
376
384
377
385
query collect_mod_item_types( key: DefId ) -> ( ) {
378
- desc { |tcx| "collecting item types in {}" , key . describe_as_module( tcx) }
386
+ desc { |tcx| "collecting item types in {}" , describe_as_module( key , tcx) }
379
387
}
380
388
381
389
/// Caches `CoerceUnsized` kinds for impls on custom types.
0 commit comments