Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 514bab5

Browse files
authored
Merge branch 'rust-lang:master' into master
2 parents 2e515d0 + fdb8aa2 commit 514bab5

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

crates/ide-assists/src/handlers/extract_function.rs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,14 +1360,15 @@ fn make_call(ctx: &AssistContext<'_>, fun: &Function, indent: IndentLevel) -> St
13601360
}
13611361

13621362
format_to!(buf, "{expr}");
1363-
let insert_comma = fun
1364-
.body
1365-
.parent()
1366-
.and_then(ast::MatchArm::cast)
1367-
.map_or(false, |it| it.comma_token().is_none());
1363+
let parent_match_arm = fun.body.parent().and_then(ast::MatchArm::cast);
1364+
let insert_comma = parent_match_arm.as_ref().is_some_and(|it| it.comma_token().is_none());
1365+
13681366
if insert_comma {
13691367
buf.push(',');
1370-
} else if fun.ret_ty.is_unit() && (!fun.outliving_locals.is_empty() || !expr.is_block_like()) {
1368+
} else if parent_match_arm.is_none()
1369+
&& fun.ret_ty.is_unit()
1370+
&& (!fun.outliving_locals.is_empty() || !expr.is_block_like())
1371+
{
13711372
buf.push(';');
13721373
}
13731374
buf
@@ -4611,6 +4612,29 @@ fn $0fun_name() -> i32 {
46114612
}
46124613
"#,
46134614
);
4615+
4616+
// Makes sure no semicolon is added for unit-valued match arms
4617+
check_assist(
4618+
extract_function,
4619+
r#"
4620+
fn main() {
4621+
match () {
4622+
_ => $0()$0,
4623+
}
4624+
}
4625+
"#,
4626+
r#"
4627+
fn main() {
4628+
match () {
4629+
_ => fun_name(),
4630+
}
4631+
}
4632+
4633+
fn $0fun_name() {
4634+
()
4635+
}
4636+
"#,
4637+
)
46144638
}
46154639

46164640
#[test]

docs/user/manual.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ If you're not using Code, you can compile and install only the LSP server:
141141
$ cargo xtask install --server
142142
----
143143

144+
Make sure that `.cargo/bin` is in `$PATH` and precedes paths where `rust-analyzer` may also be installed.
145+
Specifically, `rustup` includes a proxy called `rust-analyzer`, which can cause problems if you're planning to use a source build or even a downloaded binary.
146+
144147
=== rust-analyzer Language Server Binary
145148

146149
Other editors generally require the `rust-analyzer` binary to be in `$PATH`.

0 commit comments

Comments
 (0)