@@ -26,7 +26,6 @@ use rustc_parse::{
2626} ;
2727use rustc_passes:: { abi_test, input_stats, layout_test} ;
2828use rustc_resolve:: Resolver ;
29- use rustc_session:: code_stats:: VTableSizeInfo ;
3029use rustc_session:: config:: { CrateType , Input , OutFileName , OutputFilenames , OutputType } ;
3130use rustc_session:: cstore:: Untracked ;
3231use rustc_session:: output:: { collect_crate_types, filename_for_input, find_crate_name} ;
@@ -989,90 +988,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) {
989988 // we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
990989 let _ = tcx. all_diagnostic_items ( ( ) ) ;
991990 } ) ;
992-
993- if sess. opts . unstable_opts . print_vtable_sizes {
994- let traits = tcx. traits ( LOCAL_CRATE ) ;
995-
996- for & tr in traits {
997- if !tcx. is_dyn_compatible ( tr) {
998- continue ;
999- }
1000-
1001- let name = ty:: print:: with_no_trimmed_paths!( tcx. def_path_str( tr) ) ;
1002-
1003- let mut first_dsa = true ;
1004-
1005- // Number of vtable entries, if we didn't have upcasting
1006- let mut entries_ignoring_upcasting = 0 ;
1007- // Number of vtable entries needed solely for upcasting
1008- let mut entries_for_upcasting = 0 ;
1009-
1010- let trait_ref = ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, tr) ) ;
1011-
1012- // A slightly edited version of the code in
1013- // `rustc_trait_selection::traits::vtable::vtable_entries`, that works without self
1014- // type and just counts number of entries.
1015- //
1016- // Note that this is technically wrong, for traits which have associated types in
1017- // supertraits:
1018- //
1019- // trait A: AsRef<Self::T> + AsRef<()> { type T; }
1020- //
1021- // Without self type we can't normalize `Self::T`, so we can't know if `AsRef<Self::T>`
1022- // and `AsRef<()>` are the same trait, thus we assume that those are different, and
1023- // potentially over-estimate how many vtable entries there are.
1024- //
1025- // Similarly this is wrong for traits that have methods with possibly-impossible bounds.
1026- // For example:
1027- //
1028- // trait B<T> { fn f(&self) where T: Copy; }
1029- //
1030- // Here `dyn B<u8>` will have 4 entries, while `dyn B<String>` will only have 3.
1031- // However, since we don't know `T`, we can't know if `T: Copy` holds or not,
1032- // thus we lean on the bigger side and say it has 4 entries.
1033- traits:: vtable:: prepare_vtable_segments ( tcx, trait_ref, |segment| {
1034- match segment {
1035- traits:: vtable:: VtblSegment :: MetadataDSA => {
1036- // If this is the first dsa, it would be included either way,
1037- // otherwise it's needed for upcasting
1038- if std:: mem:: take ( & mut first_dsa) {
1039- entries_ignoring_upcasting += 3 ;
1040- } else {
1041- entries_for_upcasting += 3 ;
1042- }
1043- }
1044-
1045- traits:: vtable:: VtblSegment :: TraitOwnEntries { trait_ref, emit_vptr } => {
1046- // Lookup the shape of vtable for the trait.
1047- let own_existential_entries =
1048- tcx. own_existential_vtable_entries ( trait_ref. def_id ( ) ) ;
1049-
1050- // The original code here ignores the method if its predicates are
1051- // impossible. We can't really do that as, for example, all not trivial
1052- // bounds on generic parameters are impossible (since we don't know the
1053- // parameters...), see the comment above.
1054- entries_ignoring_upcasting += own_existential_entries. len ( ) ;
1055-
1056- if emit_vptr {
1057- entries_for_upcasting += 1 ;
1058- }
1059- }
1060- }
1061-
1062- std:: ops:: ControlFlow :: Continue :: < std:: convert:: Infallible > ( ( ) )
1063- } ) ;
1064-
1065- sess. code_stats . record_vtable_size ( tr, & name, VTableSizeInfo {
1066- trait_name : name. clone ( ) ,
1067- entries : entries_ignoring_upcasting + entries_for_upcasting,
1068- entries_ignoring_upcasting,
1069- entries_for_upcasting,
1070- upcasting_cost_percent : entries_for_upcasting as f64
1071- / entries_ignoring_upcasting as f64
1072- * 100. ,
1073- } )
1074- }
1075- }
1076991}
1077992
1078993/// Check for the `#[rustc_error]` annotation, which forces an error in codegen. This is used
@@ -1153,12 +1068,6 @@ pub(crate) fn start_codegen<'tcx>(
11531068 tcx. sess . code_stats . print_type_sizes ( ) ;
11541069 }
11551070
1156- if tcx. sess . opts . unstable_opts . print_vtable_sizes {
1157- let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
1158-
1159- tcx. sess . code_stats . print_vtable_sizes ( crate_name) ;
1160- }
1161-
11621071 codegen
11631072}
11641073
0 commit comments