diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-10 16:18:49 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-10 16:18:49 +0000 |
commit | 44978acf51e25513ef8420e228221273f42abf8c (patch) | |
tree | cc798690135a0adc9ee43bdb6d2b99686ce9e6f1 /crates/hir_ty/src/diagnostics.rs | |
parent | 5a6065e3b05e2624c4c340f928b20c04ce579928 (diff) | |
parent | bbb0bc7b041278480edbfaa7c3cdadc5a704fc03 (diff) |
Merge #6769
6769: Add native "remove this semicolon" diagnostics r=matklad a=ivan770
Closes #6739
![demo2](https://user-images.githubusercontent.com/14003886/101530533-b76c3180-399a-11eb-9d18-5c8457721655.gif)
Co-authored-by: ivan770 <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/diagnostics.rs')
-rw-r--r-- | crates/hir_ty/src/diagnostics.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs index b58fe0ed7..e59487e54 100644 --- a/crates/hir_ty/src/diagnostics.rs +++ b/crates/hir_ty/src/diagnostics.rs | |||
@@ -216,6 +216,30 @@ impl Diagnostic for MissingOkInTailExpr { | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | #[derive(Debug)] | ||
220 | pub struct RemoveThisSemicolon { | ||
221 | pub file: HirFileId, | ||
222 | pub expr: AstPtr<ast::Expr>, | ||
223 | } | ||
224 | |||
225 | impl Diagnostic for RemoveThisSemicolon { | ||
226 | fn code(&self) -> DiagnosticCode { | ||
227 | DiagnosticCode("remove-this-semicolon") | ||
228 | } | ||
229 | |||
230 | fn message(&self) -> String { | ||
231 | "Remove this semicolon".to_string() | ||
232 | } | ||
233 | |||
234 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
235 | InFile { file_id: self.file, value: self.expr.clone().into() } | ||
236 | } | ||
237 | |||
238 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
239 | self | ||
240 | } | ||
241 | } | ||
242 | |||
219 | // Diagnostic: break-outside-of-loop | 243 | // Diagnostic: break-outside-of-loop |
220 | // | 244 | // |
221 | // This diagnostic is triggered if `break` keyword is used outside of a loop. | 245 | // This diagnostic is triggered if `break` keyword is used outside of a loop. |