mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-16 02:27:33 +00:00
Simplify
This commit is contained in:
parent
9cb13b6efb
commit
634d588fd7
13 changed files with 137 additions and 176 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use hir::{HirFileIdExt, InFile, ModuleDef};
|
||||
use hir::{InFile, MacroFileIdExt, ModuleDef};
|
||||
use ide_db::{helpers::mod_path_to_ast, imports::import_assets::NameToImport, items_locator};
|
||||
use itertools::Itertools;
|
||||
use syntax::{
|
||||
|
|
@ -43,12 +43,12 @@ pub(crate) fn replace_derive_with_manual_impl(
|
|||
) -> Option<()> {
|
||||
let attr = ctx.find_node_at_offset_with_descend::<ast::Attr>()?;
|
||||
let path = attr.path()?;
|
||||
let hir_file = ctx.sema.hir_file_for(attr.syntax());
|
||||
if !hir_file.is_derive_attr_pseudo_expansion(ctx.db()) {
|
||||
let macro_file = ctx.sema.hir_file_for(attr.syntax()).macro_file()?;
|
||||
if !macro_file.is_derive_attr_pseudo_expansion(ctx.db()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let InFile { file_id, value } = hir_file.call_node(ctx.db())?;
|
||||
let InFile { file_id, value } = macro_file.call_node(ctx.db());
|
||||
if file_id.is_macro() {
|
||||
// FIXME: make this work in macro files
|
||||
return None;
|
||||
|
|
@ -56,7 +56,7 @@ pub(crate) fn replace_derive_with_manual_impl(
|
|||
// collect the derive paths from the #[derive] expansion
|
||||
let current_derives = ctx
|
||||
.sema
|
||||
.parse_or_expand(hir_file)
|
||||
.parse_or_expand(macro_file.into())
|
||||
.descendants()
|
||||
.filter_map(ast::Attr::cast)
|
||||
.filter_map(|attr| attr.path())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue