Skip to content

Documentation is missing lines from code snippets #17966

New issue

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

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

Already on GitHub? # to your account

Closed
wildework opened this issue Aug 26, 2024 · 3 comments
Closed

Documentation is missing lines from code snippets #17966

wildework opened this issue Aug 26, 2024 · 3 comments
Labels
C-bug Category: bug

Comments

@wildework
Copy link

wildework commented Aug 26, 2024

I'm getting completion results with missing lines from documentation code blocks.

rust-analyzer version: rust-analyzer version: 0.3.2086-standalone (7106cd3be 2024-08-25)

rustc version: rustc 1.80.1 (3f5fd8dd4 2024-08-06)

editor or extension: Manually LSP server requests but same behavior with VS Code Version: 1.92.2.

code snippet to reproduce:

fn main() {
    // Place cursor at the end of ...by and the completion suggestion will include incorrect documentation.
    u16::from_le_by
}
Screenshot 2024-08-26 at 11 03 23

The generated documentation has the full snippets. Also, the same as the official docs

let value = u16::from_le_bytes([0x34, 0x12]);
assert_eq!(value, 0x1234);

and

fn read_le_u16(input: &mut &[u8]) -> u16 {
    let (int_bytes, rest) = input.split_at(std::mem::size_of::<u16>());
    *input = rest;
    u16::from_le_bytes(int_bytes.try_into().unwrap())
}

Whereas rust-analyzer generates the first block as empty code and the second one with two lines with the rest missing.

Here's the LSP server completion response JSON.

{
        "label": "from_le_bytes",
        "kind": 3,
        "detail": "const fn([u8; {in type const InTypeConstId(36)}]) -> u16",
        "documentation": {
          "kind": "markdown",
          "value": "Create a native endian integer value from its representation\nas a byte array in little endian.\n\n\n\n# Examples\n\n```rust\n```\n\nWhen starting from a slice rather than an array, fallible conversion APIs can be used:\n\n```rust\n    *input = rest;\n}\n```"
        },
        "deprecated": false,
        "sortText": "ffffffe0",
        "filterText": "from_le_bytes",
        "textEdit": {
          "range": {
            "start": {
              "line": 22,
              "character": 9
            },
            "end": {
              "line": 22,
              "character": 18
            }
          },
          "newText": "from_le_bytes"
        },
        "additionalTextEdits": []
},
@wildework wildework added the C-bug Category: bug label Aug 26, 2024
@rust-lang rust-lang deleted a comment Aug 26, 2024
@Veykril
Copy link
Member

Veykril commented Aug 26, 2024

This is known, the cause is that r-a can't yet expand macros in inert attributes (closing it as t here are bunch of issues regarding this already)

@Veykril Veykril closed this as completed Aug 26, 2024
@wildework
Copy link
Author

wildework commented Aug 26, 2024

Thanks! Perhaps you could link to the other issues that refer to this issue? I looked but couldn't find them. @Veykril

@rust-lang rust-lang deleted a comment Aug 26, 2024
@lnicola
Copy link
Member

lnicola commented Aug 26, 2024

#8092, #11137

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants