aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-13 18:13:15 +0100
committerAleksey Kladov <[email protected]>2021-06-13 18:14:12 +0100
commit74f3cca85ab870614f314c6180e2fbb883ad4fe3 (patch)
tree69f0f7aac85ae2fe0a6907a956b94b0bd434ea7e /crates/hir
parent8d391ec981562785ec92ce3afe950972c523f925 (diff)
internal: refactor remove this semicolon diagnostics
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/diagnostics.rs22
-rw-r--r--crates/hir/src/lib.rs5
2 files changed, 3 insertions, 24 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index f839616ce..b144bb335 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -39,6 +39,7 @@ diagnostics![
39 MissingFields, 39 MissingFields,
40 MissingUnsafe, 40 MissingUnsafe,
41 NoSuchField, 41 NoSuchField,
42 RemoveThisSemicolon,
42 UnimplementedBuiltinMacro, 43 UnimplementedBuiltinMacro,
43 UnresolvedExternCrate, 44 UnresolvedExternCrate,
44 UnresolvedImport, 45 UnresolvedImport,
@@ -153,26 +154,7 @@ pub struct MismatchedArgCount {
153 154
154#[derive(Debug)] 155#[derive(Debug)]
155pub struct RemoveThisSemicolon { 156pub struct RemoveThisSemicolon {
156 pub file: HirFileId, 157 pub expr: InFile<AstPtr<ast::Expr>>,
157 pub expr: AstPtr<ast::Expr>,
158}
159
160impl Diagnostic for RemoveThisSemicolon {
161 fn code(&self) -> DiagnosticCode {
162 DiagnosticCode("remove-this-semicolon")
163 }
164
165 fn message(&self) -> String {
166 "Remove this semicolon".to_string()
167 }
168
169 fn display_source(&self) -> InFile<SyntaxNodePtr> {
170 InFile { file_id: self.file, value: self.expr.clone().into() }
171 }
172
173 fn as_any(&self) -> &(dyn Any + Send + 'static) {
174 self
175 }
176} 158}
177 159
178// Diagnostic: missing-ok-or-some-in-tail-expr 160// Diagnostic: missing-ok-or-some-in-tail-expr
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index c1af5f097..cb9bf60b8 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1184,10 +1184,7 @@ impl Function {
1184 } 1184 }
1185 BodyValidationDiagnostic::RemoveThisSemicolon { expr } => { 1185 BodyValidationDiagnostic::RemoveThisSemicolon { expr } => {
1186 match source_map.expr_syntax(expr) { 1186 match source_map.expr_syntax(expr) {
1187 Ok(source_ptr) => sink.push(RemoveThisSemicolon { 1187 Ok(expr) => acc.push(RemoveThisSemicolon { expr }.into()),
1188 file: source_ptr.file_id,
1189 expr: source_ptr.value,
1190 }),
1191 Err(SyntheticSyntax) => (), 1188 Err(SyntheticSyntax) => (),
1192 } 1189 }
1193 } 1190 }