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

Commit 19e9994

Browse files
committed
Add cov_mark tests
1 parent e457759 commit 19e9994

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
6060
let right_line = line_index.line_col(r_curly_range.start()).line;
6161

6262
if left_line == right_line {
63+
cov_mark::hit!(single_line);
6364
text.push('\n');
6465
}
6566

@@ -75,12 +76,13 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
7576

7677
#[cfg(test)]
7778
mod tests {
78-
use crate::tests::check_assist;
79+
use crate::tests::{check_assist, check_assist_not_applicable};
7980

8081
use super::*;
8182

8283
#[test]
8384
fn bind_unused_empty_block() {
85+
cov_mark::check!(single_line);
8486
check_assist(
8587
bind_unused_param,
8688
r#"
@@ -124,6 +126,33 @@ fn foo<T>(y: T)
124126
where T : Default {
125127
let _ = y;
126128
}
129+
"#,
130+
);
131+
}
132+
133+
#[test]
134+
fn trait_impl() {
135+
cov_mark::check!(trait_impl);
136+
check_assist_not_applicable(
137+
bind_unused_param,
138+
r#"
139+
trait Trait {
140+
fn foo(x: i32);
141+
}
142+
impl Trait for () {
143+
fn foo($0x: i32) {}
144+
}
145+
"#,
146+
);
147+
}
148+
149+
#[test]
150+
fn keep_used() {
151+
cov_mark::check!(keep_used);
152+
check_assist_not_applicable(
153+
bind_unused_param,
154+
r#"
155+
fn foo(x: i32, $0y: i32) { y; }
127156
"#,
128157
);
129158
}

0 commit comments

Comments
 (0)