aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/diagnostics.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 8e011a40d..d97bde939 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -63,7 +63,7 @@ pub(crate) fn diagnostics(
63 .into(), 63 .into(),
64 ); 64 );
65 res.borrow_mut().push(Diagnostic { 65 res.borrow_mut().push(Diagnostic {
66 name: Some(d.name()), 66 name: Some(d.name().into()),
67 range: sema.diagnostics_range(d).range, 67 range: sema.diagnostics_range(d).range,
68 message: d.message(), 68 message: d.message(),
69 severity: Severity::Error, 69 severity: Severity::Error,
@@ -98,7 +98,7 @@ pub(crate) fn diagnostics(
98 }; 98 };
99 99
100 res.borrow_mut().push(Diagnostic { 100 res.borrow_mut().push(Diagnostic {
101 name: Some(d.name()), 101 name: Some(d.name().into()),
102 range: sema.diagnostics_range(d).range, 102 range: sema.diagnostics_range(d).range,
103 message: d.message(), 103 message: d.message(),
104 severity: Severity::Error, 104 severity: Severity::Error,
@@ -112,7 +112,7 @@ pub(crate) fn diagnostics(
112 let source_change = SourceFileEdit { file_id, edit }.into(); 112 let source_change = SourceFileEdit { file_id, edit }.into();
113 let fix = Fix::new("Wrap with ok", source_change); 113 let fix = Fix::new("Wrap with ok", source_change);
114 res.borrow_mut().push(Diagnostic { 114 res.borrow_mut().push(Diagnostic {
115 name: Some(d.name()), 115 name: Some(d.name().into()),
116 range: sema.diagnostics_range(d).range, 116 range: sema.diagnostics_range(d).range,
117 message: d.message(), 117 message: d.message(),
118 severity: Severity::Error, 118 severity: Severity::Error,
@@ -121,7 +121,7 @@ pub(crate) fn diagnostics(
121 }) 121 })
122 .on::<hir::diagnostics::NoSuchField, _>(|d| { 122 .on::<hir::diagnostics::NoSuchField, _>(|d| {
123 res.borrow_mut().push(Diagnostic { 123 res.borrow_mut().push(Diagnostic {
124 name: Some(d.name()), 124 name: Some(d.name().into()),
125 range: sema.diagnostics_range(d).range, 125 range: sema.diagnostics_range(d).range,
126 message: d.message(), 126 message: d.message(),
127 severity: Severity::Error, 127 severity: Severity::Error,
@@ -133,8 +133,8 @@ pub(crate) fn diagnostics(
133 133
134 if !analysis_config.disabled_diagnostics.is_empty() { 134 if !analysis_config.disabled_diagnostics.is_empty() {
135 // Do not collect disabled diagnostics. 135 // Do not collect disabled diagnostics.
136 sink_builder = sink_builder 136 sink_builder =
137 .filter(|diag| !analysis_config.disabled_diagnostics.contains(&diag.name())); 137 sink_builder.filter(|diag| !analysis_config.disabled_diagnostics.contains(diag.name()));
138 } 138 }
139 139
140 // Finalize the `DiagnosticSink` building process. 140 // Finalize the `DiagnosticSink` building process.
@@ -142,7 +142,7 @@ pub(crate) fn diagnostics(
142 // Diagnostics not handled above get no fix and default treatment. 142 // Diagnostics not handled above get no fix and default treatment.
143 .build(|d| { 143 .build(|d| {
144 res.borrow_mut().push(Diagnostic { 144 res.borrow_mut().push(Diagnostic {
145 name: Some(d.name()), 145 name: Some(d.name().into()),
146 message: d.message(), 146 message: d.message(),
147 range: sema.diagnostics_range(d).range, 147 range: sema.diagnostics_range(d).range,
148 severity: Severity::Error, 148 severity: Severity::Error,
@@ -313,6 +313,7 @@ fn check_struct_shorthand_initialization(
313 313
314#[cfg(test)] 314#[cfg(test)]
315mod tests { 315mod tests {
316 use std::collections::HashSet;
316 use stdx::trim_indent; 317 use stdx::trim_indent;
317 use test_utils::assert_eq_text; 318 use test_utils::assert_eq_text;
318 319
@@ -385,12 +386,9 @@ mod tests {
385 386
386 /// Takes a multi-file input fixture with annotated cursor position and the list of disabled diagnostics, 387 /// Takes a multi-file input fixture with annotated cursor position and the list of disabled diagnostics,
387 /// and checks that provided diagnostics aren't spawned during analysis. 388 /// and checks that provided diagnostics aren't spawned during analysis.
388 fn check_disabled_diagnostics( 389 fn check_disabled_diagnostics(ra_fixture: &str, disabled_diagnostics: &[&'static str]) {
389 ra_fixture: &str, 390 let disabled_diagnostics: HashSet<_> =
390 disabled_diagnostics: impl IntoIterator<Item = String>, 391 disabled_diagnostics.into_iter().map(|diag| diag.to_string()).collect();
391 ) {
392 let disabled_diagnostics: std::collections::HashSet<_> =
393 disabled_diagnostics.into_iter().collect();
394 392
395 let mock = MockAnalysis::with_files(ra_fixture); 393 let mock = MockAnalysis::with_files(ra_fixture);
396 let files = mock.files().map(|(it, _)| it).collect::<Vec<_>>(); 394 let files = mock.files().map(|(it, _)| it).collect::<Vec<_>>();
@@ -871,6 +869,6 @@ struct Foo {
871 869
872 #[test] 870 #[test]
873 fn test_disabled_diagnostics() { 871 fn test_disabled_diagnostics() {
874 check_disabled_diagnostics(r#"mod foo;"#, vec!["unresolved-module".to_string()]); 872 check_disabled_diagnostics(r#"mod foo;"#, &vec!["unresolved-module"]);
875 } 873 }
876} 874}