1
Fork 0

Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank

rework `-Zverbose`

implements the changes described in https://github.com/rust-lang/compiler-team/issues/706

the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics.

possible follow up work:
- `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200
- `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`.

r? `@compiler-errors` cc `@estebank`
This commit is contained in:
bors 2023-12-26 12:27:29 +00:00
commit 2fe50cd72c
69 changed files with 160 additions and 98 deletions

View file

@ -627,7 +627,11 @@ where
w,
"{:A$} // {}{}",
indented_body,
if tcx.sess.verbose() { format!("{current_location:?}: ") } else { String::new() },
if tcx.sess.verbose_internals() {
format!("{current_location:?}: ")
} else {
String::new()
},
comment(tcx, statement.source_info),
A = ALIGN,
)?;
@ -652,7 +656,11 @@ where
w,
"{:A$} // {}{}",
indented_terminator,
if tcx.sess.verbose() { format!("{current_location:?}: ") } else { String::new() },
if tcx.sess.verbose_internals() {
format!("{current_location:?}: ")
} else {
String::new()
},
comment(tcx, data.terminator().source_info),
A = ALIGN,
)?;
@ -943,7 +951,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
// When printing regions, add trailing space if necessary.
let print_region = ty::tls::with(|tcx| {
tcx.sess.verbose() || tcx.sess.opts.unstable_opts.identify_regions
tcx.sess.verbose_internals() || tcx.sess.opts.unstable_opts.identify_regions
});
let region = if print_region {
let mut region = region.to_string();
@ -1668,7 +1676,7 @@ fn pretty_print_const_value_tcx<'tcx>(
) -> fmt::Result {
use crate::ty::print::PrettyPrinter;
if tcx.sess.verbose() {
if tcx.sess.verbose_internals() {
fmt.write_str(&format!("ConstValue({ct:?}: {ty})"))?;
return Ok(());
}

View file

@ -177,7 +177,7 @@ impl<'tcx> ObligationCause<'tcx> {
// NOTE(flaper87): As of now, it keeps track of the whole error
// chain. Ideally, we should have a way to configure this either
// by using -Z verbose or just a CLI argument.
// by using -Z verbose-internals or just a CLI argument.
self.code =
variant(DerivedObligationCause { parent_trait_pred, parent_code: self.code }).into();
self

View file

@ -326,7 +326,7 @@ impl<'tcx> Generics {
own_params.start = 1;
}
let verbose = tcx.sess.verbose();
let verbose = tcx.sess.verbose_internals();
// Filter the default arguments.
//
@ -342,7 +342,7 @@ impl<'tcx> Generics {
param.default_value(tcx).is_some_and(|default| {
default.instantiate(tcx, args) == args[param.index as usize]
})
// filter out trailing effect params, if we're not in `-Zverbose`.
// filter out trailing effect params, if we're not in `-Zverbose-internals`.
|| (!verbose && matches!(param.kind, GenericParamDefKind::Const { is_host_effect: true, .. }))
})
.count();

View file

@ -744,7 +744,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
// only affect certain debug messages (e.g. messages printed
// from `rustc_middle::ty` during the computation of `tcx.predicates_of`),
// and should have no effect on any compiler output.
// [Unless `-Zverbose` is used, e.g. in the output of
// [Unless `-Zverbose-internals` is used, e.g. in the output of
// `tests/ui/nll/ty-outlives/impl-trait-captures.rs`, for
// example.]
if self.should_print_verbose() {
@ -829,7 +829,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
ty::CoroutineWitness(did, args) => {
p!(write("{{"));
if !self.tcx().sess.verbose() {
if !self.tcx().sess.verbose_internals() {
p!("coroutine witness");
// FIXME(eddyb) should use `def_span`.
if let Some(did) = did.as_local() {
@ -1698,7 +1698,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
fn should_print_verbose(&self) -> bool {
self.tcx().sess.verbose()
self.tcx().sess.verbose_internals()
}
}