Skip to content

Commit ae118bd

Browse files
committed
don't elide shared parts of types in diagnostics when --verbose is passed
this also changes some parts of lifetime printing, which previously were not gated behind `-Z verbose`
1 parent b5d8361 commit ae118bd

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
11891189

11901190
fn fmt_region<'tcx>(region: ty::Region<'tcx>) -> String {
11911191
let mut r = region.to_string();
1192-
if r == "'_" {
1192+
if r == "'_" && !self.tcx.sess.options.verbose {
11931193
r.clear();
11941194
} else {
11951195
r.push(' ');
@@ -1302,7 +1302,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
13021302
if lifetimes.0 != lifetimes.1 {
13031303
values.0.push_highlighted(l1);
13041304
values.1.push_highlighted(l2);
1305-
} else if lifetimes.0.is_bound() {
1305+
} else if lifetimes.0.is_bound() || self.tcx.sess.options.verbose {
13061306
values.0.push_normal(l1);
13071307
values.1.push_normal(l2);
13081308
} else {
@@ -1323,7 +1323,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
13231323
let num_display_types = consts_offset - regions_len;
13241324
for (i, (ta1, ta2)) in type_arguments.take(num_display_types).enumerate() {
13251325
let i = i + regions_len;
1326-
if ta1 == ta2 && !self.tcx.sess.verbose_internals() {
1326+
if ta1 == ta2 && !self.tcx.sess.opts.verbose {
13271327
values.0.push_normal("_");
13281328
values.1.push_normal("_");
13291329
} else {
@@ -1337,7 +1337,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
13371337
let const_arguments = sub1.consts().zip(sub2.consts());
13381338
for (i, (ca1, ca2)) in const_arguments.enumerate() {
13391339
let i = i + consts_offset;
1340-
if ca1 == ca2 && !self.tcx.sess.verbose_internals() {
1340+
if ca1 == ca2 && !self.tcx.sess.opts.verbose {
13411341
values.0.push_normal("_");
13421342
values.1.push_normal("_");
13431343
} else {
@@ -1507,7 +1507,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
15071507
(ty::FnPtr(sig1), ty::FnPtr(sig2)) => self.cmp_fn_sig(sig1, sig2),
15081508

15091509
_ => {
1510-
if t1 == t2 && !self.tcx.sess.verbose_internals() {
1510+
if t1 == t2 && !self.tcx.sess.opts.verbose {
15111511
// The two types are the same, elide and don't highlight.
15121512
(DiagnosticStyledString::normal("_"), DiagnosticStyledString::normal("_"))
15131513
} else {

compiler/rustc_session/src/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ impl Default for Options {
11161116
working_dir: RealFileName::LocalPath(std::env::current_dir().unwrap()),
11171117
color: ColorConfig::Auto,
11181118
logical_env: FxIndexMap::default(),
1119+
verbose: false,
11191120
}
11201121
}
11211122
}
@@ -2916,6 +2917,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
29162917
RealFileName::LocalPath(path.into_owned())
29172918
};
29182919

2920+
let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals;
2921+
29192922
Options {
29202923
assert_incr_state,
29212924
crate_types,
@@ -2957,6 +2960,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
29572960
working_dir,
29582961
color,
29592962
logical_env,
2963+
verbose,
29602964
}
29612965
}
29622966

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ top_level_options!(
223223
/// The (potentially remapped) working directory
224224
working_dir: RealFileName [TRACKED],
225225
color: ColorConfig [UNTRACKED],
226+
227+
verbose: bool [UNTRACKED],
226228
}
227229
);
228230

0 commit comments

Comments
 (0)