Prefer DiagnosticBuilder
over Diagnostic
in diagnostic modifiers.
There are lots of functions that modify a diagnostic. This can be via a `&mut Diagnostic` or a `&mut DiagnosticBuilder`, because the latter type wraps the former and impls `DerefMut`. This commit converts all the `&mut Diagnostic` occurrences to `&mut DiagnosticBuilder`. This is a step towards greatly simplifying `Diagnostic`. Some of the relevant function are made generic, because they deal with both errors and warnings. No function bodies are changed, because all the modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`.
This commit is contained in:
parent
8b21296b5d
commit
b18f3e11fa
66 changed files with 536 additions and 454 deletions
|
@ -7,7 +7,7 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{
|
||||
codes::*, pluralize, report_ambiguity_error, struct_span_code_err, Applicability, DiagCtxt,
|
||||
Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, SuggestionStyle,
|
||||
DiagnosticBuilder, ErrorGuaranteed, MultiSpan, SuggestionStyle,
|
||||
};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
|
@ -360,7 +360,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
/// ```
|
||||
fn add_suggestion_for_rename_of_use(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
name: Symbol,
|
||||
import: Import<'_>,
|
||||
binding_span: Span,
|
||||
|
@ -436,7 +436,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
/// as characters expected by span manipulations won't be present.
|
||||
fn add_suggestion_for_duplicate_nested_use(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
import: Import<'_>,
|
||||
binding_span: Span,
|
||||
) {
|
||||
|
@ -1399,7 +1399,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
pub(crate) fn unresolved_macro_suggestions(
|
||||
&mut self,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
macro_kind: MacroKind,
|
||||
parent_scope: &ParentScope<'a>,
|
||||
ident: Ident,
|
||||
|
@ -1515,7 +1515,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
|
||||
pub(crate) fn add_typo_suggestion(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
suggestion: Option<TypoSuggestion>,
|
||||
span: Span,
|
||||
) -> bool {
|
||||
|
@ -2461,7 +2461,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
/// Finds a cfg-ed out item inside `module` with the matching name.
|
||||
pub(crate) fn find_cfg_stripped(
|
||||
&mut self,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
segment: &Symbol,
|
||||
module: DefId,
|
||||
) {
|
||||
|
@ -2670,7 +2670,7 @@ pub(crate) enum DiagnosticMode {
|
|||
|
||||
pub(crate) fn import_candidates(
|
||||
tcx: TyCtxt<'_>,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
// This is `None` if all placement locations are inside expansions
|
||||
use_placement_span: Option<Span>,
|
||||
candidates: &[ImportSuggestion],
|
||||
|
@ -2696,7 +2696,7 @@ pub(crate) fn import_candidates(
|
|||
/// found and suggested, returns `true`, otherwise returns `false`.
|
||||
fn show_candidates(
|
||||
tcx: TyCtxt<'_>,
|
||||
err: &mut Diagnostic,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
// This is `None` if all placement locations are inside expansions
|
||||
use_placement_span: Option<Span>,
|
||||
candidates: &[ImportSuggestion],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue