aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r--crates/ide/src/diagnostics.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index dc815a483..906f72a42 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -219,7 +219,7 @@ mod tests {
219 use test_utils::assert_eq_text; 219 use test_utils::assert_eq_text;
220 220
221 use crate::{ 221 use crate::{
222 mock_analysis::{analysis_and_position, single_file, MockAnalysis}, 222 mock_analysis::{analysis_and_position, many_files, single_file},
223 DiagnosticsConfig, 223 DiagnosticsConfig,
224 }; 224 };
225 225
@@ -282,9 +282,7 @@ mod tests {
282 /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics 282 /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics
283 /// apply to the file containing the cursor. 283 /// apply to the file containing the cursor.
284 fn check_no_diagnostics(ra_fixture: &str) { 284 fn check_no_diagnostics(ra_fixture: &str) {
285 let mock = MockAnalysis::with_files(ra_fixture); 285 let (analysis, files) = many_files(ra_fixture);
286 let files = mock.files().map(|(it, _)| it).collect::<Vec<_>>();
287 let analysis = mock.analysis();
288 let diagnostics = files 286 let diagnostics = files
289 .into_iter() 287 .into_iter()
290 .flat_map(|file_id| { 288 .flat_map(|file_id| {
@@ -304,7 +302,7 @@ mod tests {
304 fn test_wrap_return_type() { 302 fn test_wrap_return_type() {
305 check_fix( 303 check_fix(
306 r#" 304 r#"
307//- /main.rs 305//- /main.rs crate:main deps:core
308use core::result::Result::{self, Ok, Err}; 306use core::result::Result::{self, Ok, Err};
309 307
310fn div(x: i32, y: i32) -> Result<i32, ()> { 308fn div(x: i32, y: i32) -> Result<i32, ()> {
@@ -313,7 +311,7 @@ fn div(x: i32, y: i32) -> Result<i32, ()> {
313 } 311 }
314 x / y<|> 312 x / y<|>
315} 313}
316//- /core/lib.rs 314//- /core/lib.rs crate:core
317pub mod result { 315pub mod result {
318 pub enum Result<T, E> { Ok(T), Err(E) } 316 pub enum Result<T, E> { Ok(T), Err(E) }
319} 317}
@@ -335,7 +333,7 @@ fn div(x: i32, y: i32) -> Result<i32, ()> {
335 fn test_wrap_return_type_handles_generic_functions() { 333 fn test_wrap_return_type_handles_generic_functions() {
336 check_fix( 334 check_fix(
337 r#" 335 r#"
338//- /main.rs 336//- /main.rs crate:main deps:core
339use core::result::Result::{self, Ok, Err}; 337use core::result::Result::{self, Ok, Err};
340 338
341fn div<T>(x: T) -> Result<T, i32> { 339fn div<T>(x: T) -> Result<T, i32> {
@@ -344,7 +342,7 @@ fn div<T>(x: T) -> Result<T, i32> {
344 } 342 }
345 <|>x 343 <|>x
346} 344}
347//- /core/lib.rs 345//- /core/lib.rs crate:core
348pub mod result { 346pub mod result {
349 pub enum Result<T, E> { Ok(T), Err(E) } 347 pub enum Result<T, E> { Ok(T), Err(E) }
350} 348}
@@ -366,7 +364,7 @@ fn div<T>(x: T) -> Result<T, i32> {
366 fn test_wrap_return_type_handles_type_aliases() { 364 fn test_wrap_return_type_handles_type_aliases() {
367 check_fix( 365 check_fix(
368 r#" 366 r#"
369//- /main.rs 367//- /main.rs crate:main deps:core
370use core::result::Result::{self, Ok, Err}; 368use core::result::Result::{self, Ok, Err};
371 369
372type MyResult<T> = Result<T, ()>; 370type MyResult<T> = Result<T, ()>;
@@ -377,7 +375,7 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
377 } 375 }
378 x <|>/ y 376 x <|>/ y
379} 377}
380//- /core/lib.rs 378//- /core/lib.rs crate:core
381pub mod result { 379pub mod result {
382 pub enum Result<T, E> { Ok(T), Err(E) } 380 pub enum Result<T, E> { Ok(T), Err(E) }
383} 381}
@@ -401,12 +399,12 @@ fn div(x: i32, y: i32) -> MyResult<i32> {
401 fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() { 399 fn test_wrap_return_type_not_applicable_when_expr_type_does_not_match_ok_type() {
402 check_no_diagnostics( 400 check_no_diagnostics(
403 r#" 401 r#"
404//- /main.rs 402//- /main.rs crate:main deps:core
405use core::result::Result::{self, Ok, Err}; 403use core::result::Result::{self, Ok, Err};
406 404
407fn foo() -> Result<(), i32> { 0 } 405fn foo() -> Result<(), i32> { 0 }
408 406
409//- /core/lib.rs 407//- /core/lib.rs crate:core
410pub mod result { 408pub mod result {
411 pub enum Result<T, E> { Ok(T), Err(E) } 409 pub enum Result<T, E> { Ok(T), Err(E) }
412} 410}
@@ -418,14 +416,14 @@ pub mod result {
418 fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() { 416 fn test_wrap_return_type_not_applicable_when_return_type_is_not_result() {
419 check_no_diagnostics( 417 check_no_diagnostics(
420 r#" 418 r#"
421//- /main.rs 419//- /main.rs crate:main deps:core
422use core::result::Result::{self, Ok, Err}; 420use core::result::Result::{self, Ok, Err};
423 421
424enum SomeOtherEnum { Ok(i32), Err(String) } 422enum SomeOtherEnum { Ok(i32), Err(String) }
425 423
426fn foo() -> SomeOtherEnum { 0 } 424fn foo() -> SomeOtherEnum { 0 }
427 425
428//- /core/lib.rs 426//- /core/lib.rs crate:core
429pub mod result { 427pub mod result {
430 pub enum Result<T, E> { Ok(T), Err(E) } 428 pub enum Result<T, E> { Ok(T), Err(E) }
431} 429}
@@ -567,7 +565,7 @@ fn test_fn() {
567 file_system_edits: [ 565 file_system_edits: [
568 CreateFile { 566 CreateFile {
569 anchor: FileId( 567 anchor: FileId(
570 1, 568 0,
571 ), 569 ),
572 dst: "foo.rs", 570 dst: "foo.rs",
573 }, 571 },