mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
Merge pull request #20303 from Hmikihiro/migrate_path_transform
Migrate path transform
This commit is contained in:
commit
3a0cf54236
8 changed files with 170 additions and 87 deletions
|
|
@ -192,7 +192,7 @@ pub fn add_trait_assoc_items_to_impl(
|
|||
original_items
|
||||
.iter()
|
||||
.map(|InFile { file_id, value: original_item }| {
|
||||
let cloned_item = {
|
||||
let mut cloned_item = {
|
||||
if let Some(macro_file) = file_id.macro_file() {
|
||||
let span_map = sema.db.expansion_span_map(macro_file);
|
||||
let item_prettified = prettify_macro_expansion(
|
||||
|
|
@ -208,17 +208,18 @@ pub fn add_trait_assoc_items_to_impl(
|
|||
}
|
||||
}
|
||||
original_item.clone_for_update()
|
||||
};
|
||||
}
|
||||
.reset_indent();
|
||||
|
||||
if let Some(source_scope) = sema.scope(original_item.syntax()) {
|
||||
// FIXME: Paths in nested macros are not handled well. See
|
||||
// `add_missing_impl_members::paths_in_nested_macro_should_get_transformed` test.
|
||||
let transform =
|
||||
PathTransform::trait_impl(target_scope, &source_scope, trait_, impl_.clone());
|
||||
transform.apply(cloned_item.syntax());
|
||||
cloned_item = ast::AssocItem::cast(transform.apply(cloned_item.syntax())).unwrap();
|
||||
}
|
||||
cloned_item.remove_attrs_and_docs();
|
||||
cloned_item.reset_indent()
|
||||
cloned_item
|
||||
})
|
||||
.map(|item| {
|
||||
match &item {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue