Unnamed repository; edit this file 'description' to name the repository.
minor: add a test for derive macros in core
Aleksey Kladov 2021-10-10
parent 5af80d8 · commit a883441
-rw-r--r--crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs20
-rw-r--r--crates/hir_expand/src/builtin_derive_macro.rs1
2 files changed, 21 insertions, 0 deletions
diff --git a/crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs b/crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs
index 177409dc38..aa50fa6d33 100644
--- a/crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs
+++ b/crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs
@@ -21,6 +21,26 @@ impl < > core::marker::Copy for Foo< > {}"##]],
}
#[test]
+fn test_copy_expand_in_core() {
+ cov_mark::check!(test_copy_expand_in_core);
+ check(
+ r#"
+#[rustc_builtin_macro]
+macro Copy {}
+#[derive(Copy)]
+struct Foo;
+"#,
+ expect![[r##"
+#[rustc_builtin_macro]
+macro Copy {}
+#[derive(Copy)]
+struct Foo;
+
+impl < > crate ::marker::Copy for Foo< > {}"##]],
+ );
+}
+
+#[test]
fn test_copy_expand_with_type_params() {
check(
r#"
diff --git a/crates/hir_expand/src/builtin_derive_macro.rs b/crates/hir_expand/src/builtin_derive_macro.rs
index d4fcf42dd3..31b99e3c41 100644
--- a/crates/hir_expand/src/builtin_derive_macro.rs
+++ b/crates/hir_expand/src/builtin_derive_macro.rs
@@ -176,6 +176,7 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: MacroCallId) -> tt::TokenTree {
let tt = if cg[krate].dependencies.iter().any(|dep| &*dep.name == "core") {
quote! { core }
} else {
+ cov_mark::hit!(test_copy_expand_in_core);
quote! { crate }
};