Skip to content

Commit

Permalink
Merge #9400
Browse files Browse the repository at this point in the history
9400: fix: Fix renaming associated trait items with colliding names r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
  • Loading branch information
bors[bot] and Veykril committed Jun 25, 2021
2 parents c8d0ca8 + 942eeb2 commit 2ac1ffc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions crates/ide/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,25 @@ impl Foo for () {
);
}

#[test]
fn test_rename_trait_method_prefix_of_second() {
check(
"qux",
r#"
trait Foo {
fn foo$0() {}
fn foobar() {}
}
"#,
r#"
trait Foo {
fn qux() {}
fn foobar() {}
}
"#,
);
}

#[test]
fn test_rename_trait_const() {
let res = r"
Expand Down
4 changes: 3 additions & 1 deletion crates/ide_db/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,9 @@ impl<'a> FindUsages<'a> {
let trait_ = mod_def
.as_assoc_item(self.sema.db)?
.containing_trait_or_trait_impl(self.sema.db)?;
(trait_ == this_trait).then(|| {
(trait_ == this_trait
&& self.def.name(self.sema.db) == mod_def.name(self.sema.db))
.then(|| {
let FileRange { file_id, range } = self.sema.original_range(name.syntax());
let reference = FileReference {
range,
Expand Down

0 comments on commit 2ac1ffc

Please sign in to comment.