Skip to content

Commit 88ecb2d

Browse files
committed
make -Z mir-include-spans an optional bool
this allows priority for the CLI even in NLL MIR dumps where we want this to be true by default, compared to the other passes where it's mostly off by default
1 parent 5320a43 commit 88ecb2d

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn test_unstable_options_tracking_hash() {
705705
untracked!(ls, vec!["all".to_owned()]);
706706
untracked!(macro_backtrace, true);
707707
untracked!(meta_stats, true);
708-
untracked!(mir_include_spans, true);
708+
untracked!(mir_include_spans, Some(true));
709709
untracked!(nll_facts, true);
710710
untracked!(no_analysis, true);
711711
untracked!(no_leak_check, true);

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,25 @@ pub enum PassWhere {
4848
#[derive(Copy, Clone)]
4949
pub struct PrettyPrintMirOptions {
5050
/// Whether to include extra comments, like span info. From `-Z mir-include-spans`.
51-
pub include_extra_comments: bool,
51+
include_extra_comments: bool,
5252
}
5353

5454
impl PrettyPrintMirOptions {
5555
/// Create the default set of MIR pretty-printing options from the CLI flags.
5656
pub fn from_cli(tcx: TyCtxt<'_>) -> Self {
57-
Self { include_extra_comments: tcx.sess.opts.unstable_opts.mir_include_spans }
57+
// We include extra comments only if there's an explicit opt-in, we don't show them by
58+
// default.
59+
Self::from_cli_with_default(tcx, false)
60+
}
61+
62+
/// Create MIR pretty-printing options from the CLI flags if specified, using a default value
63+
/// otherwise.
64+
pub fn from_cli_with_default(tcx: TyCtxt<'_>, include_extra_comments_default: bool) -> Self {
65+
// We include extra comments only if there's an explicit opt-in, we don't show them by
66+
// default.
67+
let include_extra_comments =
68+
tcx.sess.opts.unstable_opts.mir_include_spans.unwrap_or(include_extra_comments_default);
69+
Self { include_extra_comments }
5870
}
5971
}
6072

compiler/rustc_session/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,7 @@ options! {
18321832
specified passes to be enabled, overriding all other checks. In particular, this will \
18331833
enable unsound (known-buggy and hence usually disabled) passes without further warning! \
18341834
Passes that are not specified are enabled or disabled by other flags as usual."),
1835-
mir_include_spans: bool = (false, parse_bool, [UNTRACKED],
1835+
mir_include_spans: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
18361836
"use line numbers relative to the function in mir pretty printing"),
18371837
mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],
18381838
"keep place mention MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \

0 commit comments

Comments
 (0)