diff --git a/tests/structs/src/debug_derive.c b/tests/structs/src/debug_derive.c new file mode 100644 index 0000000000..562b20810e --- /dev/null +++ b/tests/structs/src/debug_derive.c @@ -0,0 +1,29 @@ +//! derive:Debug + +#include + +typedef struct { + int a; +} Debuggable1; + +typedef struct { + va_list v; +} Debuggable2; + +Debuggable1 *kDebuggable1; +Debuggable2 *kDebuggable2; + +// A struct containing a union cannot derive Debug, so make +// sure we don't generate a #[derive] for it +typedef struct { + struct { + struct { + union { + int d; + float e; + } c; + } b; + } a; +} NotDebuggable1; + +NotDebuggable1 kNotDebuggable1; diff --git a/tests/structs/src/debug_derive_bad.c b/tests/structs/src/debug_derive_bad.c deleted file mode 100644 index fa62720424..0000000000 --- a/tests/structs/src/debug_derive_bad.c +++ /dev/null @@ -1,15 +0,0 @@ -//! derive:Debug - -// A struct containing a union is not debuggable -typedef struct { - struct { - struct { - union { - int d; - float e; - } c; - } b; - } a; -} StructWithUnion; - -StructWithUnion kStructWithUnion; \ No newline at end of file diff --git a/tests/structs/src/debug_derive_good.c b/tests/structs/src/debug_derive_good.c deleted file mode 100644 index bdbf71ea03..0000000000 --- a/tests/structs/src/debug_derive_good.c +++ /dev/null @@ -1,14 +0,0 @@ -//! derive:Debug - -#include - -typedef struct { - int a; -} S1; - -typedef struct { - va_list v; -} S2; - -S1 *kS1; -S2 *kS2; diff --git a/tests/structs/src/test_debug_derive.rs b/tests/structs/src/test_debug_derive.rs new file mode 100644 index 0000000000..bd5b7a1a3e --- /dev/null +++ b/tests/structs/src/test_debug_derive.rs @@ -0,0 +1,11 @@ +//! feature_c_variadic + +use crate::debug_derive::{rust_kDebuggable1, rust_kDebuggable2}; +use std::fmt::Debug; + +pub fn test_debuggable() { + unsafe { + // Make sure all debuggable structs implement `Debug` + let _debuggable: Vec<*mut dyn Debug> = vec![rust_kDebuggable1, rust_kDebuggable2]; + } +} diff --git a/tests/structs/src/test_debug_derive_bad.rs b/tests/structs/src/test_debug_derive_bad.rs deleted file mode 100644 index bb09029fab..0000000000 --- a/tests/structs/src/test_debug_derive_bad.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! xfail - -mod debug_derive_bad; -use debug_derive_bad::rust_kStructWithUnion; - -pub fn test_union() { - unsafe { - format!("{rust_kStructWithUnion:?}"); - } -} diff --git a/tests/structs/src/test_debug_derive_good.rs b/tests/structs/src/test_debug_derive_good.rs deleted file mode 100644 index cdf558d69c..0000000000 --- a/tests/structs/src/test_debug_derive_good.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! feature_c_variadic - -use crate::debug_derive_good::{rust_kS1, rust_kS2}; -use std::fmt::Debug; - -pub fn test_debuggable() { - unsafe { - // Make sure each struct implements `Debug` - let _debuggable: Vec<*mut dyn Debug> = vec![rust_kS1, rust_kS2]; - } -}