Skip to content

Commit 456e72c

Browse files
theotherphilmatklad
authored andcommitted
Change test to not rely on trait inference
1 parent a40e390 commit 456e72c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

crates/ra_ide_api/src/diagnostics.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,34 +285,29 @@ fn div(x: i32, y: i32) -> Result<i32, String> {
285285
fn test_wrap_return_type_handles_generic_functions() {
286286
let before = r#"
287287
//- /main.rs
288-
use std::{default::Default, result::Result::{self, Ok, Err}};
288+
use std::result::Result::{self, Ok, Err};
289289
290-
fn div<T: Default, i32>(x: i32) -> Result<T, i32> {
290+
fn div<T>(x: T) -> Result<T, i32> {
291291
if x == 0 {
292292
return Err(7);
293293
}
294-
T::default()
294+
x
295295
}
296296
297297
//- /std/lib.rs
298298
pub mod result {
299299
pub enum Result<T, E> { Ok(T), Err(E) }
300300
}
301-
pub mod default {
302-
pub trait Default {
303-
fn default() -> Self;
304-
}
305-
}
306301
"#;
307302
// The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
308303
// 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(..)`
310-
let after = r#"use std::{default::Default, result::Result::{self, Ok, Err}};
311-
fn div<T: Default>(x: i32) -> Result<T, i32> {
304+
// expr is now wrapped in `Ok(..)`
305+
let after = r#"use std::result::Result::{self, Ok, Err};
306+
fn div<T>(x: T) -> Result<T, i32> {
312307
if x == 0 {
313308
return Err(7);
314309
}
315-
Ok(T::default())
310+
Ok(x)
316311
}
317312
"#;
318313
check_apply_diagnostic_fix_for_target_file("/main.rs", before, after);

0 commit comments

Comments
 (0)