-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustdoc cuts off the last line in a #[doc]
attribute if it only has a single character
#90618
Comments
@nicholasbishop does this also happen for string constants and other things using |
Oh I didn't think to check that. Looks like the bug doesn't reproduce with a non- This runs without error: fn main() {
let inc1 = include_str!("inc1");
let inc2 = include_str!("inc2");
assert_eq!(inc1, "inc1\nab\n");
assert_eq!(inc2, "inc2\nx\n");
} |
Ok cool and follow-up question - does |
That does reproduce the issue. #[doc = "inc2\nx\n"]
pub const C: usize = 2; The rustdoc output looks like |
cc @GuillaumeGomez, this is probably related to your changes to try and make the indentation smarter. |
#[doc]
attribute if it only has a single character
You mean removing the smart indent? ;) But yes, very likely. I'll take a look. |
…emoved, r=jyn514 Fix bug with `#[doc]` string single-character last lines Fixes rust-lang#90618. This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
…emoved, r=jyn514 Fix bug with `#[doc]` string single-character last lines Fixes rust-lang#90618. This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
…emoved, r=jyn514 Fix bug with `#[doc]` string single-character last lines Fixes rust-lang#90618. This is because `.iter().all(|c| c == '*')` returns `true` if there is no character checked. And in case the last line has only one character, it simply returns `true`, making the last line behind removed.
When using
#[doc = include_str!("...")]
to insert another file as a docstring, it seems that the last line gets cut off if it contains only one character.src/inc1
:src/inc2
:(Both
inc
files have a trailing new line.)src/lib.rs
:Running
cargo doc --open
on the above produces output like this:That is, the
inc1
file gets included correctly, but theinc2
file loses its second line. This bug only seems to happen if the last line is a single character.Meta
Reproduced this bug on both stable and nightly.
rustc --version --verbose
:rustc +nightly --version --verbose
:The text was updated successfully, but these errors were encountered: