Repository navigation
Description
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.
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:
-
First, how the implementation is generated:
rust/library/core/src/fmt/num.rs
Lines 594 to 612 in 3bc6ea5
// 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.
-
And second that the pointer size configs are hidden:
Lines 54 to 74 in 3bc6ea5
#![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):

Activity
jyn514 commentedon Mar 10, 2026
@rustbot label A-docs F-doc_auto_cfg
eggyal commentedon Mar 10, 2026
Is this really an issue for
T-rustdocandF-doc_auto_cfg- aren't they all behaving as they should? I rather think this is just a libs issue, where the use ofdoc(auto_cfg)needs tweaking/overriding in this case.@rustbot label -F-doc_auto_cfg -T-rustdoc +T-libs -needs-triage
jyn514 commentedon Mar 10, 2026
@eggyal what would the correct usage be? is there a way to override the auto_cfg behavior for individual items?
eggyal commentedon Mar 10, 2026
https://doc.rust-lang.org/rustdoc/unstable-features.html#doccfg-and-docauto_cfg
Also https://doc.rust-lang.org/rustdoc/unstable-features.html#doccfg
Also perhaps most relevant https://doc.rust-lang.org/rustdoc/unstable-features.html#docauto_cfgdocauto_cfg--truedocauto_cfg--false
eggyal commentedon Mar 10, 2026
Alternatively the code could be restructured so that there is in fact just a single
implacross all configurations, and only the methods within those implementations differ by conditional compilation. I'm not sure whether libs have a preference for how this is done, or indeed if the issue has even arisen before.Urhengulas commentedon Mar 11, 2026
@eggyal I am just trying to overwrite the auto_cfg configuration for this module only but it does not seem to work as I would expect.
auto_cfg(show/hide(...))Using
#[doc(auto_cfg(show/hide(...)))]does not seem to have any effect. I don't think this is intended but maybe I am misunderstanding how it should work.#![doc(auto_cfg(hide(target_arch = "wasm32")))]Adding
#![doc(auto_cfg(hide(target_arch = "wasm32")))]to either the module or the macro invocation does not change anything, the generated rustdoc stays the same.diff
#![doc(auto_cfg(show(target_pointer_width = "64")))]Adding
#![doc(auto_cfg(show(target_pointer_width = "64")))]also has no effect.diff
doc(cfg(all()))The only option I found that generates the rustdoc without any "only available on ..." note is
#[doc(cfg(all()))]on the macro invocation. Which is an okay workaround but does not seem like a proper solution.diff
19 remaining items
Add regression test for rust-lang#153655
GuillaumeGomez commentedon Mar 16, 2026
Finally opened #153964.
Add regression test for rust-lang#153655
Add regression test for rust-lang#153655
Add regression test for rust-lang#153655
Rollup merge of rust-lang#153964 - GuillaumeGomez:fix-trait-impl-doc-…
Rollup merge of rust-lang#153964 - GuillaumeGomez:fix-trait-impl-doc-…
eggyal commentedon Mar 24, 2026
Ah, while #153964 fixed the rustdoc bug that prevented this issue being fixed in core,
#[doc(auto_cfg = false)](or similar) still needs to be applied to thecore::fmt::num::impmodule to actually fix this issue.Perhaps someone can reopen until then?
GuillaumeGomez commentedon Mar 24, 2026
Sure!
GuillaumeGomez commentedon Mar 24, 2026
I'll also send the fix to
libcoreso we're done with this issue once and for all.Rollup merge of rust-lang#154311 - GuillaumeGomez:fix-integer-doc-cfg…
Rollup merge of rust-lang#154311 - GuillaumeGomez:fix-integer-doc-cfg…