diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-13 13:49:37 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-13 13:49:37 +0100 |
commit | cc6d761a99ab3b7e28ed13ca3839358f3341da4d (patch) | |
tree | d9d180d516ddbafc7eb950f401e9a8ab3f1e88fe /crates/ide/src/diagnostics.rs | |
parent | 3f53a5dd724cbc7aa20280cddba44c7d2c0c8a6d (diff) | |
parent | 6383252cc2770545505d40217732f14e93a396c4 (diff) |
Merge #9246
9246: internal: unified missing fields diagnostic r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 075aae8d5..3307e240b 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -5,6 +5,7 @@ | |||
5 | //! original files. So we need to map the ranges. | 5 | //! original files. So we need to map the ranges. |
6 | 6 | ||
7 | mod unresolved_module; | 7 | mod unresolved_module; |
8 | mod missing_fields; | ||
8 | 9 | ||
9 | mod fixes; | 10 | mod fixes; |
10 | mod field_shorthand; | 11 | mod field_shorthand; |
@@ -123,9 +124,6 @@ pub(crate) fn diagnostics( | |||
123 | } | 124 | } |
124 | let res = RefCell::new(res); | 125 | let res = RefCell::new(res); |
125 | let sink_builder = DiagnosticSinkBuilder::new() | 126 | let sink_builder = DiagnosticSinkBuilder::new() |
126 | .on::<hir::diagnostics::MissingFields, _>(|d| { | ||
127 | res.borrow_mut().push(diagnostic_with_fix(d, &sema, resolve)); | ||
128 | }) | ||
129 | .on::<hir::diagnostics::MissingOkOrSomeInTailExpr, _>(|d| { | 127 | .on::<hir::diagnostics::MissingOkOrSomeInTailExpr, _>(|d| { |
130 | res.borrow_mut().push(diagnostic_with_fix(d, &sema, resolve)); | 128 | res.borrow_mut().push(diagnostic_with_fix(d, &sema, resolve)); |
131 | }) | 129 | }) |
@@ -232,7 +230,8 @@ pub(crate) fn diagnostics( | |||
232 | let ctx = DiagnosticsContext { config, sema, resolve }; | 230 | let ctx = DiagnosticsContext { config, sema, resolve }; |
233 | for diag in diags { | 231 | for diag in diags { |
234 | let d = match diag { | 232 | let d = match diag { |
235 | AnyDiagnostic::UnresolvedModule(d) => unresolved_module::render(&ctx, &d), | 233 | AnyDiagnostic::UnresolvedModule(d) => unresolved_module::unresolved_module(&ctx, &d), |
234 | AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), | ||
236 | }; | 235 | }; |
237 | if let Some(code) = d.code { | 236 | if let Some(code) = d.code { |
238 | if ctx.config.disabled.contains(code.as_str()) { | 237 | if ctx.config.disabled.contains(code.as_str()) { |
@@ -1057,20 +1056,6 @@ fn main() { | |||
1057 | } | 1056 | } |
1058 | 1057 | ||
1059 | #[test] | 1058 | #[test] |
1060 | fn missing_record_pat_field_diagnostic() { | ||
1061 | check_diagnostics( | ||
1062 | r#" | ||
1063 | struct S { foo: i32, bar: () } | ||
1064 | fn baz(s: S) { | ||
1065 | let S { foo: _ } = s; | ||
1066 | //^ Missing structure fields: | ||
1067 | //| - bar | ||
1068 | } | ||
1069 | "#, | ||
1070 | ); | ||
1071 | } | ||
1072 | |||
1073 | #[test] | ||
1074 | fn missing_record_pat_field_no_diagnostic_if_not_exhaustive() { | 1059 | fn missing_record_pat_field_no_diagnostic_if_not_exhaustive() { |
1075 | check_diagnostics( | 1060 | check_diagnostics( |
1076 | r" | 1061 | r" |