From ccbff3f366c1935241f1089f5431b983c27da990 Mon Sep 17 00:00:00 2001 From: jyn Date: Tue, 19 Dec 2023 13:24:05 -0500 Subject: [PATCH] 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` --- compiler/rustc_infer/src/infer/error_reporting/mod.rs | 8 ++++---- compiler/rustc_session/src/config.rs | 4 ++++ compiler/rustc_session/src/options.rs | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index a799a008a822f..80ddff6e0ba4d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1302,7 +1302,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { if lifetimes.0 != lifetimes.1 { values.0.push_highlighted(l1); values.1.push_highlighted(l2); - } else if lifetimes.0.is_bound() { + } else if lifetimes.0.is_bound() || self.tcx.sess.opts.verbose { values.0.push_normal(l1); values.1.push_normal(l2); } else { @@ -1323,7 +1323,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let num_display_types = consts_offset - regions_len; for (i, (ta1, ta2)) in type_arguments.take(num_display_types).enumerate() { let i = i + regions_len; - if ta1 == ta2 && !self.tcx.sess.verbose_internals() { + if ta1 == ta2 && !self.tcx.sess.opts.verbose { values.0.push_normal("_"); values.1.push_normal("_"); } else { @@ -1337,7 +1337,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { let const_arguments = sub1.consts().zip(sub2.consts()); for (i, (ca1, ca2)) in const_arguments.enumerate() { let i = i + consts_offset; - if ca1 == ca2 && !self.tcx.sess.verbose_internals() { + if ca1 == ca2 && !self.tcx.sess.opts.verbose { values.0.push_normal("_"); values.1.push_normal("_"); } else { @@ -1507,7 +1507,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { (ty::FnPtr(sig1), ty::FnPtr(sig2)) => self.cmp_fn_sig(sig1, sig2), _ => { - if t1 == t2 && !self.tcx.sess.verbose_internals() { + if t1 == t2 && !self.tcx.sess.opts.verbose { // The two types are the same, elide and don't highlight. (DiagnosticStyledString::normal("_"), DiagnosticStyledString::normal("_")) } else { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 0c21e4eb43e78..ddccbc23627a6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1116,6 +1116,7 @@ impl Default for Options { working_dir: RealFileName::LocalPath(std::env::current_dir().unwrap()), color: ColorConfig::Auto, logical_env: FxIndexMap::default(), + verbose: false, } } } @@ -2916,6 +2917,8 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M RealFileName::LocalPath(path.into_owned()) }; + let verbose = matches.opt_present("verbose") || unstable_opts.verbose_internals; + Options { assert_incr_state, crate_types, @@ -2957,6 +2960,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M working_dir, color, logical_env, + verbose, } } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index a0e713a3d9dbb..61996d9b672ab 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -223,6 +223,8 @@ top_level_options!( /// The (potentially remapped) working directory working_dir: RealFileName [TRACKED], color: ColorConfig [UNTRACKED], + + verbose: bool [UNTRACKED], } );