about summary refs log tree commit diff
path: root/src/librustc/session/code_stats.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc/session/code_stats.rs')
-rw-r--r--src/librustc/session/code_stats.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/librustc/session/code_stats.rs b/src/librustc/session/code_stats.rs
index 730abacf6f6..0f535249b5e 100644
--- a/src/librustc/session/code_stats.rs
+++ b/src/librustc/session/code_stats.rs
@@ -57,7 +57,13 @@ impl CodeStats {
                                          overall_size: Size,
                                          packed: bool,
                                          opt_discr_size: Option<Size>,
-                                         variants: Vec<VariantInfo>) {
+                                         mut variants: Vec<VariantInfo>) {
+        // Sort variants so the largest ones are shown first. A stable sort is
+        // used here so that source code order is preserved for all variants
+        // that have the same size.
+        variants.sort_by(|info1, info2| {
+            info2.size.cmp(&info1.size)
+        });
         let info = TypeSizeInfo {
             kind,
             type_description: type_desc.to_string(),