aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorPhil Ellison <[email protected]>2019-08-11 15:03:27 +0100
committerAleksey Kladov <[email protected]>2019-08-25 10:55:56 +0100
commit456e72c4e472d9ea0717c64a75bd02e94b6e90e8 (patch)
treec2448602a56091b97506bd0c27839e315d38f317 /crates/ra_ide_api
parenta40e390860987a23f9b899abc5947f1525d3709c (diff)
Change test to not rely on trait inference
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs19
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 57454719c..9841fbdf3 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<i32, String> {
285 fn test_wrap_return_type_handles_generic_functions() { 285 fn test_wrap_return_type_handles_generic_functions() {
286 let before = r#" 286 let before = r#"
287 //- /main.rs 287 //- /main.rs
288 use std::{default::Default, result::Result::{self, Ok, Err}}; 288 use std::result::Result::{self, Ok, Err};
289 289
290 fn div<T: Default, i32>(x: i32) -> Result<T, i32> { 290 fn div<T>(x: T) -> Result<T, i32> {
291 if x == 0 { 291 if x == 0 {
292 return Err(7); 292 return Err(7);
293 } 293 }
294 T::default() 294 x
295 } 295 }
296 296
297 //- /std/lib.rs 297 //- /std/lib.rs
298 pub mod result { 298 pub mod result {
299 pub enum Result<T, E> { Ok(T), Err(E) } 299 pub enum Result<T, E> { Ok(T), Err(E) }
300 } 300 }
301 pub mod default {
302 pub trait Default {
303 fn default() -> Self;
304 }
305 }
306 "#; 301 "#;
307// The formatting here is a bit odd due to how the parse_fixture function works in test_utils - 302// The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
308// it strips empty lines and leading whitespace. The important part of this test is that the final 303// it strips empty lines and leading whitespace. The important part of this test is that the final
309// `x / y` expr is now wrapped in `Ok(..)` 304// expr is now wrapped in `Ok(..)`
310 let after = r#"use std::{default::Default, result::Result::{self, Ok, Err}}; 305 let after = r#"use std::result::Result::{self, Ok, Err};
311fn div<T: Default>(x: i32) -> Result<T, i32> { 306fn div<T>(x: T) -> Result<T, i32> {
312 if x == 0 { 307 if x == 0 {
313 return Err(7); 308 return Err(7);
314 } 309 }
315 Ok(T::default()) 310 Ok(x)
316} 311}
317"#; 312"#;
318 check_apply_diagnostic_fix_for_target_file("/main.rs", before, after); 313 check_apply_diagnostic_fix_for_target_file("/main.rs", before, after);