Skip to content

ctest: Figure out a way to test anonymous structs/unions #4650

Open

Description

@tgross35

We should provide a cfg way to identify a union or struct field as anonymous. This can probably be a is_field_anonymous function that would make ctest "inline" the relevant tests.

This discussion was started at #4610 (comment) but I don't think we actually need that tricky regex pattern.

Activity

  1. mbyx commented on Aug 13, 2025

    @mbyx
    Contributor

    Could you explain a bit about what it means to "inline" the tests? Marking anonymous structs isn't too difficult.

  2. tgross35 commented on Aug 13, 2025

    @tgross35
    MemberAuthor

    That was a bad way to describe how to treat it in tests. So for:

    struct foo {
        bar: anon_bar,
    }
    
    struct anon_bar {
        a: u32,
        b: u32,
    }

    I think we can basically generate tests as if it was instead:

    struct foo {
        a: u32,
        b: u32
    }

    But only for what is passed to the test template, that kind of definition isn't actually accurate because of alignment.

    This isn't high priority btw, just an enhancement over old ctest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ctestIssues relating to the ctest crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions