diff options
| author | Veera <sveera.2001@gmail.com> | 2024-07-04 19:19:15 -0400 |
|---|---|---|
| committer | Veera <sveera.2001@gmail.com> | 2024-07-18 17:56:34 -0400 |
| commit | 4cad705017f34a6545deb1505d0ce85537c18df5 (patch) | |
| tree | 183a600bcce3a1af7aeb7cc82bcbe8896c0cd02a /compiler/rustc_parse/src/errors.rs | |
| parent | 5834772177540912b53dc4f19413a4ba3c804ea4 (diff) | |
| download | rust-4cad705017f34a6545deb1505d0ce85537c18df5.tar.gz rust-4cad705017f34a6545deb1505d0ce85537c18df5.zip | |
Parser: Suggest Placing the Return Type After Function Parameters
Diffstat (limited to 'compiler/rustc_parse/src/errors.rs')
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 8d49887f164..05bc0686e8e 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -1435,6 +1435,20 @@ pub(crate) struct FnPtrWithGenerics { } #[derive(Subdiagnostic)] +#[multipart_suggestion( + parse_misplaced_return_type, + style = "verbose", + applicability = "maybe-incorrect" +)] +pub(crate) struct MisplacedReturnType { + #[suggestion_part(code = " {snippet}")] + pub fn_params_end: Span, + pub snippet: String, + #[suggestion_part(code = "")] + pub ret_ty_span: Span, +} + +#[derive(Subdiagnostic)] #[multipart_suggestion(parse_suggestion, applicability = "maybe-incorrect")] pub(crate) struct FnPtrWithGenericsSugg { #[suggestion_part(code = "{snippet}")] @@ -1448,7 +1462,6 @@ pub(crate) struct FnPtrWithGenericsSugg { pub(crate) struct FnTraitMissingParen { pub span: Span, - pub machine_applicable: bool, } impl Subdiagnostic for FnTraitMissingParen { @@ -1458,16 +1471,11 @@ impl Subdiagnostic for FnTraitMissingParen { _: &F, ) { diag.span_label(self.span, crate::fluent_generated::parse_fn_trait_missing_paren); - let applicability = if self.machine_applicable { - Applicability::MachineApplicable - } else { - Applicability::MaybeIncorrect - }; diag.span_suggestion_short( self.span.shrink_to_hi(), crate::fluent_generated::parse_add_paren, "()", - applicability, + Applicability::MachineApplicable, ); } } |
