diff options
| author | yukang <moorekang@gmail.com> | 2022-09-29 13:16:47 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2022-10-04 17:30:52 +0800 |
| commit | 5dd44d4d4c4545f65f15f890e93fac68214cfe54 (patch) | |
| tree | 2c79664ff64bc841dd9c0e61fecd6b6789df22f2 /compiler/rustc_hir_analysis/src/errors.rs | |
| parent | d9f8b4b98503e3f88623eb59d4f20432161b840a (diff) | |
| download | rust-5dd44d4d4c4545f65f15f890e93fac68214cfe54.tar.gz rust-5dd44d4d4c4545f65f15f890e93fac68214cfe54.zip | |
fix #102396, suggest parentheses for possible range methods
Diffstat (limited to 'compiler/rustc_hir_analysis/src/errors.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index d891171b824..6634444c636 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -346,3 +346,28 @@ pub struct ExpectedUsedSymbol { #[primary_span] pub span: Span, } + +#[derive(Diagnostic)] +#[diag(hir_analysis::missing_parentheses_in_range, code = "E0599")] +pub struct MissingParentheseInRange { + #[primary_span] + #[label(hir_analysis::missing_parentheses_in_range)] + pub span: Span, + pub ty_str: String, + + #[subdiagnostic] + pub add_missing_parentheses: Option<AddMissingParenthesesInRange>, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion_verbose( + hir_analysis::add_missing_parentheses_in_range, + applicability = "maybe-incorrect" +)] +pub struct AddMissingParenthesesInRange { + pub func_name: String, + #[suggestion_part(code = "(")] + pub left: Span, + #[suggestion_part(code = ")")] + pub right: Span, +} |
