Skip to content

Commit 5beddf9

Browse files
committed
additional test without further usages
1 parent 95cabfd commit 5beddf9

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

crates/ide_assists/src/handlers/extract_function.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4337,7 +4337,7 @@ fn $0fun_name(a: _) -> _ {
43374337
}
43384338

43394339
#[test]
4340-
fn test_jeroen() {
4340+
fn reference_mutable_param_with_further_usages() {
43414341
check_assist(
43424342
extract_function,
43434343
r#"
@@ -4365,6 +4365,37 @@ pub fn testfn(arg: &mut Foo) {
43654365
println!("{}", arg.field); // read access
43664366
}
43674367
4368+
fn $0fun_name(arg: &mut Foo) {
4369+
arg.field = 8;
4370+
println!("{}", arg.field);
4371+
}
4372+
"#,
4373+
);
4374+
}
4375+
4376+
#[test]
4377+
fn reference_mutable_param_without_further_usages() {
4378+
check_assist(
4379+
extract_function,
4380+
r#"
4381+
pub struct Foo {
4382+
field: u32,
4383+
}
4384+
4385+
pub fn testfn(arg: &mut Foo) {
4386+
$0arg.field = 8; // write access
4387+
println!("{}", arg.field); // read access$0
4388+
}
4389+
"#,
4390+
r#"
4391+
pub struct Foo {
4392+
field: u32,
4393+
}
4394+
4395+
pub fn testfn(arg: &mut Foo) {
4396+
fun_name(arg); // read access
4397+
}
4398+
43684399
fn $0fun_name(arg: &mut Foo) {
43694400
arg.field = 8;
43704401
println!("{}", arg.field);

0 commit comments

Comments
 (0)