From 34d19634f5ae448ff3fb281b22306cc8cfa3ee8c Mon Sep 17 00:00:00 2001 From: Esteban Kuber Date: Tue, 10 Aug 2021 10:53:43 +0000 Subject: Use smaller spans for some structured suggestions Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212 --- compiler/rustc_resolve/src/late/diagnostics.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'compiler/rustc_resolve/src') diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 7c97a17b454..e88c1fd831e 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -12,7 +12,7 @@ use rustc_ast::{ }; use rustc_ast_pretty::pprust::path_segment_to_string; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, SuggestionStyle}; +use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder}; use rustc_hir as hir; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind}; @@ -1950,11 +1950,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { introduce_suggestion.push((*span, formatter(<_name))); } } - err.multipart_suggestion_with_style( + err.multipart_suggestion_verbose( &msg, introduce_suggestion, Applicability::MaybeIncorrect, - SuggestionStyle::ShowAlways, ); } @@ -1966,14 +1965,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { }) .map(|(formatter, span)| (*span, formatter(name))) .collect(); - err.multipart_suggestion_with_style( + err.multipart_suggestion_verbose( &format!( "consider using the `{}` lifetime", lifetime_names.iter().next().unwrap() ), spans_suggs, Applicability::MaybeIncorrect, - SuggestionStyle::ShowAlways, ); }; let suggest_new = |err: &mut DiagnosticBuilder<'_>, suggs: Vec>| { @@ -2064,11 +2062,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { }; spans_suggs.push((span, sugg.to_string())); } - err.multipart_suggestion_with_style( + err.multipart_suggestion_verbose( "consider using the `'static` lifetime", spans_suggs, Applicability::MaybeIncorrect, - SuggestionStyle::ShowAlways, ); continue; } @@ -2088,11 +2085,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { introduce_suggestion.push((span, sugg.to_string())); } } - err.multipart_suggestion_with_style( + err.multipart_suggestion_verbose( &msg, introduce_suggestion, Applicability::MaybeIncorrect, - SuggestionStyle::ShowAlways, ); if should_break { break; @@ -2167,11 +2163,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { if spans_suggs.len() > 0 { // This happens when we have `Foo` where we point at the space before `T`, // but this can be confusing so we give a suggestion with placeholders. - err.multipart_suggestion_with_style( + err.multipart_suggestion_verbose( "consider using one of the available lifetimes here", spans_suggs, Applicability::HasPlaceholders, - SuggestionStyle::ShowAlways, ); } } -- cgit 1.4.1-3-g733a5