@@ -48,7 +48,13 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
48
48
println ! ( "impl item `{}`" , item. ident. name) ;
49
49
match cx. tcx . visibility ( item. def_id ) {
50
50
ty:: Visibility :: Public => println ! ( "public" ) ,
51
- ty:: Visibility :: Restricted ( def_id) => println ! ( "visible in module `{}`" , cx. tcx. def_path_str( def_id) ) ,
51
+ ty:: Visibility :: Restricted ( def_id) => {
52
+ if def_id. is_top_level_module ( ) {
53
+ println ! ( "visible crate wide" )
54
+ } else {
55
+ println ! ( "visible in module `{}`" , cx. tcx. def_path_str( def_id) )
56
+ }
57
+ } ,
52
58
ty:: Visibility :: Invisible => println ! ( "invisible" ) ,
53
59
}
54
60
match item. kind {
@@ -359,7 +365,13 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
359
365
println ! ( "item `{}`" , item. ident. name) ;
360
366
match cx. tcx . visibility ( item. def_id ) {
361
367
ty:: Visibility :: Public => println ! ( "public" ) ,
362
- ty:: Visibility :: Restricted ( def_id) => println ! ( "visible in module `{}`" , cx. tcx. def_path_str( def_id) ) ,
368
+ ty:: Visibility :: Restricted ( def_id) => {
369
+ if def_id. is_top_level_module ( ) {
370
+ println ! ( "visible crate wide" )
371
+ } else {
372
+ println ! ( "visible in module `{}`" , cx. tcx. def_path_str( def_id) )
373
+ }
374
+ } ,
363
375
ty:: Visibility :: Invisible => println ! ( "invisible" ) ,
364
376
}
365
377
match item. kind {
0 commit comments