rename "trait_def" to "def_in_trait"

This commit is contained in:
bitgaoshu 2022-06-24 22:42:30 +08:00
parent 353829fc4e
commit 900b4208fd
2 changed files with 6 additions and 3 deletions

View File

@ -271,7 +271,7 @@ fn rename_reference(
} }
} }
let def = convert_to_trait_def(def, sema); let def = convert_to_def_in_trait(def, sema);
let usages = def.usages(sema).all(); let usages = def.usages(sema).all();
if !usages.is_empty() && ident_kind == IdentifierKind::Underscore { if !usages.is_empty() && ident_kind == IdentifierKind::Underscore {
@ -298,7 +298,10 @@ fn rename_reference(
Ok(source_change) Ok(source_change)
} }
pub(crate) fn convert_to_trait_def(def: Definition, sema: &Semantics<RootDatabase>) -> Definition { pub(crate) fn convert_to_def_in_trait(
def: Definition,
sema: &Semantics<RootDatabase>,
) -> Definition {
// HACK: resolve trait impl items to the item def of the trait definition // HACK: resolve trait impl items to the item def of the trait definition
// so that we properly resolve all trait item references // so that we properly resolve all trait item references
let assoc_item = match def { let assoc_item = match def {

View File

@ -620,7 +620,7 @@ fn found_name_ref(
sink(file_id, reference) sink(file_id, reference)
} }
Some(NameRefClass::Definition(def)) Some(NameRefClass::Definition(def))
if crate::rename::convert_to_trait_def(def, self.sema) == self.def => if crate::rename::convert_to_def_in_trait(def, self.sema) == self.def =>
{ {
let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax()); let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax());
let reference = FileReference { let reference = FileReference {