Skip to content

doc attribute removes whitespace #70732

Closed
@Luro02

Description

@Luro02

I tried this code:

/// You are supposed to call it like this
///
/// # Example
///
/// ```
/// let example = Example::new()
///     .first("hello")
#[cfg_attr(not(feature = "one"), doc = "     .second(\"hello\")\n")]
///     .third("hello")
///     .build();
/// ```
pub struct Example {}

fn main() {}

with cargo doc --open

I expected to see this:

Screenshot_20200403_123723

Instead, this happened:

Screenshot_20200403_123648

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (564758c4c 2020-03-08)
binary: rustc
commit-hash: 564758c4c329e89722454dd2fbb35f1ac0b8b47c
commit-date: 2020-03-08
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

running cargo expand over the code gives me

#![feature(prelude_import)]
#[prelude_import]                                                                                                                                                                             
use std::prelude::v1::*;                                                                                                                                                                      
#[macro_use]                                                                                                                                                                                  
extern crate std;                                                                                                                                                                             
/// You are supposed to call it like this
///                                                                                                                                                                                           
/// # Example                                                                                                                                                                                 
///                                                                                                                                                                                           
/// ```                                                                                                                                                                                       
/// let example = Example::new()                                                                                                                                                              
///     .first("hello")
///     .second("hello")
///     .third("hello")
///     .build();
/// ```
pub struct Example {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions