Skip to content

release Rustfmt 1.4.22 #4453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## [Unreleased]

## [1.4.22] 2020-10-04

### Changed

- Update `rustc-ap-*` crates to v679.0.0
- Add config option to allow control of leading match arm pipes
- Support `RUSTFMT` environment variable in `cargo fmt` to run specified `rustfmt` instance


### Fixed

- Fix preservation of type aliases within extern blocks


## [1.4.9] 2019-10-07

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "rustfmt-nightly"
version = "1.4.21"
version = "1.4.22"
authors = ["Nicholas Cameron <ncameron@mozilla.com>", "The Rustfmt developers"]
description = "Tool to find and fix Rust formatting issues"
repository = "https://github.com/rust-lang/rustfmt"
Expand Down
9 changes: 8 additions & 1 deletion config_proc_macro/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ pub fn is_unit(v: &syn::Variant) -> bool {
pub fn debug_with_rustfmt(input: &TokenStream) {
use std::io::Write;
use std::process::{Command, Stdio};
use std::env;
use std::ffi::OsStr;

let mut child = Command::new("rustfmt")
let rustfmt_var = env::var_os("RUSTFMT");
let rustfmt = match &rustfmt_var {
Some(rustfmt) => rustfmt,
None => OsStr::new("rustfmt"),
};
let mut child = Command::new(rustfmt)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
Expand Down
14 changes: 12 additions & 2 deletions src/cargo-fmt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use cargo_metadata;
use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet};
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::hash::{Hash, Hasher};
use std::io::{self, Write};
Expand Down Expand Up @@ -129,6 +130,15 @@ fn execute() -> i32 {
}
}

fn rustfmt_command() -> Command {
let rustfmt_var = env::var_os("RUSTFMT");
let rustfmt = match &rustfmt_var {
Some(rustfmt) => rustfmt,
None => OsStr::new("rustfmt"),
};
Command::new(rustfmt)
}

fn convert_message_format_to_rustfmt_args(
message_format: &str,
rustfmt_args: &mut Vec<String>,
Expand Down Expand Up @@ -205,7 +215,7 @@ fn handle_command_status(status: Result<i32, io::Error>) -> i32 {
}

fn get_rustfmt_info(args: &[String]) -> Result<i32, io::Error> {
let mut command = Command::new("rustfmt")
let mut command = rustfmt_command()
.stdout(std::process::Stdio::inherit())
.args(args)
.spawn()
Expand Down Expand Up @@ -484,7 +494,7 @@ fn run_rustfmt(
println!();
}

let mut command = Command::new("rustfmt")
let mut command = rustfmt_command()
.stdout(stdout)
.args(files)
.args(&["--edition", edition])
Expand Down
9 changes: 8 additions & 1 deletion src/format-diff/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use serde_json as json;
use thiserror::Error;

use std::collections::HashSet;
use std::env;
use std::ffi::OsStr;
use std::io::{self, BufRead};
use std::process;

Expand Down Expand Up @@ -94,7 +96,12 @@ fn run_rustfmt(files: &HashSet<String>, ranges: &[Range]) -> Result<(), FormatDi
debug!("Files: {:?}", files);
debug!("Ranges: {:?}", ranges);

let exit_status = process::Command::new("rustfmt")
let rustfmt_var = env::var_os("RUSTFMT");
let rustfmt = match &rustfmt_var {
Some(rustfmt) => rustfmt,
None => OsStr::new("rustfmt"),
};
let exit_status = process::Command::new(rustfmt)
.args(files)
.arg("--file-lines")
.arg(ranges_as_json)
Expand Down