Skip to content

empty_item_single_line should apply to trait definitions as well #5047

Closed
@nebulaeandstars

Description

@nebulaeandstars

1.4.37-nightly

Using this rustfmt.toml

brace_style = "AlwaysNextLine"
empty_item_single_line = true

rustfmt will format the following code like this:

fn function() {}

struct Struct {}

enum Enum {}

trait Trait
{
}

impl<T> Trait for T {}

This is inconsistent, and empty traits end up sticking out like a sore thumb. Intended behaviour is probably this:

fn function() {}
struct Struct {}
enum Enum {}
trait Trait {}
impl<T> Trait for T {}

This is important, as empty traits are often quite useful. For instance, you might want something like this:

trait Trait: Send + Clone {}
impl<T: Send + Clone> Trait for T {}

which will look quite ugly at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues up for grabs, also good candidates for new rustfmt contributorshelp wantedonly-with-optionrequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions