From a73d5f1e50ee9facb776e4a9ad4019a32092be0a Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 17 Sep 2026 15:00:53 -0400 Subject: [PATCH] Add regression test for recursive type bug found a while ago when compiling Rust for Linux --- tests/compile/recursive_types.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/compile/recursive_types.rs diff --git a/tests/compile/recursive_types.rs b/tests/compile/recursive_types.rs new file mode 100644 index 00000000000..3c69074887f --- /dev/null +++ b/tests/compile/recursive_types.rs @@ -0,0 +1,22 @@ +// Compiler: + +// `Set` reaches itself by value through `*mut Root`, so a backend that emits `Root`'s +// fields with the still-incomplete `Set` type fails to compile this. + +#![crate_type = "lib"] + +#[repr(C)] +pub struct Set { + pub root: *mut Root, + pub first: usize, + pub second: usize, +} + +#[repr(C)] +pub struct Root { + pub default_set: Set, +} + +pub fn identity(set: Set) -> Set { + set +}