Skip to content

"rust-format-on-save" sometimes leads to a "stdin" buffer #365

@xelephas

Description

@xelephas

Seems like I couldn't save the following code if I have (rust-format-on-save t). It always leads to a "stdin" buffer.
I think it's because of the empty lines (with spaces) between the arg blocks. If I remove them, it works fine.

use clap::{App, Arg, ArgMatches, SubCommand};

pub fn func() -> ArgMatches<'static> {
    App::new("test")
        .version("0.1.0")
        .subcommand(
            SubCommand::with_name("add")
                .about("Add a new entry")
                .arg(
                    Arg::with_name("ENTRY")
                )

                
                .arg(
                    Arg::with_name("DATE_MATH")
                        .takes_value(true)
                        .required(false)
                        .multiple(false)
                        .help("The date, can be in the form of 2019-12-20 or -1d/w (1 day/week before)"),
                ),
        )
        .get_matches()
}

The*rustfmt* buffer says:

error[internal]: left behind trailing whitespace
  --> stdin:13:13:0
   |
13 |                 
   | ^^^^^^^^^^^^^^^^
   |

warning: rustfmt has failed to format. See previous 1 errors.

Below is my environment:

GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin19.0.0, NS appkit-1894.10 Version 10.15.1 (Build 19B88)) of 2019-11-26

$ rustfmt  --version
rustfmt 1.4.11-stable (18382352 2019-12-03)

$ elpa/rust-mode-20200322.1749/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions