Skip to content

rustdoc reports wrong config conditions for impl LowerExp for integers #153655

@Urhengulas

Description

@Urhengulas

View all comments

Actual Output

In the generated documentation for the core library, it reports LowerExp to be only implemented for integers on WebAssembly. See: https://doc.rust-lang.org/1.94.0/core/fmt/trait.LowerExp.html#impl-LowerExp-for-i8.

Show 'Available on WebAssembly only.'

This probably affects other trait implementations as well.

Expected Outcome

LowerExp is available for all integer types on all platforms, therefore I expect it to report nothing regarding configs.

Version

1.94.0

Additional Details

In my understanding the problem is a combination of:

  1. First, how the implementation is generated:

    // Include wasm32 in here since it doesn't reflect the native pointer size, and
    // often cares strongly about getting a smaller code size.
    #[cfg(any(target_pointer_width = "64", target_arch = "wasm32"))]
    mod imp {
    use super::*;
    impl_Display!(i8, u8, i16, u16, i32, u32, i64, u64, isize, usize; as u64 into display_u64);
    impl_Exp!(i8, u8, i16, u16, i32, u32, i64, u64, isize, usize; as u64 into exp_u64);
    }
    #[cfg(not(any(target_pointer_width = "64", target_arch = "wasm32")))]
    mod imp {
    use super::*;
    impl_Display!(i8, u8, i16, u16, i32, u32, isize, usize; as u32 into display_u32);
    impl_Display!(i64, u64; as u64 into display_u64);
    impl_Exp!(i8, u8, i16, u16, i32, u32, isize, usize; as u32 into exp_u32);
    impl_Exp!(i64, u64; as u64 into exp_u64);
    }
    impl_Exp!(i128, u128; as u128 into exp_u128);

    In the end the trait is implemented for all pointer sizes, but it is different depending on the pointer size.

  2. And second that the pointer size configs are hidden:

    #![doc(auto_cfg(hide(
    no_fp_fmt_parse,
    target_pointer_width = "16",
    target_pointer_width = "32",
    target_pointer_width = "64",
    target_has_atomic = "8",
    target_has_atomic = "16",
    target_has_atomic = "32",
    target_has_atomic = "64",
    target_has_atomic = "ptr",
    target_has_atomic_equal_alignment = "8",
    target_has_atomic_equal_alignment = "16",
    target_has_atomic_equal_alignment = "32",
    target_has_atomic_equal_alignment = "64",
    target_has_atomic_equal_alignment = "ptr",
    target_has_atomic_load_store = "8",
    target_has_atomic_load_store = "16",
    target_has_atomic_load_store = "32",
    target_has_atomic_load_store = "64",
    target_has_atomic_load_store = "ptr",
    )))]

If I remove the target_pointer_widths from the doc(auto_cfg(hide(..., then it gets shown like this (which is not really better tbh):

Show 'Available on 64-bit or WebAssembly only.'

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions