Closed
Description
The generated documentation for const generic expressions generated by macros doesn't substitute macro parameters.
The docs for this code:
pub trait ConstGeneric<const N: usize> {}
macro_rules! trait_impl {
($typ:ty) => {
impl ConstGeneric<{core::mem::size_of::<$typ>()}> for $typ {}
}
}
trait_impl!(i64);
Note that the $typ
macro parameter shows up literally in the const expression of the generic. This bug only happens if the macro parameter is in a const expression within the const generic; other occurrences of the macro parameter are properly substituted.
Produced on rustdoc 1.52.0-nightly (3a5d45f68 2021-03-09)
and rustdoc 1.51.0-beta.4 (4d25f4607 2021-03-05)
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jyn514 commentedon Mar 10, 2021
This looks like a duplicate of #82852.
Flying-Toast commentedon Mar 10, 2021
@jyn514 I think #82852 is a bit different - that’s about substituting const values, this is relating to substitution of macro parameters.
Unless the intended behavior is for rustdoc to show
impl ConstGeneric<8> for i64
?jyn514 commentedon Mar 10, 2021
I think that's what it should show, yes. I'm ok with keeping this issue open for the intermediate step of
impl ConstGeneric<{core::mem::size_of::<i64>()}> for i64 {}
, but I think in practice it will be easier to fix both at once.Flying-Toast commentedon Mar 10, 2021
Ok, makes sense. I’ll close this since it’s really just a subset of #82852 and I don’t want to clutter the issue tracker.