Skip to content

Commit 4f7e5ed

Browse files
committed
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.
1 parent 975a57c commit 4f7e5ed

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/librustc/session/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ debugging_opts! {
278278
PARSE_ONLY,
279279
NO_TRANS,
280280
NO_ANALYSIS,
281-
UNSTABLE_OPTIONS
281+
UNSTABLE_OPTIONS,
282+
PRINT_ENUM_SIZES
282283
]
283284
0
284285
}
@@ -331,7 +332,9 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
331332
("no-analysis", "Parse and expand the source, but run no analysis and",
332333
NO_TRANS),
333334
("unstable-options", "Adds unstable command line options to rustc interface",
334-
UNSTABLE_OPTIONS)]
335+
UNSTABLE_OPTIONS),
336+
("print-enum-sizes", "Print the size of enums and their variants", PRINT_ENUM_SIZES),
337+
]
335338
}
336339

337340
#[deriving(Clone)]

src/librustc/session/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ impl Session {
202202
pub fn show_span(&self) -> bool {
203203
self.debugging_opt(config::SHOW_SPAN)
204204
}
205+
pub fn print_enum_sizes(&self) -> bool {
206+
self.debugging_opt(config::PRINT_ENUM_SIZES)
207+
}
205208
pub fn sysroot<'a>(&'a self) -> &'a Path {
206209
match self.opts.maybe_sysroot {
207210
Some (ref sysroot) => sysroot,
@@ -304,4 +307,3 @@ pub fn early_warn(msg: &str) {
304307
let mut emitter = diagnostic::EmitterWriter::stderr(diagnostic::Auto, None);
305308
emitter.emit(None, msg, None, diagnostic::Warning);
306309
}
307-

src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
21252125
fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, id: ast::NodeId) {
21262126
let mut sizes = Vec::new(); // does no allocation if no pushes, thankfully
21272127

2128-
let print_info = log_enabled!(::log::INFO);
2128+
let print_info = ccx.sess().print_enum_sizes();
21292129

21302130
let levels = ccx.tcx().node_lint_levels.borrow();
21312131
let lint_id = lint::LintId::of(lint::builtin::VARIANT_SIZE_DIFFERENCES);

0 commit comments

Comments
 (0)