diff options
| author | bors <bors@rust-lang.org> | 2024-08-31 16:43:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-31 16:43:26 +0000 |
| commit | d571ae851d93541bef826c3c48c1e9ad99da77d6 (patch) | |
| tree | 3786c5de1594f23563dbc6e1755aacdd5b351140 /compiler/rustc_session/src | |
| parent | 9649706eada1b2c68cf6504356efb058f68ad739 (diff) | |
| parent | 830b1deaeec6bff881c4a969ee1e5ddb1c156a0a (diff) | |
| download | rust-d571ae851d93541bef826c3c48c1e9ad99da77d6.tar.gz rust-d571ae851d93541bef826c3c48c1e9ad99da77d6.zip | |
Auto merge of #129817 - matthiaskrgr:rollup-ll2ld5m, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - #129659 (const fn stability checking: also check declared language features) - #129711 (Expand NLL MIR dumps) - #129730 (f32 docs: define 'arithmetic' operations) - #129733 (Subtree update of `rust-analyzer`) - #129749 (llvm-wrapper: adapt for LLVM API changes) - #129757 (Add a test for trait solver overflow in MIR inliner cycle detection) - #129760 (Make the "detect-old-time" UI test more representative) - #129767 (Remove `#[macro_use] extern crate tracing`, round 4) - #129774 (Remove `#[macro_use] extern crate tracing` from rustdoc and rustfmt) - #129785 (Miri subtree update) - #129791 (mark joboet as on vacation) - #129812 (interpret, codegen: tweak some comments and checks regarding Box with custom allocator) Failed merges: - #129777 (Add `unreachable_pub`, round 4) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 18 |
2 files changed, 38 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index fbdb3cb1534..945bab6887e 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -3369,3 +3369,25 @@ pub enum FunctionReturn { /// Replace returns with jumps to thunk, without emitting the thunk. 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 + } +} diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 4492ad09357..37077901e0c 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -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_function_return: &str = "`keep` or `thunk-extern`"; 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 { @@ -1488,6 +1490,17 @@ mod parse { } 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! { @@ -1848,8 +1861,9 @@ options! { 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! \ Passes that are not specified are enabled or disabled by other flags as usual."), - mir_include_spans: bool = (false, parse_bool, [UNTRACKED], - "use line numbers relative to the function in mir pretty printing"), + mir_include_spans: MirIncludeSpans = (MirIncludeSpans::default(), parse_mir_include_spans, [UNTRACKED], + "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], "keep place mention MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \ (default: no)"), |
