@@ -16,6 +16,14 @@ use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
1616use rustc_span:: symbol:: Symbol ;
1717use std:: borrow:: Cow ;
1818
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+
1927// Each of these queries corresponds to a function pointer field in the
2028// `Providers` struct for requesting a value of that type, and a method
2129// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
@@ -332,50 +340,50 @@ rustc_queries! {
332340
333341 Other {
334342 query lint_mod( key: DefId ) -> ( ) {
335- desc { |tcx| "linting {}" , key . describe_as_module( tcx) }
343+ desc { |tcx| "linting {}" , describe_as_module( key , tcx) }
336344 }
337345
338346 /// Checks the attributes in the module.
339347 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) }
341349 }
342350
343351 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) }
345353 }
346354
347355 /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
348356 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) }
350358 }
351359
352360 /// Checks the loops in the module.
353361 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) }
355363 }
356364
357365 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) }
359367 }
360368
361369 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) }
363371 }
364372
365373 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) }
367375 }
368376
369377 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) }
371379 }
372380
373381 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) }
375383 }
376384
377385 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) }
379387 }
380388
381389 /// Caches `CoerceUnsized` kinds for impls on custom types.
0 commit comments