mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
make -Z mir-include-spans
a dedicated enum
We want to allow setting this on the CLI, override it only in MIR passes, and disable it altogether in mir-opt tests. The default value is "only for NLL MIR dumps", which is considered off for all intents and purposes, except for `rustc_borrowck` when an NLL MIR dump is requested.
This commit is contained in:
parent
c646b46b52
commit
e0bb1c7291
@ -12,9 +12,10 @@ use rustc_session::config::{
|
|||||||
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
|
CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat,
|
||||||
ErrorOutputType, ExternEntry, ExternLocation, Externs, FmtDebug, FunctionReturn,
|
ErrorOutputType, ExternEntry, ExternLocation, Externs, FmtDebug, FunctionReturn,
|
||||||
InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
|
InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
|
||||||
LinkerPluginLto, LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName,
|
LinkerPluginLto, LocationDetail, LtoCli, MirIncludeSpans, NextSolverConfig, OomStrategy,
|
||||||
OutputType, OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry, Polonius,
|
Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes,
|
||||||
ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
|
PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath,
|
||||||
|
SymbolManglingVersion, WasiExecModel,
|
||||||
};
|
};
|
||||||
use rustc_session::lint::Level;
|
use rustc_session::lint::Level;
|
||||||
use rustc_session::search_paths::SearchPath;
|
use rustc_session::search_paths::SearchPath;
|
||||||
@ -705,7 +706,7 @@ fn test_unstable_options_tracking_hash() {
|
|||||||
untracked!(ls, vec!["all".to_owned()]);
|
untracked!(ls, vec!["all".to_owned()]);
|
||||||
untracked!(macro_backtrace, true);
|
untracked!(macro_backtrace, true);
|
||||||
untracked!(meta_stats, true);
|
untracked!(meta_stats, true);
|
||||||
untracked!(mir_include_spans, true);
|
untracked!(mir_include_spans, MirIncludeSpans::On);
|
||||||
untracked!(nll_facts, true);
|
untracked!(nll_facts, true);
|
||||||
untracked!(no_analysis, true);
|
untracked!(no_analysis, true);
|
||||||
untracked!(no_leak_check, true);
|
untracked!(no_leak_check, true);
|
||||||
|
@ -54,7 +54,7 @@ pub struct PrettyPrintMirOptions {
|
|||||||
impl PrettyPrintMirOptions {
|
impl PrettyPrintMirOptions {
|
||||||
/// Create the default set of MIR pretty-printing options from the CLI flags.
|
/// Create the default set of MIR pretty-printing options from the CLI flags.
|
||||||
pub fn from_cli(tcx: TyCtxt<'_>) -> Self {
|
pub fn from_cli(tcx: TyCtxt<'_>) -> Self {
|
||||||
Self { include_extra_comments: tcx.sess.opts.unstable_opts.mir_include_spans }
|
Self { include_extra_comments: tcx.sess.opts.unstable_opts.mir_include_spans.is_enabled() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3369,3 +3369,25 @@ pub enum FunctionReturn {
|
|||||||
/// Replace returns with jumps to thunk, without emitting the thunk.
|
/// Replace returns with jumps to thunk, without emitting the thunk.
|
||||||
ThunkExtern,
|
ThunkExtern,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether extra span comments are included when dumping MIR, via the `-Z mir-include-spans` flag.
|
||||||
|
/// By default, only enabled in the NLL MIR dumps, and disabled in all other passes.
|
||||||
|
#[derive(Clone, Copy, Default, PartialEq, Debug)]
|
||||||
|
pub enum MirIncludeSpans {
|
||||||
|
Off,
|
||||||
|
On,
|
||||||
|
/// Default: include extra comments in NLL MIR dumps only. Can be ignored and considered as
|
||||||
|
/// `Off` in all other cases.
|
||||||
|
#[default]
|
||||||
|
Nll,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MirIncludeSpans {
|
||||||
|
/// Unless opting into extra comments for all passes, they can be considered disabled.
|
||||||
|
/// The cases where a distinction between on/off and a per-pass value can exist will be handled
|
||||||
|
/// in the passes themselves: i.e. the `Nll` value is considered off for all intents and
|
||||||
|
/// purposes, except for the NLL MIR dump pass.
|
||||||
|
pub fn is_enabled(self) -> bool {
|
||||||
|
self == MirIncludeSpans::On
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -445,6 +445,8 @@ mod desc {
|
|||||||
pub const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
|
pub const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
|
||||||
pub const parse_function_return: &str = "`keep` or `thunk-extern`";
|
pub const parse_function_return: &str = "`keep` or `thunk-extern`";
|
||||||
pub const parse_wasm_c_abi: &str = "`legacy` or `spec`";
|
pub const parse_wasm_c_abi: &str = "`legacy` or `spec`";
|
||||||
|
pub const parse_mir_include_spans: &str =
|
||||||
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)";
|
||||||
}
|
}
|
||||||
|
|
||||||
mod parse {
|
mod parse {
|
||||||
@ -1488,6 +1490,17 @@ mod parse {
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn parse_mir_include_spans(slot: &mut MirIncludeSpans, v: Option<&str>) -> bool {
|
||||||
|
*slot = match v {
|
||||||
|
Some("on" | "yes" | "y" | "true") | None => MirIncludeSpans::On,
|
||||||
|
Some("off" | "no" | "n" | "false") => MirIncludeSpans::Off,
|
||||||
|
Some("nll") => MirIncludeSpans::Nll,
|
||||||
|
_ => return false,
|
||||||
|
};
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
options! {
|
options! {
|
||||||
@ -1848,8 +1861,9 @@ options! {
|
|||||||
specified passes to be enabled, overriding all other checks. In particular, this will \
|
specified passes to be enabled, overriding all other checks. In particular, this will \
|
||||||
enable unsound (known-buggy and hence usually disabled) passes without further warning! \
|
enable unsound (known-buggy and hence usually disabled) passes without further warning! \
|
||||||
Passes that are not specified are enabled or disabled by other flags as usual."),
|
Passes that are not specified are enabled or disabled by other flags as usual."),
|
||||||
mir_include_spans: bool = (false, parse_bool, [UNTRACKED],
|
mir_include_spans: MirIncludeSpans = (MirIncludeSpans::default(), parse_mir_include_spans, [UNTRACKED],
|
||||||
"use line numbers relative to the function in mir pretty printing"),
|
"include extra comments in mir pretty printing, like line numbers and statement indices, \
|
||||||
|
details about types, etc. (boolean for all passes, 'nll' to enable in NLL MIR only, default: 'nll')"),
|
||||||
mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],
|
mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],
|
||||||
"keep place mention MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
|
"keep place mention MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
|
||||||
(default: no)"),
|
(default: no)"),
|
||||||
|
Loading…
Reference in New Issue
Block a user