Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir/src/semantics.rs4
-rw-r--r--crates/hir_def/src/attr.rs14
-rw-r--r--crates/ide/src/goto_definition.rs11
3 files changed, 14 insertions, 15 deletions
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 2bffb12dee..eefc12570d 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -364,9 +364,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.resolve_derive_ident(derive, ident)
}
- // FIXME: use this instead?
- // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>;
-
pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> {
self.imp.record_literal_missing_fields(literal)
}
@@ -931,7 +928,6 @@ impl<'db> SemanticsImpl<'db> {
file.with_value(derive.clone()),
)?;
let attrs = adt_def.attrs(self.db);
- // FIXME: https://github.com/rust-analyzer/rust-analyzer/issues/11298
let mut derive_paths = attrs.get(attr_id)?.parse_path_comma_token_tree()?;
let derive_idx = tt
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index f4d8d0d3bd..0a8fb2e47a 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -73,8 +73,8 @@ impl ops::Deref for RawAttrs {
}
}
impl Attrs {
- pub fn get(&self, AttrId { ast_index, .. }: AttrId) -> Option<&Attr> {
- (**self).get(ast_index as usize)
+ pub fn get(&self, id: AttrId) -> Option<&Attr> {
+ (**self).iter().find(|attr| attr.id == id)
}
}
@@ -89,14 +89,6 @@ impl ops::Deref for Attrs {
}
}
-impl ops::Index<AttrId> for Attrs {
- type Output = Attr;
-
- fn index(&self, AttrId { ast_index, .. }: AttrId) -> &Self::Output {
- &(**self)[ast_index as usize]
- }
-}
-
impl ops::Deref for AttrsWithOwner {
type Target = Attrs;
@@ -110,7 +102,7 @@ impl RawAttrs {
pub(crate) fn new(db: &dyn DefDatabase, owner: &dyn ast::HasAttrs, hygiene: &Hygiene) -> Self {
let entries = collect_attrs(owner)
- .flat_map(|(id, attr)| match attr {
+ .filter_map(|(id, attr)| match attr {
Either::Left(attr) => {
attr.meta().and_then(|meta| Attr::from_src(db, meta, hygiene, id))
}
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 29fc1fd2e0..e599efc5e2 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -1364,10 +1364,21 @@ impl Twait for Stwuct {
fn goto_def_derive_input() {
check(
r#"
+ //- minicore:derive
+ #[rustc_builtin_macro]
+ pub macro Copy {}
+ // ^^^^
+ #[derive(Copy$0)]
+ struct Foo;
+ "#,
+ );
+ check(
+ r#"
//- minicore:derive
#[rustc_builtin_macro]
pub macro Copy {}
// ^^^^
+#[cfg_attr(feature = "false", derive)]
#[derive(Copy$0)]
struct Foo;
"#,