about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-12-05 11:49:07 -0800
committerHuon Wilson <dbau.pp+github@gmail.com>2014-12-29 23:55:25 +1100
commit4f7e5ed6601186b26a9e9f142cc07e18cd318d59 (patch)
treed6808b79fb88f1b68bab757c9299a8bbee49d002
parent975a57ce431456a2877af455d6316c1531192dcf (diff)
downloadrust-4f7e5ed6601186b26a9e9f142cc07e18cd318d59.tar.gz
rust-4f7e5ed6601186b26a9e9f142cc07e18cd318d59.zip
Add the -Z print-enum-sizes flag for displaying enum info.
This replaces required the RUST_LOG=... invocation to make it much more
user friendly.
-rw-r--r--src/librustc/session/config.rs7
-rw-r--r--src/librustc/session/mod.rs4
-rw-r--r--src/librustc_trans/trans/base.rs2
3 files changed, 9 insertions, 4 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index 6629f6620d4..5f3fbf897dc 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -278,7 +278,8 @@ debugging_opts! {
         PARSE_ONLY,
         NO_TRANS,
         NO_ANALYSIS,
-        UNSTABLE_OPTIONS
+        UNSTABLE_OPTIONS,
+        PRINT_ENUM_SIZES
     ]
     0
 }
@@ -331,7 +332,9 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
      ("no-analysis", "Parse and expand the source, but run no analysis and",
       NO_TRANS),
      ("unstable-options", "Adds unstable command line options to rustc interface",
-      UNSTABLE_OPTIONS)]
+      UNSTABLE_OPTIONS),
+     ("print-enum-sizes", "Print the size of enums and their variants", PRINT_ENUM_SIZES),
+    ]
 }
 
 #[deriving(Clone)]
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 37bdd1673e9..35c325bd764 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -202,6 +202,9 @@ impl Session {
     pub fn show_span(&self) -> bool {
         self.debugging_opt(config::SHOW_SPAN)
     }
+    pub fn print_enum_sizes(&self) -> bool {
+        self.debugging_opt(config::PRINT_ENUM_SIZES)
+    }
     pub fn sysroot<'a>(&'a self) -> &'a Path {
         match self.opts.maybe_sysroot {
             Some (ref sysroot) => sysroot,
@@ -304,4 +307,3 @@ pub fn early_warn(msg: &str) {
     let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
     emitter.emit(None, msg, None, diagnostic::Warning);
 }
-
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index aa6ffc00a3e..dd5809730d6 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -2125,7 +2125,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
 fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, id: ast::NodeId) {
     let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully
 
-    let print_info = log_enabled!(::log::INFO);
+    let print_info = ccx.sess().print_enum_sizes();
 
     let levels = ccx.tcx().node_lint_levels.borrow();
     let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCES);