Skip to content

pow documentation is cut off #17206

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
lkurcak opened this issue May 8, 2024 · 4 comments
Closed

pow documentation is cut off #17206

lkurcak opened this issue May 8, 2024 · 4 comments

Comments

@lkurcak
Copy link

lkurcak commented May 8, 2024

Location

/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs

Summary

Documentation is cut off before examples are shown.

Neovim

image

VS Code

image

Source code of pow, the documentation stops rendering at the #[doc] directive:

/// Raises self to the power of `exp`, using exponentiation by squaring.
///
/// # Examples
///
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".pow(5), 32);")]
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_pow", since = "1.50.0")]
#[must_use = "this returns the result of the operation, \
              without modifying the original"]
#[inline]
#[rustc_inherit_overflow_checks]
pub const fn pow(self, mut exp: u32) -> Self {
    if exp == 0 {
        return 1;
    }
    let mut base = self;
    let mut acc = 1;

    while exp > 1 {
        if (exp & 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }

    // since exp!=0, finally the exp must be 1.
    // Deal with the final bit of the exponent separately, since
    // squaring the base afterwards is not necessary and may cause a
    // needless overflow.
    acc * base
}

There are many functions in this file that have the same problem.

P.S. Usually I would expect documentation to be like this:

/// Basic usage:
///
/// ```
/// assert_eq!(2.pow(5), 32);
/// ```
@Urgau
Copy link
Member

Urgau commented May 8, 2024

Given that I can see the full documentation of pow on the website, I think this is an issue with rust-analyzer.

Which is in this Github repository: https://github.com/rust-lang/rust-analyzer.

@fmease
Copy link
Member

fmease commented May 8, 2024

@rustbot transfer rust-analyzer

@rustbot rustbot transferred this issue from rust-lang/rust May 8, 2024
@roife
Copy link
Member

roife commented May 9, 2024

Might be related to #8092.

@Veykril
Copy link
Member

Veykril commented May 9, 2024

Duplicate of #8092

@Veykril Veykril marked this as a duplicate of #8092 May 9, 2024
@Veykril Veykril closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants