@@ -732,12 +732,13 @@ impl MetadataBlob {
732
732
) -> io:: Result < ( ) > {
733
733
let root = self . get_root ( ) ;
734
734
735
- let all_ls_kinds = vec ! [ "root" . to_owned( ) , "lang_items" . to_owned( ) , "features" . to_owned( ) ] ;
736
- let ls_kinds = if ls_kinds. contains ( & "all" . to_owned ( ) ) {
737
- & all_ls_kinds
738
- } else {
739
- ls_kinds
740
- } ;
735
+ let all_ls_kinds = vec ! [
736
+ "root" . to_owned( ) ,
737
+ "lang_items" . to_owned( ) ,
738
+ "features" . to_owned( ) ,
739
+ "items" . to_owned( ) ,
740
+ ] ;
741
+ let ls_kinds = if ls_kinds. contains ( & "all" . to_owned ( ) ) { & all_ls_kinds } else { ls_kinds } ;
741
742
742
743
for kind in ls_kinds {
743
744
match & * * kind {
@@ -778,7 +779,7 @@ impl MetadataBlob {
778
779
root. profiler_runtime
779
780
) ?;
780
781
781
- writeln ! ( out, "\n =External Dependencies=" ) ?;
782
+ writeln ! ( out, "=External Dependencies=" ) ?;
782
783
let dylib_dependency_formats =
783
784
root. dylib_dependency_formats . decode ( self ) . collect :: < Vec < _ > > ( ) ;
784
785
for ( i, dep) in root. crate_deps . decode ( self ) . enumerate ( ) {
@@ -801,7 +802,7 @@ impl MetadataBlob {
801
802
}
802
803
803
804
"lang_items" => {
804
- writeln ! ( out, "\n =Lang items=" ) ?;
805
+ writeln ! ( out, "=Lang items=" ) ?;
805
806
for ( id, lang_item) in root. lang_items . decode ( self ) {
806
807
writeln ! (
807
808
out,
@@ -823,7 +824,7 @@ impl MetadataBlob {
823
824
}
824
825
825
826
"features" => {
826
- writeln ! ( out, "\n =Lib features=" ) ?;
827
+ writeln ! ( out, "=Lib features=" ) ?;
827
828
for ( feature, since) in root. lib_features . decode ( self ) {
828
829
writeln ! (
829
830
out,
@@ -839,8 +840,77 @@ impl MetadataBlob {
839
840
write ! ( out, "\n " ) ?;
840
841
}
841
842
843
+ "items" => {
844
+ writeln ! ( out, "=Items=" ) ?;
845
+
846
+ fn print_item (
847
+ blob : & MetadataBlob ,
848
+ out : & mut dyn io:: Write ,
849
+ item : DefIndex ,
850
+ indent : usize ,
851
+ ) -> io:: Result < ( ) > {
852
+ let root = blob. get_root ( ) ;
853
+
854
+ let def_kind = root. tables . opt_def_kind . get ( blob, item) . unwrap ( ) ;
855
+ let def_key = root. tables . def_keys . get ( blob, item) . unwrap ( ) . decode ( blob) ;
856
+ let def_name = if item == CRATE_DEF_INDEX {
857
+ rustc_span:: symbol:: kw:: Crate
858
+ } else {
859
+ def_key
860
+ . disambiguated_data
861
+ . data
862
+ . get_opt_name ( )
863
+ . unwrap_or_else ( || Symbol :: intern ( "???" ) )
864
+ } ;
865
+ let visibility =
866
+ root. tables . visibility . get ( blob, item) . unwrap ( ) . decode ( blob) . map_id (
867
+ |index| {
868
+ format ! (
869
+ "crate{}" ,
870
+ DefPath :: make( LOCAL_CRATE , index, |parent| root
871
+ . tables
872
+ . def_keys
873
+ . get( blob, parent)
874
+ . unwrap( )
875
+ . decode( blob) )
876
+ . to_string_no_crate_verbose( )
877
+ )
878
+ } ,
879
+ ) ;
880
+ write ! (
881
+ out,
882
+ "{nil: <indent$}{:?} {:?} {} {{" ,
883
+ visibility,
884
+ def_kind,
885
+ def_name,
886
+ nil = "" ,
887
+ ) ?;
888
+
889
+ if let Some ( children) =
890
+ root. tables . module_children_non_reexports . get ( blob, item)
891
+ {
892
+ write ! ( out, "\n " ) ?;
893
+ for child in children. decode ( blob) {
894
+ print_item ( blob, out, child, indent + 4 ) ?;
895
+ }
896
+ writeln ! ( out, "{nil: <indent$}}}" , nil = "" ) ?;
897
+ } else {
898
+ writeln ! ( out, "}}" ) ?;
899
+ }
900
+
901
+ Ok ( ( ) )
902
+ }
903
+
904
+ print_item ( self , out, CRATE_DEF_INDEX , 0 ) ?;
905
+
906
+ write ! ( out, "\n " ) ?;
907
+ }
908
+
842
909
_ => {
843
- writeln ! ( out, "unknown -Zls kind. allowed values are: no, all, root, lang_items, features" ) ?;
910
+ writeln ! (
911
+ out,
912
+ "unknown -Zls kind. allowed values are: no, all, root, lang_items, features, items"
913
+ ) ?;
844
914
}
845
915
}
846
916
}
0 commit comments