Skip to content

Commit

Permalink
don't elide shared parts of types in diagnostics when --verbose is …
Browse files Browse the repository at this point in the history
…passed

this also changes some parts of lifetime printing, which previously were not gated behind `-Z verbose`
  • Loading branch information
jyn514 committed Dec 19, 2023
1 parent b5d8361 commit ccbff3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -2957,6 2960,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
working_dir,
color,
logical_env,
verbose,
}
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 223,8 @@ top_level_options!(
/// The (potentially remapped) working directory
working_dir: RealFileName [TRACKED],
color: ColorConfig [UNTRACKED],

verbose: bool [UNTRACKED],
}
);

Expand Down

0 comments on commit ccbff3f

Please sign in to comment.