Replace &mut DiagnosticBuilder
, in signatures, with &mut Diagnostic
.
This commit is contained in:
parent
f24ff1815f
commit
02ff9e0aef
65 changed files with 369 additions and 466 deletions
|
@ -3,7 +3,7 @@ use std::ptr;
|
|||
use rustc_ast::{self as ast, Path};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind};
|
||||
|
@ -1031,7 +1031,7 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
crate fn unresolved_macro_suggestions(
|
||||
&mut self,
|
||||
err: &mut DiagnosticBuilder<'a>,
|
||||
err: &mut Diagnostic,
|
||||
macro_kind: MacroKind,
|
||||
parent_scope: &ParentScope<'a>,
|
||||
ident: Ident,
|
||||
|
@ -1120,7 +1120,7 @@ impl<'a> Resolver<'a> {
|
|||
|
||||
crate fn add_typo_suggestion(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
suggestion: Option<TypoSuggestion>,
|
||||
span: Span,
|
||||
) -> bool {
|
||||
|
@ -1817,7 +1817,7 @@ fn find_span_immediately_after_crate_name(
|
|||
crate fn show_candidates(
|
||||
definitions: &rustc_hir::definitions::Definitions,
|
||||
session: &Session,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
// This is `None` if all placement locations are inside expansions
|
||||
use_placement_span: Option<Span>,
|
||||
candidates: &[ImportSuggestion],
|
||||
|
|
|
@ -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};
|
||||
use rustc_errors::{pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
|
||||
|
@ -606,11 +606,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
(err, candidates)
|
||||
}
|
||||
|
||||
fn detect_assoct_type_constraint_meant_as_path(
|
||||
&self,
|
||||
base_span: Span,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) {
|
||||
fn detect_assoct_type_constraint_meant_as_path(&self, base_span: Span, err: &mut Diagnostic) {
|
||||
let Some(ty) = self.diagnostic_metadata.current_type_path else { return; };
|
||||
let TyKind::Path(_, path) = &ty.kind else { return; };
|
||||
for segment in &path.segments {
|
||||
|
@ -675,11 +671,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
}
|
||||
|
||||
/// Given `where <T as Bar>::Baz: String`, suggest `where T: Bar<Baz = String>`.
|
||||
fn restrict_assoc_type_in_where_clause(
|
||||
&mut self,
|
||||
span: Span,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
) -> bool {
|
||||
fn restrict_assoc_type_in_where_clause(&mut self, span: Span, err: &mut Diagnostic) -> bool {
|
||||
// Detect that we are actually in a `where` predicate.
|
||||
let (bounded_ty, bounds, where_span) =
|
||||
if let Some(ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate {
|
||||
|
@ -875,7 +867,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
/// Returns `true` if able to provide context-dependent help.
|
||||
fn smart_resolve_context_dependent_help(
|
||||
&mut self,
|
||||
err: &mut DiagnosticBuilder<'a>,
|
||||
err: &mut Diagnostic,
|
||||
span: Span,
|
||||
source: PathSource<'_>,
|
||||
res: Res,
|
||||
|
@ -885,7 +877,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
let ns = source.namespace();
|
||||
let is_expected = &|res| source.is_expected(res);
|
||||
|
||||
let path_sep = |err: &mut DiagnosticBuilder<'_>, expr: &Expr| match expr.kind {
|
||||
let path_sep = |err: &mut Diagnostic, expr: &Expr| match expr.kind {
|
||||
ExprKind::Field(_, ident) => {
|
||||
err.span_suggestion(
|
||||
expr.span,
|
||||
|
@ -908,7 +900,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
_ => false,
|
||||
};
|
||||
|
||||
let find_span = |source: &PathSource<'_>, err: &mut DiagnosticBuilder<'_>| {
|
||||
let find_span = |source: &PathSource<'_>, err: &mut Diagnostic| {
|
||||
match source {
|
||||
PathSource::Expr(Some(Expr { span, kind: ExprKind::Call(_, _), .. }))
|
||||
| PathSource::TupleStruct(span, _) => {
|
||||
|
@ -1435,7 +1427,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
start.to(sm.next_point(start))
|
||||
}
|
||||
|
||||
fn type_ascription_suggestion(&self, err: &mut DiagnosticBuilder<'_>, base_span: Span) -> bool {
|
||||
fn type_ascription_suggestion(&self, err: &mut Diagnostic, base_span: Span) -> bool {
|
||||
let sm = self.r.session.source_map();
|
||||
let base_snippet = sm.span_to_snippet(base_span);
|
||||
if let Some(&sp) = self.diagnostic_metadata.current_type_ascription.last() {
|
||||
|
@ -1577,7 +1569,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||
/// Adds a suggestion for using an enum's variant when an enum is used instead.
|
||||
fn suggest_using_enum_variant(
|
||||
&mut self,
|
||||
err: &mut DiagnosticBuilder<'a>,
|
||||
err: &mut Diagnostic,
|
||||
source: PathSource<'_>,
|
||||
def_id: DefId,
|
||||
span: Span,
|
||||
|
@ -1910,7 +1902,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
/// Returns whether to add `'static` lifetime to the suggested lifetime list.
|
||||
crate fn report_elision_failure(
|
||||
&mut self,
|
||||
db: &mut DiagnosticBuilder<'_>,
|
||||
// FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
|
||||
db: &mut Diagnostic,
|
||||
params: &[ElisionFailureInfo],
|
||||
) -> bool {
|
||||
let mut m = String::new();
|
||||
|
@ -2059,7 +2052,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
|
||||
crate fn add_missing_lifetime_specifiers_label(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
mut spans_with_counts: Vec<(Span, usize)>,
|
||||
lifetime_names: &FxHashSet<Symbol>,
|
||||
lifetime_spans: Vec<Span>,
|
||||
|
@ -2090,7 +2083,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let suggest_existing =
|
||||
|err: &mut DiagnosticBuilder<'_>,
|
||||
|err: &mut Diagnostic,
|
||||
name: &str,
|
||||
formatters: Vec<Option<Box<dyn Fn(&str) -> String>>>| {
|
||||
if let Some(MissingLifetimeSpot::HigherRanked { span: for_span, span_type }) =
|
||||
|
@ -2174,7 +2167,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
|||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
};
|
||||
let suggest_new = |err: &mut DiagnosticBuilder<'_>, suggs: Vec<Option<String>>| {
|
||||
let suggest_new = |err: &mut Diagnostic, suggs: Vec<Option<String>>| {
|
||||
for missing in self.missing_named_lifetime_spots.iter().rev() {
|
||||
let mut introduce_suggestion = vec![];
|
||||
let msg;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use crate::late::diagnostics::{ForLifetimeSpanType, MissingLifetimeSpot};
|
||||
use rustc_ast::walk_list;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefIdMap, LocalDefId};
|
||||
|
@ -1873,7 +1873,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
|
|||
// or from `fn rah<'a>(T<'a>)` to `fn rah(T<'_>)`
|
||||
fn suggest_eliding_single_use_lifetime(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
def_id: DefId,
|
||||
lifetime: &hir::Lifetime,
|
||||
) {
|
||||
|
|
|
@ -40,7 +40,7 @@ use rustc_ast_pretty::pprust;
|
|||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_errors::{struct_span_err, Applicability, Diagnostic, DiagnosticBuilder};
|
||||
use rustc_expand::base::{DeriveResolutions, SyntaxExtension, SyntaxExtensionKind};
|
||||
use rustc_hir::def::Namespace::*;
|
||||
use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes};
|
||||
|
@ -3169,7 +3169,7 @@ impl<'a> Resolver<'a> {
|
|||
/// ```
|
||||
fn add_suggestion_for_rename_of_use(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
name: Symbol,
|
||||
import: &Import<'_>,
|
||||
binding_span: Span,
|
||||
|
@ -3248,7 +3248,7 @@ impl<'a> Resolver<'a> {
|
|||
/// as characters expected by span manipulations won't be present.
|
||||
fn add_suggestion_for_duplicate_nested_use(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
err: &mut Diagnostic,
|
||||
import: &Import<'_>,
|
||||
binding_span: Span,
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue