Skip to content

doc of macro generated functions is incomplete and constants appear in some internal representation #17090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antonilol opened this issue Apr 17, 2024 · 2 comments
Labels
C-bug Category: bug

Comments

@antonilol
Copy link

rust-analyzer version: rust-analyzer version: 0.4.1830-standalone

rustc version: rustc 1.77.0 (aedd173a2 2024-03-17)

editor or extension: Code OSS (on arch linux, installed with pacman, code 1.87.2-1)

relevant settings: None

code snippet to reproduce:

// start typing this to get the completions
usize::from_be

for me, this looks like this:

image

but the doc should look like this: https://doc.rust-lang.org/std/primitive.usize.html#method.from_be_bytes

the function is defined like this:

        ...

        /// Create a native endian integer value from its representation
        /// as a byte array in big endian.
        ///
        #[doc = $from_xe_bytes_doc]
        ///
        /// # Examples
        ///
        /// ```
        #[doc = concat!("let value = ", stringify!($SelfT), "::from_be_bytes(", $be_bytes, ");")]
        #[doc = concat!("assert_eq!(value, ", $swap_op, ");")]
        /// ```
        ///
        /// When starting from a slice rather than an array, fallible conversion APIs can be used:
        ///
        /// ```
        #[doc = concat!("fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT), " {")]
        #[doc = concat!("    let (int_bytes, rest) = input.split_at(std::mem::size_of::<", stringify!($SelfT), ">());")]
        ///     *input = rest;
        #[doc = concat!("    ", stringify!($SelfT), "::from_be_bytes(int_bytes.try_into().unwrap())")]
        /// }
        /// ```
        #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
        #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
        #[must_use]
        #[inline]
        pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
            Self::from_be(Self::from_ne_bytes(bytes))
        }

        ...

all parts that are not rendered by rust-analyzer are the parts that are different per int type, and put in there with #[doc = ...] and concat!(), the constant that is not evaluated is in [u8; mem::size_of::<Self>()] ([u8; 8] on 64 bit platforms)

@antonilol antonilol added the C-bug Category: bug label Apr 17, 2024
@antonilol
Copy link
Author

antonilol commented Apr 17, 2024

image

when just hovering on it the constant appears as {const}, doc has the same issues as in the original post

@aogier
Copy link

aogier commented Apr 24, 2025

same here, probably related/duplicated of #8092

@Veykril Veykril closed this as completed Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants