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.
This commit is contained in:
Huon Wilson 2014-12-05 11:49:07 -08:00
parent 975a57ce43
commit 4f7e5ed660
3 changed files with 9 additions and 4 deletions

View File

@ -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)]

View File

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

View File

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