Skip to content

Commit 9134d88

Browse files
bors[bot]matklad
andauthored
Merge #4291
4291: Add test marks r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 3b1d983 + 13bce1a commit 9134d88

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

crates/ra_ide/src/marks.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ test_utils::marks!(
1111
self_fulfilling_completion
1212
test_struct_field_completion_in_func_call
1313
test_struct_field_completion_in_record_lit
14+
test_rename_struct_field_for_shorthand
15+
test_rename_local_for_field_shorthand
1416
);

crates/ra_ide/src/references/rename.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ use ra_syntax::{
77
algo::find_node_at_offset, ast, lex_single_valid_syntax_kind, AstNode, SyntaxKind, SyntaxNode,
88
};
99
use ra_text_edit::TextEdit;
10+
use test_utils::tested_by;
1011

1112
use crate::{
12-
FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind, SourceChange,
13-
SourceFileEdit, TextRange,
13+
references::find_all_refs, FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind,
14+
SourceChange, SourceFileEdit, TextRange,
1415
};
1516

16-
use super::find_all_refs;
17-
1817
pub(crate) fn rename(
1918
db: &RootDatabase,
2019
position: FilePosition,
@@ -52,11 +51,13 @@ fn source_edit_from_reference(reference: Reference, new_name: &str) -> SourceFil
5251
let file_id = reference.file_range.file_id;
5352
let range = match reference.kind {
5453
ReferenceKind::FieldShorthandForField => {
54+
tested_by!(test_rename_struct_field_for_shorthand);
5555
replacement_text.push_str(new_name);
5656
replacement_text.push_str(": ");
5757
TextRange::new(reference.file_range.range.start(), reference.file_range.range.start())
5858
}
5959
ReferenceKind::FieldShorthandForLocal => {
60+
tested_by!(test_rename_local_for_field_shorthand);
6061
replacement_text.push_str(": ");
6162
replacement_text.push_str(new_name);
6263
TextRange::new(reference.file_range.range.end(), reference.file_range.range.end())
@@ -147,7 +148,7 @@ fn rename_reference(
147148
mod tests {
148149
use insta::assert_debug_snapshot;
149150
use ra_text_edit::TextEditBuilder;
150-
use test_utils::assert_eq_text;
151+
use test_utils::{assert_eq_text, covers};
151152

152153
use crate::{
153154
mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId,
@@ -379,6 +380,7 @@ mod tests {
379380

380381
#[test]
381382
fn test_rename_struct_field_for_shorthand() {
383+
covers!(test_rename_struct_field_for_shorthand);
382384
test_rename(
383385
r#"
384386
struct Foo {
@@ -408,6 +410,7 @@ mod tests {
408410

409411
#[test]
410412
fn test_rename_local_for_field_shorthand() {
413+
covers!(test_rename_local_for_field_shorthand);
411414
test_rename(
412415
r#"
413416
struct Foo {

0 commit comments

Comments
 (0)