diff options
| author | bors <bors@rust-lang.org> | 2021-09-13 16:31:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-13 16:31:12 +0000 |
| commit | 9bb77da74dac4768489127d21e32db19b59ada5b (patch) | |
| tree | 5bcc7471a627d3d440646060935da4dcfcfd501b /compiler/rustc_resolve/src | |
| parent | b0ee4951f0289aa31e54b101c5706f220315e197 (diff) | |
| parent | 34d19634f5ae448ff3fb281b22306cc8cfa3ee8c (diff) | |
| download | rust-9bb77da74dac4768489127d21e32db19b59ada5b.tar.gz rust-9bb77da74dac4768489127d21e32db19b59ada5b.zip | |
Auto merge of #87915 - estebank:fancy-spans, r=oli-obk
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
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/late/diagnostics.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index a11d7a69c54..19136c6ceeb 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}; @@ -1960,11 +1960,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, ); } @@ -1976,14 +1975,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<Option<String>>| { @@ -2074,11 +2072,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; } @@ -2163,11 +2160,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { .unwrap_or((span, sugg)); 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; @@ -2243,11 +2239,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { if spans_suggs.len() > 0 { // This happens when we have `Foo<T>` 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, ); } } |
