Use &mut Diagnostic instead of &mut DiagnosticBuilder unless needed
This commit is contained in:
parent
34a6cae28e
commit
a2b6744af0
15 changed files with 37 additions and 59 deletions
|
@ -13,9 +13,7 @@ use rustc_ast::walk_list;
|
||||||
use rustc_ast::*;
|
use rustc_ast::*;
|
||||||
use rustc_ast_pretty::pprust::{self, State};
|
use rustc_ast_pretty::pprust::{self, State};
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{
|
use rustc_errors::{error_code, pluralize, struct_span_err, Applicability, Diagnostic};
|
||||||
error_code, pluralize, struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed,
|
|
||||||
};
|
|
||||||
use rustc_parse::validate_attr;
|
use rustc_parse::validate_attr;
|
||||||
use rustc_session::lint::builtin::{
|
use rustc_session::lint::builtin::{
|
||||||
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, PATTERNS_IN_FNS_WITHOUT_BODY,
|
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, PATTERNS_IN_FNS_WITHOUT_BODY,
|
||||||
|
@ -477,7 +475,7 @@ impl<'a> AstValidator<'a> {
|
||||||
ctx: &str,
|
ctx: &str,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
sugg: &str,
|
sugg: &str,
|
||||||
help: impl FnOnce(&mut DiagnosticBuilder<'_, ErrorGuaranteed>),
|
help: impl FnOnce(&mut Diagnostic),
|
||||||
) {
|
) {
|
||||||
let source_map = self.session.source_map();
|
let source_map = self.session.source_map();
|
||||||
let end = source_map.end_point(sp);
|
let end = source_map.end_point(sp);
|
||||||
|
@ -1196,7 +1194,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
let msg = "free function without a body";
|
let msg = "free function without a body";
|
||||||
let ext = sig.header.ext;
|
let ext = sig.header.ext;
|
||||||
|
|
||||||
let f = |e: &mut DiagnosticBuilder<'_, _>| {
|
let f = |e: &mut Diagnostic| {
|
||||||
if let Extern::Implicit(start_span) | Extern::Explicit(_, start_span) = &ext
|
if let Extern::Implicit(start_span) | Extern::Explicit(_, start_span) = &ext
|
||||||
{
|
{
|
||||||
let start_suggestion = if let Extern::Explicit(abi, _) = ext {
|
let start_suggestion = if let Extern::Explicit(abi, _) = ext {
|
||||||
|
|
|
@ -451,7 +451,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
|
|
||||||
fn suggest_borrow_fn_like(
|
fn suggest_borrow_fn_like(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
move_sites: &[MoveSite],
|
move_sites: &[MoveSite],
|
||||||
value_name: &str,
|
value_name: &str,
|
||||||
|
@ -526,12 +526,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suggest_adding_copy_bounds(
|
fn suggest_adding_copy_bounds(&self, err: &mut Diagnostic, ty: Ty<'tcx>, span: Span) {
|
||||||
&self,
|
|
||||||
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
|
||||||
ty: Ty<'tcx>,
|
|
||||||
span: Span,
|
|
||||||
) {
|
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
let generics = tcx.generics_of(self.mir_def_id());
|
let generics = tcx.generics_of(self.mir_def_id());
|
||||||
|
|
||||||
|
|
|
@ -783,7 +783,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
fn maybe_suggest_constrain_dyn_trait_impl(
|
fn maybe_suggest_constrain_dyn_trait_impl(
|
||||||
&self,
|
&self,
|
||||||
diag: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
diag: &mut Diagnostic,
|
||||||
f: Region<'tcx>,
|
f: Region<'tcx>,
|
||||||
o: Region<'tcx>,
|
o: Region<'tcx>,
|
||||||
category: &ConstraintCategory<'tcx>,
|
category: &ConstraintCategory<'tcx>,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_ast::{NodeId, DUMMY_NODE_ID};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_attr::{self as attr, TransparencyError};
|
use rustc_attr::{self as attr, TransparencyError};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder};
|
||||||
use rustc_feature::Features;
|
use rustc_feature::Features;
|
||||||
use rustc_lint_defs::builtin::{
|
use rustc_lint_defs::builtin::{
|
||||||
RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
|
RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
|
||||||
|
@ -608,11 +608,7 @@ enum ExplainDocComment {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
fn annotate_doc_comment(
|
fn annotate_doc_comment(err: &mut Diagnostic, sm: &SourceMap, span: Span) {
|
||||||
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
|
||||||
sm: &SourceMap,
|
|
||||||
span: Span,
|
|
||||||
) {
|
|
||||||
if let Ok(src) = sm.span_to_snippet(span) {
|
if let Ok(src) = sm.span_to_snippet(span) {
|
||||||
if src.starts_with("///") || src.starts_with("/**") {
|
if src.starts_with("///") || src.starts_with("/**") {
|
||||||
err.subdiagnostic(ExplainDocComment::Outer { span });
|
err.subdiagnostic(ExplainDocComment::Outer { span });
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult,
|
fluent, Applicability, DiagnosticBuilder, DiagnosticMessage, Handler, MultiSpan, PResult,
|
||||||
};
|
};
|
||||||
use rustc_errors::{pluralize, struct_span_err, Diagnostic, EmissionGuarantee, ErrorGuaranteed};
|
use rustc_errors::{pluralize, struct_span_err, Diagnostic, ErrorGuaranteed};
|
||||||
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
|
use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::{kw, Ident};
|
use rustc_span::symbol::{kw, Ident};
|
||||||
|
@ -228,13 +228,13 @@ struct MultiSugg {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultiSugg {
|
impl MultiSugg {
|
||||||
fn emit<G: EmissionGuarantee>(self, err: &mut DiagnosticBuilder<'_, G>) {
|
fn emit(self, err: &mut Diagnostic) {
|
||||||
err.multipart_suggestion(&self.msg, self.patches, self.applicability);
|
err.multipart_suggestion(&self.msg, self.patches, self.applicability);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Overrides individual messages and applicabilities.
|
/// Overrides individual messages and applicabilities.
|
||||||
fn emit_many<G: EmissionGuarantee>(
|
fn emit_many(
|
||||||
err: &mut DiagnosticBuilder<'_, G>,
|
err: &mut Diagnostic,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
applicability: Applicability,
|
applicability: Applicability,
|
||||||
suggestions: impl Iterator<Item = Self>,
|
suggestions: impl Iterator<Item = Self>,
|
||||||
|
|
|
@ -859,7 +859,7 @@ impl<'a> Parser<'a> {
|
||||||
);
|
);
|
||||||
let mut err = self.struct_span_err(span, &msg);
|
let mut err = self.struct_span_err(span, &msg);
|
||||||
|
|
||||||
let suggest_parens = |err: &mut DiagnosticBuilder<'_, _>| {
|
let suggest_parens = |err: &mut Diagnostic| {
|
||||||
let suggestions = vec![
|
let suggestions = vec![
|
||||||
(span.shrink_to_lo(), "(".to_string()),
|
(span.shrink_to_lo(), "(".to_string()),
|
||||||
(span.shrink_to_hi(), ")".to_string()),
|
(span.shrink_to_hi(), ")".to_string()),
|
||||||
|
|
|
@ -2021,9 +2021,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
|
|
||||||
fn suggest_introducing_lifetime(
|
fn suggest_introducing_lifetime(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
name: Option<&str>,
|
name: Option<&str>,
|
||||||
suggest: impl Fn(&mut DiagnosticBuilder<'_, ErrorGuaranteed>, bool, Span, &str, String) -> bool,
|
suggest: impl Fn(&mut Diagnostic, bool, Span, &str, String) -> bool,
|
||||||
) {
|
) {
|
||||||
let mut suggest_note = true;
|
let mut suggest_note = true;
|
||||||
for rib in self.lifetime_ribs.iter().rev() {
|
for rib in self.lifetime_ribs.iter().rev() {
|
||||||
|
@ -2149,7 +2149,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
||||||
|
|
||||||
pub(crate) fn add_missing_lifetime_specifiers_label(
|
pub(crate) fn add_missing_lifetime_specifiers_label(
|
||||||
&mut self,
|
&mut self,
|
||||||
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
lifetime_refs: Vec<MissingLifetime>,
|
lifetime_refs: Vec<MissingLifetime>,
|
||||||
function_param_lifetimes: Option<(Vec<MissingLifetime>, Vec<ElisionFnParameter>)>,
|
function_param_lifetimes: Option<(Vec<MissingLifetime>, Vec<ElisionFnParameter>)>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -16,7 +16,8 @@ use crate::require_c_abi_if_c_variadic;
|
||||||
use rustc_ast::TraitObjectSyntax;
|
use rustc_ast::TraitObjectSyntax;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, MultiSpan,
|
struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, FatalError,
|
||||||
|
MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
|
||||||
|
@ -2106,7 +2107,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
pub fn prohibit_generics<'a>(
|
pub fn prohibit_generics<'a>(
|
||||||
&self,
|
&self,
|
||||||
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
|
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
|
||||||
extend: impl Fn(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>),
|
extend: impl Fn(&mut Diagnostic),
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let args = segments.clone().flat_map(|segment| segment.args().args);
|
let args = segments.clone().flat_map(|segment| segment.args().args);
|
||||||
|
|
||||||
|
@ -2984,11 +2985,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make sure that we are in the condition to suggest the blanket implementation.
|
/// Make sure that we are in the condition to suggest the blanket implementation.
|
||||||
fn maybe_lint_blanket_trait_impl<T: rustc_errors::EmissionGuarantee>(
|
fn maybe_lint_blanket_trait_impl(&self, self_ty: &hir::Ty<'_>, diag: &mut Diagnostic) {
|
||||||
&self,
|
|
||||||
self_ty: &hir::Ty<'_>,
|
|
||||||
diag: &mut DiagnosticBuilder<'_, T>,
|
|
||||||
) {
|
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let parent_id = tcx.hir().get_parent_item(self_ty.hir_id);
|
let parent_id = tcx.hir().get_parent_item(self_ty.hir_id);
|
||||||
if let hir::Node::Item(hir::Item {
|
if let hir::Node::Item(hir::Item {
|
||||||
|
@ -3081,7 +3078,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
sugg,
|
sugg,
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
self.maybe_lint_blanket_trait_impl::<()>(&self_ty, &mut diag);
|
self.maybe_lint_blanket_trait_impl(&self_ty, &mut diag);
|
||||||
diag.emit();
|
diag.emit();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -1525,9 +1525,7 @@ fn detect_discriminant_duplicate<'tcx>(
|
||||||
) {
|
) {
|
||||||
// Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate.
|
// Helper closure to reduce duplicate code. This gets called everytime we detect a duplicate.
|
||||||
// Here `idx` refers to the order of which the discriminant appears, and its index in `vs`
|
// Here `idx` refers to the order of which the discriminant appears, and its index in `vs`
|
||||||
let report = |dis: Discr<'tcx>,
|
let report = |dis: Discr<'tcx>, idx: usize, err: &mut Diagnostic| {
|
||||||
idx: usize,
|
|
||||||
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>| {
|
|
||||||
let var = &vs[idx]; // HIR for the duplicate discriminant
|
let var = &vs[idx]; // HIR for the duplicate discriminant
|
||||||
let (span, display_discr) = match var.disr_expr {
|
let (span, display_discr) = match var.disr_expr {
|
||||||
Some(ref expr) => {
|
Some(ref expr) => {
|
||||||
|
|
|
@ -1581,9 +1581,9 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn note_unreachable_loop_return<'a>(
|
fn note_unreachable_loop_return(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'a, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
expr: &hir::Expr<'tcx>,
|
expr: &hir::Expr<'tcx>,
|
||||||
ret_exprs: &Vec<&'tcx hir::Expr<'tcx>>,
|
ret_exprs: &Vec<&'tcx hir::Expr<'tcx>>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
|
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
|
||||||
EmissionGuarantee, ErrorGuaranteed,
|
ErrorGuaranteed,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||||
|
@ -879,7 +879,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
lhs: &'tcx hir::Expr<'tcx>,
|
lhs: &'tcx hir::Expr<'tcx>,
|
||||||
err_code: &'static str,
|
err_code: &'static str,
|
||||||
op_span: Span,
|
op_span: Span,
|
||||||
adjust_err: impl FnOnce(&mut DiagnosticBuilder<'tcx, ErrorGuaranteed>),
|
adjust_err: impl FnOnce(&mut Diagnostic),
|
||||||
) {
|
) {
|
||||||
if lhs.is_syntactic_place_expr() {
|
if lhs.is_syntactic_place_expr() {
|
||||||
return;
|
return;
|
||||||
|
@ -1089,8 +1089,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace);
|
let lhs_ty = self.check_expr_with_needs(&lhs, Needs::MutPlace);
|
||||||
|
|
||||||
let suggest_deref_binop = |err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
let suggest_deref_binop = |err: &mut Diagnostic, rhs_ty: Ty<'tcx>| {
|
||||||
rhs_ty: Ty<'tcx>| {
|
|
||||||
if let Some(lhs_deref_ty) = self.deref_once_mutably_for_diagnostic(lhs_ty) {
|
if let Some(lhs_deref_ty) = self.deref_once_mutably_for_diagnostic(lhs_ty) {
|
||||||
// Can only assign if the type is sized, so if `DerefMut` yields a type that is
|
// Can only assign if the type is sized, so if `DerefMut` yields a type that is
|
||||||
// unsized, do not suggest dereferencing it.
|
// unsized, do not suggest dereferencing it.
|
||||||
|
@ -2205,9 +2204,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.tcx().ty_error()
|
self.tcx().ty_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_call_constructor<G: EmissionGuarantee>(
|
fn check_call_constructor(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'_, G>,
|
err: &mut Diagnostic,
|
||||||
base: &'tcx hir::Expr<'tcx>,
|
base: &'tcx hir::Expr<'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1778,7 +1778,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
fn label_fn_like(
|
fn label_fn_like(
|
||||||
&self,
|
&self,
|
||||||
err: &mut rustc_errors::DiagnosticBuilder<'tcx, rustc_errors::ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
callable_def_id: Option<DefId>,
|
callable_def_id: Option<DefId>,
|
||||||
callee_ty: Option<Ty<'tcx>>,
|
callee_ty: Option<Ty<'tcx>>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -904,7 +904,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let label_span_not_found = |err: &mut DiagnosticBuilder<'_, _>| {
|
let label_span_not_found = |err: &mut Diagnostic| {
|
||||||
if unsatisfied_predicates.is_empty() {
|
if unsatisfied_predicates.is_empty() {
|
||||||
err.span_label(span, format!("{item_kind} not found in `{ty_str}`"));
|
err.span_label(span, format!("{item_kind} not found in `{ty_str}`"));
|
||||||
let is_string_or_ref_str = match actual.kind() {
|
let is_string_or_ref_str = match actual.kind() {
|
||||||
|
@ -1150,7 +1150,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
rcvr_ty: Ty<'tcx>,
|
rcvr_ty: Ty<'tcx>,
|
||||||
expr: &hir::Expr<'_>,
|
expr: &hir::Expr<'_>,
|
||||||
item_name: Ident,
|
item_name: Ident,
|
||||||
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let field_receiver = self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() {
|
let field_receiver = self.autoderef(span, rcvr_ty).find_map(|(ty, _)| match ty.kind() {
|
||||||
|
@ -1327,7 +1327,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
fn check_for_field_method(
|
fn check_for_field_method(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
source: SelfSource<'tcx>,
|
source: SelfSource<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
actual: Ty<'tcx>,
|
actual: Ty<'tcx>,
|
||||||
|
@ -1375,7 +1375,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
fn check_for_unwrap_self(
|
fn check_for_unwrap_self(
|
||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'tcx, ErrorGuaranteed>,
|
err: &mut Diagnostic,
|
||||||
source: SelfSource<'tcx>,
|
source: SelfSource<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
actual: Ty<'tcx>,
|
actual: Ty<'tcx>,
|
||||||
|
|
|
@ -104,7 +104,7 @@ use crate::astconv::AstConv;
|
||||||
use crate::check::gather_locals::GatherLocalsVisitor;
|
use crate::check::gather_locals::GatherLocalsVisitor;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
pluralize, struct_span_err, Applicability, DiagnosticBuilder, EmissionGuarantee, MultiSpan,
|
pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
|
@ -973,12 +973,7 @@ fn has_expected_num_generic_args<'tcx>(
|
||||||
/// * `span` - The span of the snippet
|
/// * `span` - The span of the snippet
|
||||||
/// * `params` - The number of parameters the constructor accepts
|
/// * `params` - The number of parameters the constructor accepts
|
||||||
/// * `err` - A mutable diagnostic builder to add the suggestion to
|
/// * `err` - A mutable diagnostic builder to add the suggestion to
|
||||||
fn suggest_call_constructor<G: EmissionGuarantee>(
|
fn suggest_call_constructor(span: Span, kind: CtorOf, params: usize, err: &mut Diagnostic) {
|
||||||
span: Span,
|
|
||||||
kind: CtorOf,
|
|
||||||
params: usize,
|
|
||||||
err: &mut DiagnosticBuilder<'_, G>,
|
|
||||||
) {
|
|
||||||
// Note: tuple-structs don't have named fields, so just use placeholders
|
// Note: tuple-structs don't have named fields, so just use placeholders
|
||||||
let args = vec!["_"; params].join(", ");
|
let args = vec!["_"; params].join(", ");
|
||||||
let applicable = if params > 0 {
|
let applicable = if params > 0 {
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
{
|
{
|
||||||
// Suppress this error, since we already emitted
|
// Suppress this error, since we already emitted
|
||||||
// a deref suggestion in check_overloaded_binop
|
// a deref suggestion in check_overloaded_binop
|
||||||
err.delay_as_bug();
|
err.downgrade_to_delayed_bug();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue