Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e74a0cd

Browse files
authoredJan 5, 2024
Rollup merge of #119566 - Zalathar:remove-spanview, r=Swatinem,Nilstrieb
Remove `-Zdump-mir-spanview` The `-Zdump-mir-spanview` flag was added back in #76074, as a development/debugging aid for the initial work on what would eventually become `-Cinstrument-coverage`. It causes the compiler to emit an HTML file containing a function's source code, with various spans highlighted based on the contents of MIR. When the suggestion was made to [triage and remove unnecessary `-Z` flags (Zulip)](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60-Z.60.20option.20triage), I noted that this flag could potentially be worth removing, but I wanted to keep it around to see whether I found it useful for my own coverage work. But when I actually tried to use it, I ran into various issues (e.g. it crashes on `tests/coverage/closure.rs`). If I can't trust it to work properly without a full overhaul, then instead of diving down a rabbit hole of trying to fix arcane span-handling bugs, it seems better to just remove this obscure old code entirely. --- ````@rustbot```` label +A-code-coverage
2 parents f361b59 + af32054 commit e74a0cd

File tree

12 files changed

+2
-919
lines changed

12 files changed

+2
-919
lines changed
 

‎compiler/rustc_interface/src/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use rustc_session::config::{
66
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
77
DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, Externs,
88
FunctionReturn, InliningThreshold, Input, InstrumentCoverage, InstrumentXRay,
9-
LinkSelfContained, LinkerPluginLto, LocationDetail, LtoCli, MirSpanview, NextSolverConfig,
10-
OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes, Polonius,
9+
LinkSelfContained, LinkerPluginLto, LocationDetail, LtoCli, NextSolverConfig, OomStrategy,
10+
Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes, Polonius,
1111
ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
1212
};
1313
use rustc_session::lint::Level;
@@ -666,7 +666,6 @@ fn test_unstable_options_tracking_hash() {
666666
untracked!(dump_mir_dir, String::from("abc"));
667667
untracked!(dump_mir_exclude_pass_number, true);
668668
untracked!(dump_mir_graphviz, true);
669-
untracked!(dump_mir_spanview, Some(MirSpanview::Statement));
670669
untracked!(dump_mono_stats, SwitchWithOptPath::Enabled(Some("mono-items-dir/".into())));
671670
untracked!(dump_mono_stats_format, DumpMonoStatsFormat::Json);
672671
untracked!(dylib_lto, true);

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub mod mono;
5555
pub mod patch;
5656
pub mod pretty;
5757
mod query;
58-
pub mod spanview;
5958
mod statement;
6059
mod syntax;
6160
pub mod tcx;

‎compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::io::{self, Write as _};
55
use std::path::{Path, PathBuf};
66

77
use super::graphviz::write_mir_fn_graphviz;
8-
use super::spanview::write_mir_fn_spanview;
98
use rustc_ast::InlineAsmTemplatePiece;
109
use rustc_middle::mir::interpret::{
1110
alloc_range, read_target_uint, AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer,
@@ -141,16 +140,6 @@ fn dump_matched_mir_node<'tcx, F>(
141140
write_mir_fn_graphviz(tcx, body, false, &mut file)?;
142141
};
143142
}
144-
145-
if let Some(spanview) = tcx.sess.opts.unstable_opts.dump_mir_spanview {
146-
let _: io::Result<()> = try {
147-
let file_basename = dump_file_basename(tcx, pass_num, pass_name, disambiguator, body);
148-
let mut file = create_dump_file_with_basename(tcx, &file_basename, "html")?;
149-
if body.source.def_id().is_local() {
150-
write_mir_fn_spanview(tcx, body, spanview, &file_basename, &mut file)?;
151-
}
152-
};
153-
}
154143
}
155144

156145
/// Returns the file basename portion (without extension) of a filename path

‎compiler/rustc_middle/src/mir/spanview.rs

Lines changed: 0 additions & 642 deletions
This file was deleted.

‎compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,6 @@ pub enum LtoCli {
125125
Unspecified,
126126
}
127127

128-
/// The different settings that the `-Z dump_mir_spanview` flag can have. `Statement` generates a
129-
/// document highlighting each span of every statement (including terminators). `Terminator` and
130-
/// `Block` highlight a single span per `BasicBlock`: the span of the block's `Terminator`, or a
131-
/// computed span for the block, representing the entire range, covering the block's terminator and
132-
/// all of its statements.
133-
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
134-
pub enum MirSpanview {
135-
/// Default `-Z dump_mir_spanview` or `-Z dump_mir_spanview=statement`
136-
Statement,
137-
/// `-Z dump_mir_spanview=terminator`
138-
Terminator,
139-
/// `-Z dump_mir_spanview=block`
140-
Block,
141-
}
142-
143128
/// The different settings that the `-C instrument-coverage` flag can have.
144129
///
145130
/// Coverage instrumentation now supports combining `-C instrument-coverage`

‎compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ mod desc {
391391
pub const parse_strip: &str = "either `none`, `debuginfo`, or `symbols`";
392392
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
393393
pub const parse_optimization_fuel: &str = "crate=integer";
394-
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
395394
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
396395
pub const parse_instrument_coverage: &str =
397396
"`all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off`";
@@ -866,29 +865,6 @@ mod parse {
866865
}
867866
}
868867

869-
pub(crate) fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>) -> bool {
870-
if v.is_some() {
871-
let mut bool_arg = None;
872-
if parse_opt_bool(&mut bool_arg, v) {
873-
*slot = bool_arg.unwrap().then_some(MirSpanview::Statement);
874-
return true;
875-
}
876-
}
877-
878-
let Some(v) = v else {
879-
*slot = Some(MirSpanview::Statement);
880-
return true;
881-
};
882-
883-
*slot = Some(match v.trim_end_matches('s') {
884-
"statement" | "stmt" => MirSpanview::Statement,
885-
"terminator" | "term" => MirSpanview::Terminator,
886-
"block" | "basicblock" => MirSpanview::Block,
887-
_ => return false,
888-
});
889-
true
890-
}
891-
892868
pub(crate) fn parse_time_passes_format(slot: &mut TimePassesFormat, v: Option<&str>) -> bool {
893869
match v {
894870
None => true,
@@ -1601,11 +1577,6 @@ options! {
16011577
"exclude the pass number when dumping MIR (used in tests) (default: no)"),
16021578
dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED],
16031579
"in addition to `.mir` files, create graphviz `.dot` files (default: no)"),
1604-
dump_mir_spanview: Option<MirSpanview> = (None, parse_mir_spanview, [UNTRACKED],
1605-
"in addition to `.mir` files, create `.html` files to view spans for \
1606-
all `statement`s (including terminators), only `terminator` spans, or \
1607-
computed `block` spans (one span encompassing a block's terminator and \
1608-
all statements)."),
16091580
dump_mono_stats: SwitchWithOptPath = (SwitchWithOptPath::Disabled,
16101581
parse_switch_with_opt_path, [UNTRACKED],
16111582
"output statistics about monomorphization collection"),

‎tests/mir-opt/spanview_block.main.built.after.html

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎tests/mir-opt/spanview_block.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎tests/mir-opt/spanview_statement.main.built.after.html

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎tests/mir-opt/spanview_statement.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎tests/mir-opt/spanview_terminator.main.built.after.html

Lines changed: 0 additions & 66 deletions
This file was deleted.

‎tests/mir-opt/spanview_terminator.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.