@@ -285,34 +285,29 @@ fn div(x: i32, y: i32) -> Result<i32, String> {
285
285
fn test_wrap_return_type_handles_generic_functions ( ) {
286
286
let before = r#"
287
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
291
if x == 0 {
292
292
return Err(7);
293
293
}
294
- T::default()
294
+ x
295
295
}
296
296
297
297
//- /std/lib.rs
298
298
pub mod result {
299
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
302
// The formatting here is a bit odd due to how the parse_fixture function works in test_utils -
308
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(..)`
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> {
312
307
if x == 0 {
313
308
return Err(7);
314
309
}
315
- Ok(T::default() )
310
+ Ok(x )
316
311
}
317
312
"# ;
318
313
check_apply_diagnostic_fix_for_target_file ( "/main.rs" , before, after) ;
0 commit comments