diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2023-08-06 14:00:12 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2023-08-07 05:26:38 +0000 |
| commit | 1ca4bc966ec5215a8daacf584d337f75322c0e9a (patch) | |
| tree | f9122adacc64ab956d816eecf8d6399dc2f420a4 /compiler/rustc_trait_selection/src/errors.rs | |
| parent | bc720ad36b74c428b210c71c66e4490cec12b023 (diff) | |
| download | rust-1ca4bc966ec5215a8daacf584d337f75322c0e9a.tar.gz rust-1ca4bc966ec5215a8daacf584d337f75322c0e9a.zip | |
Migrate a trait selection error to use diagnostic translation
Diffstat (limited to 'compiler/rustc_trait_selection/src/errors.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/errors.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index dde9e9c9ac6..c1fb287d63e 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -4,7 +4,7 @@ use rustc_errors::{ SubdiagnosticMessage, }; use rustc_macros::Diagnostic; -use rustc_middle::ty::{self, PolyTraitRef, Ty}; +use rustc_middle::ty::{self, ClosureKind, PolyTraitRef, Ty}; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] @@ -131,3 +131,37 @@ impl AddToDiagnostic for AdjustSignatureBorrow { } } } + +#[derive(Diagnostic)] +#[diag(trait_selection_closure_kind_mismatch, code = "E0525")] +pub struct ClosureKindMismatch { + #[primary_span] + #[label] + pub closure_span: Span, + pub expected: ClosureKind, + pub found: ClosureKind, + #[label(trait_selection_closure_kind_requirement)] + pub cause_span: Span, + + #[subdiagnostic] + pub fn_once_label: Option<ClosureFnOnceLabel>, + + #[subdiagnostic] + pub fn_mut_label: Option<ClosureFnMutLabel>, +} + +#[derive(Subdiagnostic)] +#[label(trait_selection_closure_fn_once_label)] +pub struct ClosureFnOnceLabel { + #[primary_span] + pub span: Span, + pub place: String, +} + +#[derive(Subdiagnostic)] +#[label(trait_selection_closure_fn_mut_label)] +pub struct ClosureFnMutLabel { + #[primary_span] + pub span: Span, + pub place: String, +} |
