//! Tests for `builtin_derive_macro.rs` from `hir_expand`.
use expect_test::expect;
use crate::macro_expansion_tests::check;
#[test]
fn test_copy_expand_simple() {
check(
r#"
//- minicore: derive, copy
#[derive(Copy)]
struct Foo;
"#,
expect![[r##"
#[derive(Copy)]
struct Foo;
impl < > core::marker::Copy for Foo< > {}"##]],
);
}
#[test]
fn test_copy_expand_in_core() {
cov_mark::check!(test_copy_expand_in_core);
check(
r#"
//- /lib.rs crate:core
#[rustc_builtin_macro]
macro derive {}
#[rustc_builtin_macro]
macro Copy {}
#[derive(Copy)]
struct Foo;
"#,
expect![[r##"
#[rustc_builtin_macro]
macro derive {}
#[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#"
//- minicore: derive, copy
#[derive(Copy)]
struct Foo;
"#,
expect![[r##"
#[derive(Copy)]
struct Foo;
impl core::marker::Copy for Foo {}"##]],
);
}
#[test]
fn test_copy_expand_with_lifetimes() {
// We currently just ignore lifetimes
check(
r#"
//- minicore: derive, copy
#[derive(Copy)]
struct Foo;
"#,
expect![[r##"
#[derive(Copy)]
struct Foo;
impl core::marker::Copy for Foo {}"##]],
);
}
#[test]
fn test_clone_expand() {
check(
r#"
//- minicore: derive, clone
#[derive(Clone)]
struct Foo;
"#,
expect![[r##"
#[derive(Clone)]
struct Foo;
impl core::clone::Clone for Foo {}"##]],
);
}