Bitflags reverses order of multiline doc comments #344

Closed
opened 2023-04-21 02:02:26 -05:00 by davidv1992 · 1 comment
davidv1992 commented 2023-04-21 02:02:26 -05:00 (Migrated from github.com)

When compiling code like

bitflags! {
    pub struct AdjustFlags: u32 {
        /// Add buf.time to the current time. If buf.status includes the ADJ_NANO flag, then buf.time.tv_usec is interpreted as a nanosecond value;
        /// otherwise it is interpreted as microseconds.
        ///
        /// The value of buf.time is the sum of its two fields, but the field buf.time.tv_usec must always be nonnegative.
        /// The following example shows how to normalize a timeval with nanosecond resolution.
        ///
        /// ```C
        /// while (buf.time.tv_usec < 0) {
        ///     buf.time.tv_sec  -= 1;
        ///     buf.time.tv_usec += 1000000000;
        /// }
        /// ```
        const SETOFFSET = libc::ADJ_SETOFFSET;
    }
}

The doc-comments order is reversed on compile, causing issues with generated docs and the doctest.

This bug only occurs on bitflags 2.2.0 and not on earlier versions

When compiling code like ``` bitflags! { pub struct AdjustFlags: u32 { /// Add buf.time to the current time. If buf.status includes the ADJ_NANO flag, then buf.time.tv_usec is interpreted as a nanosecond value; /// otherwise it is interpreted as microseconds. /// /// The value of buf.time is the sum of its two fields, but the field buf.time.tv_usec must always be nonnegative. /// The following example shows how to normalize a timeval with nanosecond resolution. /// /// ```C /// while (buf.time.tv_usec < 0) { /// buf.time.tv_sec -= 1; /// buf.time.tv_usec += 1000000000; /// } /// ``` const SETOFFSET = libc::ADJ_SETOFFSET; } } ``` The doc-comments order is reversed on compile, causing issues with generated docs and the doctest. This bug only occurs on bitflags 2.2.0 and not on earlier versions
KodrAus commented 2023-04-21 02:29:57 -05:00 (Migrated from github.com)

This should be trivially fixed by swapping the order attributes are "pushed" in __declare_bitflags. We've already yanked 2.2.0 because it requires a lot more recursion, but will keep this open to make sure any new approach doesn't reverse the order of attributes.

This should be trivially fixed by swapping the order attributes are "pushed" in `__declare_bitflags`. We've already yanked `2.2.0` because it requires a lot more recursion, but will keep this open to make sure any new approach doesn't reverse the order of attributes.
Sign in to join this conversation.
No labels
bug
good first issue
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-bitflags/bitflags#344
No description provided.