mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
cov_mark for add_missing_match_arms special cases
This commit is contained in:
parent
1c0eed5f97
commit
3d9ce6b6ce
1 changed files with 6 additions and 0 deletions
|
@ -50,6 +50,7 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
|
||||||
|
|
||||||
let cursor_in_range = target_range.contains_range(ctx.selection_trimmed());
|
let cursor_in_range = target_range.contains_range(ctx.selection_trimmed());
|
||||||
if !cursor_in_range {
|
if !cursor_in_range {
|
||||||
|
cov_mark::hit!(not_applicable_outside_of_range_right);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,6 +200,7 @@ fn cursor_at_trivial_match_arm_list(
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
// match x { $0 }
|
// match x { $0 }
|
||||||
if match_arm_list.arms().next() == None {
|
if match_arm_list.arms().next() == None {
|
||||||
|
cov_mark::hit!(add_missing_match_arms_empty_body);
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +209,7 @@ fn cursor_at_trivial_match_arm_list(
|
||||||
let arm = wild_pat.syntax().parent().and_then(ast::MatchArm::cast)?;
|
let arm = wild_pat.syntax().parent().and_then(ast::MatchArm::cast)?;
|
||||||
let arm_match_expr = arm.syntax().ancestors().nth(2).and_then(ast::MatchExpr::cast)?;
|
let arm_match_expr = arm.syntax().ancestors().nth(2).and_then(ast::MatchExpr::cast)?;
|
||||||
if arm_match_expr == *match_expr {
|
if arm_match_expr == *match_expr {
|
||||||
|
cov_mark::hit!(add_missing_match_arms_trivial_arm);
|
||||||
return Some(());
|
return Some(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +363,7 @@ fn foo(a: A) {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_applicable_outside_of_range_right() {
|
fn not_applicable_outside_of_range_right() {
|
||||||
|
cov_mark::check!(not_applicable_outside_of_range_right);
|
||||||
check_assist_not_applicable(
|
check_assist_not_applicable(
|
||||||
add_missing_match_arms,
|
add_missing_match_arms,
|
||||||
r#"
|
r#"
|
||||||
|
@ -651,6 +655,7 @@ fn main() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_missing_match_arms_empty_body() {
|
fn add_missing_match_arms_empty_body() {
|
||||||
|
cov_mark::check!(add_missing_match_arms_empty_body);
|
||||||
check_assist(
|
check_assist(
|
||||||
add_missing_match_arms,
|
add_missing_match_arms,
|
||||||
r#"
|
r#"
|
||||||
|
@ -954,6 +959,7 @@ fn main() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_missing_match_arms_trivial_arm() {
|
fn add_missing_match_arms_trivial_arm() {
|
||||||
|
cov_mark::check!(add_missing_match_arms_trivial_arm);
|
||||||
check_assist(
|
check_assist(
|
||||||
add_missing_match_arms,
|
add_missing_match_arms,
|
||||||
r#"
|
r#"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue