Skip to content

rustc --pretty normal generates bad code with top level struct doc comments #31722

Closed
@erickt

Description

@erickt

This code:

/// blarg
struct Foo {
    x: usize,
}

fn main() {}

When run with rustc -Z unstable-options --pretty normal foo.rs produces this invalid code because it's losing a newline:

/// blargstruct Foo {
             x: usize,
         }

fn main() { }

With rustc -Z unstable-options --pretty expanded foo.rs, however, it produces this syntactically correct code:

#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
/// blarg
struct Foo {
    x: usize,
}

fn main() { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-prettyArea: Pretty printing (including `-Z unpretty`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions