}
/// Return whether this file is the pseudo expansion of the derive attribute.
- pub fn is_derive_attr_macro(&self, db: &dyn db::AstDatabase) -> bool {
+ /// See [`crate::builtin_attr_macro::derive_attr_expand`].
+ pub fn is_derive_attr_pseudo_expansion(&self, db: &dyn db::AstDatabase) -> bool {
match self.0 {
HirFileIdRepr::MacroFile(macro_file) => {
let loc: MacroCallLoc = db.lookup_intern_macro_call(macro_file.macro_call_id);
let derive = sema.descend_into_macros(tok.clone()).into_iter().find_map(|descended| {
let hir_file = sema.hir_file_for(&descended.parent()?);
- if !hir_file.is_derive_attr_macro(db) {
+ if !hir_file.is_derive_attr_pseudo_expansion(db) {
return None;
}
.token_tree()?
.token_trees_and_tokens()
.filter_map(NodeOrToken::into_token)
- .take_while(|it| it == &token)
+ .take_while(|it| it != &token)
.filter(|it| it.kind() == T![,])
.count();
Some(ExpandedMacro {
"#]],
);
+ check(
+ r#"
+//- minicore: copy, clone, derive
+
+#[derive(Copy, Cl$0one)]
+struct Foo {}
+"#,
+ expect![[r#"
+ Clone
+ impl < >core::clone::Clone for Foo< >{}
+
+ "#]],
+ );
}
}
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_macro(ctx.db()) {
+ if !hir_file.is_derive_attr_pseudo_expansion(ctx.db()) {
return None;
}