diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_driver_impl/src/pretty.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_hir_typeck/src/expr.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 42 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/traits/structural_impls.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_interface/src/tests.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/traits/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/generics.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/print/pretty.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_query_impl/src/plumbing.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/legacy.rs | 4 | 
14 files changed, 63 insertions, 42 deletions
| diff --git a/compiler/rustc_driver_impl/src/pretty.rs b/compiler/rustc_driver_impl/src/pretty.rs index 7cd63bc6422..e5a7d550115 100644 --- a/compiler/rustc_driver_impl/src/pretty.rs +++ b/compiler/rustc_driver_impl/src/pretty.rs @@ -146,7 +146,7 @@ impl<'a> pprust_ast::PpAnn for AstHygieneAnn<'a> { } pprust_ast::AnnNode::Crate(_) => { s.s.hardbreak(); - let verbose = self.sess.verbose(); + let verbose = self.sess.verbose_internals(); s.synth_comment(rustc_span::hygiene::debug_hygiene_data(verbose)); s.s.hardbreak_if_not_bol(); } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 267fd00da84..1b47fa81904 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -187,8 +187,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Expectation<'tcx>, args: &'tcx [hir::Expr<'tcx>], ) -> Ty<'tcx> { - if self.tcx().sess.verbose() { - // make this code only run with -Zverbose because it is probably slow + if self.tcx().sess.verbose_internals() { + // make this code only run with -Zverbose-internals because it is probably slow if let Ok(lint_str) = self.tcx.sess.source_map().span_to_snippet(expr.span) { if !lint_str.contains('\n') { debug!("expr text: {lint_str}"); diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 0c0292f329e..b5a6374ec4b 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1212,6 +1212,23 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { s.push_highlighted(mutbl.prefix_str()); } + fn maybe_highlight<T: Eq + ToString>( + t1: T, + t2: T, + (buf1, buf2): &mut (DiagnosticStyledString, DiagnosticStyledString), + tcx: TyCtxt<'_>, + ) { + let highlight = t1 != t2; + let (t1, t2) = if highlight || tcx.sess.opts.verbose { + (t1.to_string(), t2.to_string()) + } else { + // The two types are the same, elide and don't highlight. + ("_".into(), "_".into()) + }; + buf1.push(t1, highlight); + buf2.push(t2, highlight); + } + fn cmp_ty_refs<'tcx>( r1: ty::Region<'tcx>, mut1: hir::Mutability, @@ -1308,7 +1325,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 { @@ -1329,7 +1346,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() { + if ta1 == ta2 && !self.tcx.sess.opts.verbose { values.0.push_normal("_"); values.1.push_normal("_"); } else { @@ -1343,13 +1360,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() { - values.0.push_normal("_"); - values.1.push_normal("_"); - } else { - values.0.push_highlighted(ca1.to_string()); - values.1.push_highlighted(ca2.to_string()); - } + maybe_highlight(ca1, ca2, &mut values, self.tcx); self.push_comma(&mut values.0, &mut values.1, len, i); } @@ -1513,16 +1524,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { (ty::FnPtr(sig1), ty::FnPtr(sig2)) => self.cmp_fn_sig(sig1, sig2), _ => { - if t1 == t2 && !self.tcx.sess.verbose() { - // The two types are the same, elide and don't highlight. - (DiagnosticStyledString::normal("_"), DiagnosticStyledString::normal("_")) - } else { - // We couldn't find anything in common, highlight everything. - ( - DiagnosticStyledString::highlighted(t1.to_string()), - DiagnosticStyledString::highlighted(t2.to_string()), - ) - } + let mut strs = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); + maybe_highlight(t1, t2, &mut strs, self.tcx); + strs } } } diff --git a/compiler/rustc_infer/src/traits/structural_impls.rs b/compiler/rustc_infer/src/traits/structural_impls.rs index 8a7c59da09e..51c06c8970b 100644 --- a/compiler/rustc_infer/src/traits/structural_impls.rs +++ b/compiler/rustc_infer/src/traits/structural_impls.rs @@ -17,7 +17,7 @@ impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> { impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if ty::tls::with(|tcx| tcx.sess.verbose()) { + if ty::tls::with(|tcx| tcx.sess.verbose_internals()) { write!( f, "Obligation(predicate={:?}, cause={:?}, param_env={:?}, depth={})", diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 04a7714d413..c4a1f3a0e51 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -714,7 +714,7 @@ fn test_unstable_options_tracking_hash() { untracked!(unpretty, Some("expanded".to_string())); untracked!(unstable_options, true); untracked!(validate_mir, true); - untracked!(verbose, true); + untracked!(verbose_internals, true); untracked!(write_long_types_to_disk, false); // tidy-alphabetical-end diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 071c6a75583..b995f622388 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -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(()); } diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 5d0187a8598..4376d891c41 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index c3699b114c4..4821ae3f087 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -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(); diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 13a5e881134..f7900d883ad 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -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() } } diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs index 0971f2d75da..f131a0f7593 100644 --- a/compiler/rustc_query_impl/src/plumbing.rs +++ b/compiler/rustc_query_impl/src/plumbing.rs @@ -315,8 +315,11 @@ pub(crate) fn create_query_frame< ty::print::with_forced_impl_filename_line!(do_describe(tcx, key)) ) ); - let description = - if tcx.sess.verbose() { format!("{description} [{name:?}]") } else { description }; + let description = if tcx.sess.verbose_internals() { + format!("{description} [{name:?}]") + } else { + description + }; let span = if kind == dep_graph::dep_kinds::def_span || with_no_queries() { // The `def_span` query is used to calculate `default_span`, // so exit to avoid infinite recursion. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index d158163f4a4..e1640d7fca9 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 10a4bdb94d4..8274fd05bc0 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], } ); @@ -1991,8 +1993,8 @@ written to standard error output)"), "use legacy .ctors section for initializers rather than .init_array"), validate_mir: bool = (false, parse_bool, [UNTRACKED], "validate MIR after each transformation"), - #[rustc_lint_opt_deny_field_access("use `Session::verbose` instead of this field")] - verbose: bool = (false, parse_bool, [UNTRACKED], + #[rustc_lint_opt_deny_field_access("use `Session::verbose_internals` instead of this field")] + verbose_internals: bool = (false, parse_bool, [UNTRACKED], "in general, enable more debug printouts (default: no)"), #[rustc_lint_opt_deny_field_access("use `Session::verify_llvm_ir` instead of this field")] verify_llvm_ir: bool = (false, parse_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 53dd48ea272..9ee7625e5bf 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -665,8 +665,8 @@ impl Session { // JUSTIFICATION: defn of the suggested wrapper fns #[allow(rustc::bad_opt_access)] impl Session { - pub fn verbose(&self) -> bool { - self.opts.unstable_opts.verbose + pub fn verbose_internals(&self) -> bool { + self.opts.unstable_opts.verbose_internals } pub fn print_llvm_stats(&self) -> bool { diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 0178ff53b24..a273a412146 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -214,7 +214,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> { | ty::Coroutine(def_id, args, _) => self.print_def_path(def_id, args), // The `pretty_print_type` formatting of array size depends on - // -Zverbose flag, so we cannot reuse it here. + // -Zverbose-internals flag, so we cannot reuse it here. ty::Array(ty, size) => { self.write_str("[")?; self.print_type(ty)?; @@ -255,7 +255,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> { // only print integers match (ct.kind(), ct.ty().kind()) { (ty::ConstKind::Value(ty::ValTree::Leaf(scalar)), ty::Int(_) | ty::Uint(_)) => { - // The `pretty_print_const` formatting depends on -Zverbose + // The `pretty_print_const` formatting depends on -Zverbose-internals // flag, so we cannot reuse it here. let signed = matches!(ct.ty().kind(), ty::Int(_)); write!( | 
