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);