Skip to content

Update rustfmt command line interface #4006

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 15 commits into from
Jan 12, 2020
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
31 changes: 5 additions & 26 deletions Cargo.lock

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

17 changes: 8 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,24 @@ test = false

[features]
default = ["cargo-fmt", "rustfmt-format-diff"]
cargo-fmt = []
rustfmt-format-diff = []
cargo-fmt = ["cargo_metadata"]
rustfmt-format-diff = ["regex", "serde", "serde_json"]
generic-simd = ["rustfmt_lib/generic-simd"]

[dependencies]
ansi_term = "0.12"
anyhow = "1.0"
cargo_metadata = "0.9"
env_logger = "0.7"
getopts = "0.2"
log = "0.4"
regex = "1.0"
serde = "1.0"
serde_json = "1.0"
structopt = "0.3"
term = "0.6"
thiserror = "1.0"

rustfmt_lib = { path = "rustfmt-core/rustfmt-lib", version = "1.0" }
cargo_metadata = { version = "0.9", optional = true }
regex = { version = "1.0", optional = true }
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }

rustfmt_lib = { path = "rustfmt-core/rustfmt-lib", version = "2.0.0-rc.1" }

[dev-dependencies]
lazy_static = "1.0"
Expand Down
8 changes: 0 additions & 8 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1881,14 +1881,6 @@ specific version of rustfmt is used in your CI, use this option.
- **Possible values**: any published version (e.g. `"0.3.8"`)
- **Stable**: No (tracking issue: #3386)

## `skip_children` (DEPRECATED #3587)

Don't reformat out of line modules

- **Default value**: `false`
- **Possible values**: `true`, `false`
- **Stable**: No (tracking issue: #3389)

## `space_after_colon`

Leave a space after the colon.
Expand Down
2 changes: 1 addition & 1 deletion rustfmt-core/rustfmt-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ structopt = "0.3"
term = "0.6"
thiserror = "1.0"

rustfmt_lib = { path = "../rustfmt-lib", version = "1.0" }
rustfmt_lib = { path = "../rustfmt-lib", version = "2.0.0-rc.1" }

[dev-dependencies]
lazy_static = "1.0"
10 changes: 8 additions & 2 deletions rustfmt-core/rustfmt-bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ fn main() {
}

println!("cargo:rerun-if-env-changed=CFG_RELEASE_CHANNEL");
if option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev") {
println!("cargo:rustc-cfg=nightly");
}

let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());

File::create(out_dir.join("commit-info.txt"))
File::create(out_dir.join("version-info.txt"))
.unwrap()
.write_all(commit_info().as_bytes())
.unwrap();
Expand All @@ -25,7 +28,10 @@ fn main() {
// (git not installed or if this is not a git repository) just return an empty string.
fn commit_info() -> String {
match (channel(), commit_hash(), commit_date()) {
(channel, Some(hash), Some(date)) => format!("{} ({} {})", channel, hash.trim_end(), date),
(channel, Some(hash), Some(date)) => {
format!("{}-{} ({} {})", option_env!("CARGO_PKG_VERSION")
.unwrap_or("unknown"), channel, hash.trim_end(), date)
},
_ => String::new(),
}
}
Expand Down
Loading