Skip to content

Commit a883441

Browse files
committed
minor: add a test for derive macros in core
1 parent 5af80d8 commit a883441

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

crates/hir_def/src/macro_expansion_tests/builtin_derive_macro.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ impl < > core::marker::Copy for Foo< > {}"##]],
2020
);
2121
}
2222

23+
#[test]
24+
fn test_copy_expand_in_core() {
25+
cov_mark::check!(test_copy_expand_in_core);
26+
check(
27+
r#"
28+
#[rustc_builtin_macro]
29+
macro Copy {}
30+
#[derive(Copy)]
31+
struct Foo;
32+
"#,
33+
expect![[r##"
34+
#[rustc_builtin_macro]
35+
macro Copy {}
36+
#[derive(Copy)]
37+
struct Foo;
38+
39+
impl < > crate ::marker::Copy for Foo< > {}"##]],
40+
);
41+
}
42+
2343
#[test]
2444
fn test_copy_expand_with_type_params() {
2545
check(

crates/hir_expand/src/builtin_derive_macro.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ fn find_builtin_crate(db: &dyn AstDatabase, id: MacroCallId) -> tt::TokenTree {
176176
let tt = if cg[krate].dependencies.iter().any(|dep| &*dep.name == "core") {
177177
quote! { core }
178178
} else {
179+
cov_mark::hit!(test_copy_expand_in_core);
179180
quote! { crate }
180181
};
181182

0 commit comments

Comments
 (0)