mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Disambiguate replace with if let assist labels
This commit is contained in:
parent
637dbb26a7
commit
0796288ed2
3 changed files with 6 additions and 6 deletions
|
@ -82,7 +82,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext)
|
||||||
let target = if_expr.syntax().text_range();
|
let target = if_expr.syntax().text_range();
|
||||||
acc.add(
|
acc.add(
|
||||||
AssistId("replace_if_let_with_match", AssistKind::RefactorRewrite),
|
AssistId("replace_if_let_with_match", AssistKind::RefactorRewrite),
|
||||||
"Replace with match",
|
"Replace if let with match",
|
||||||
target,
|
target,
|
||||||
move |edit| {
|
move |edit| {
|
||||||
let match_expr = {
|
let match_expr = {
|
||||||
|
@ -195,7 +195,7 @@ pub(crate) fn replace_match_with_if_let(acc: &mut Assists, ctx: &AssistContext)
|
||||||
let target = match_expr.syntax().text_range();
|
let target = match_expr.syntax().text_range();
|
||||||
acc.add(
|
acc.add(
|
||||||
AssistId("replace_match_with_if_let", AssistKind::RefactorRewrite),
|
AssistId("replace_match_with_if_let", AssistKind::RefactorRewrite),
|
||||||
"Replace with if let",
|
"Replace match with if let",
|
||||||
target,
|
target,
|
||||||
move |edit| {
|
move |edit| {
|
||||||
let condition = make::condition(scrutinee, Some(if_let_pat));
|
let condition = make::condition(scrutinee, Some(if_let_pat));
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||||
|
|
||||||
// Assist: replace_let_with_if_let
|
// Assist: replace_let_with_if_let
|
||||||
//
|
//
|
||||||
// Replaces `let` with an `if-let`.
|
// Replaces `let` with an `if let`.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
// # enum Option<T> { Some(T), None }
|
// # enum Option<T> { Some(T), None }
|
||||||
|
@ -45,7 +45,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) ->
|
||||||
let target = let_kw.text_range();
|
let target = let_kw.text_range();
|
||||||
acc.add(
|
acc.add(
|
||||||
AssistId("replace_let_with_if_let", AssistKind::RefactorRewrite),
|
AssistId("replace_let_with_if_let", AssistKind::RefactorRewrite),
|
||||||
"Replace with if-let",
|
"Replace let with if let",
|
||||||
target,
|
target,
|
||||||
|edit| {
|
|edit| {
|
||||||
let ty = ctx.sema.type_of_expr(&init);
|
let ty = ctx.sema.type_of_expr(&init);
|
||||||
|
|
|
@ -246,7 +246,7 @@ pub fn test_some_range(a: int) -> bool {
|
||||||
Convert integer base
|
Convert integer base
|
||||||
Extract into variable
|
Extract into variable
|
||||||
Extract into function
|
Extract into function
|
||||||
Replace with match
|
Replace if let with match
|
||||||
"#]]
|
"#]]
|
||||||
.assert_eq(&expected);
|
.assert_eq(&expected);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ pub fn test_some_range(a: int) -> bool {
|
||||||
Convert integer base
|
Convert integer base
|
||||||
Extract into variable
|
Extract into variable
|
||||||
Extract into function
|
Extract into function
|
||||||
Replace with match
|
Replace if let with match
|
||||||
"#]]
|
"#]]
|
||||||
.assert_eq(&expected);
|
.assert_eq(&expected);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue