1
Fork 0

feat: implement better error for manual impl of Fn* traits

This commit is contained in:
Ezra Shaw 2023-03-09 20:42:45 +13:00
parent 6a179026de
commit a30c2c26c0
No known key found for this signature in database
GPG key ID: 67ABF16FB0ECD870
10 changed files with 143 additions and 52 deletions

View file

@ -5,7 +5,7 @@ use rustc_errors::{
error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
MultiSpan,
};
use rustc_macros::Diagnostic;
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
use rustc_span::{symbol::Ident, Span, Symbol};
@ -129,6 +129,18 @@ pub struct AssocTypeBindingNotAllowed {
#[primary_span]
#[label]
pub span: Span,
#[subdiagnostic]
pub fn_trait_expansion: Option<ParenthesizedFnTraitExpansion>,
}
#[derive(Subdiagnostic)]
#[help(hir_analysis_parenthesized_fn_trait_expansion)]
pub struct ParenthesizedFnTraitExpansion {
#[primary_span]
pub span: Span,
pub expanded_type: String,
}
#[derive(Diagnostic)]