diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index 57454719c2e..9841fbdf329 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs @@ -285,34 +285,29 @@ fn div(x: i32, y: i32) -> Result { fn test_wrap_return_type_handles_generic_functions() { let before = r#" //- /main.rs - use std::{default::Default, result::Result::{self, Ok, Err}}; + use std::result::Result::{self, Ok, Err}; - fn div(x: i32) -> Result { + fn div(x: T) -> Result { if x == 0 { return Err(7); } - T::default() + x } //- /std/lib.rs pub mod result { pub enum Result { Ok(T), Err(E) } } - pub mod default { - pub trait Default { - fn default() -> Self; - } - } "#; // The formatting here is a bit odd due to how the parse_fixture function works in test_utils - // it strips empty lines and leading whitespace. The important part of this test is that the final -// `x / y` expr is now wrapped in `Ok(..)` - let after = r#"use std::{default::Default, result::Result::{self, Ok, Err}}; -fn div(x: i32) -> Result { +// expr is now wrapped in `Ok(..)` + let after = r#"use std::result::Result::{self, Ok, Err}; +fn div(x: T) -> Result { if x == 0 { return Err(7); } - Ok(T::default()) + Ok(x) } "#; check_apply_diagnostic_fix_for_target_file("/main.rs", before, after);