@@ -48,7 +48,13 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
4848 println ! ( "impl item `{}`" , item. ident. name) ;
4949 match cx. tcx . visibility ( item. def_id ) {
5050 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+ } ,
5258 ty:: Visibility :: Invisible => println ! ( "invisible" ) ,
5359 }
5460 match item. kind {
@@ -359,7 +365,13 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
359365 println ! ( "item `{}`" , item. ident. name) ;
360366 match cx. tcx . visibility ( item. def_id ) {
361367 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+ } ,
363375 ty:: Visibility :: Invisible => println ! ( "invisible" ) ,
364376 }
365377 match item. kind {
0 commit comments