-
Notifications
You must be signed in to change notification settings - Fork 309
Description
- rust.vim version: 97fdc4e
Steps to reproduce:
$ cargo new --bin edition-fmt
$ cd edition-fmt
$ grep edition Cargo.toml
edition = "2018"
$ echo 'fn main() { async { 1; }; }' > src/main.rsExpected vs. actual behavior:
Expected:
Open src/main.rs in editor and run :RustFmt. The file should now look like this:
fn main() {
async {
1;
};
}Actual:
Open src/main.rs in editor and run :RustFmt. You get the error:
error: expected identifier, found `1`
This is because rustfmt is run, which defaults to the 2015 edition (where async isn't supported). The rustfmt command does not take into account edition from Cargo.toml. It is possible to work around this by doing:
$ echo 'edition = "2018"' > rustfmt.tomlBut remembering to do this in all projects is a bit of a pain, and is not very discoverable. I believe the reason why rustfmt is used over cargo fmt is to support formatting only certain paths, and to support formatting even when operating on Rust files not in a cargo project, but the cost here seems too high. Is there some way we can get both that functionality and have sensible support for edition as specified in Cargo.toml?