diff --git a/Cargo.lock b/Cargo.lock index 05c039102317..4d5d4d05aa06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,15 @@ name = "bitflags" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cargo-fmt" +version = "0.4.0" +dependencies = [ + "cargo_metadata 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cargo_metadata" version = "0.4.1" @@ -109,6 +118,17 @@ name = "getopts" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "git-rustfmt" +version = "0.4.0" +dependencies = [ + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfmt-config 0.4.0", + "rustfmt-core 0.4.0", +] + [[package]] name = "itoa" version = "0.3.4" @@ -159,7 +179,15 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.1.42" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -185,7 +213,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -197,11 +225,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -293,14 +332,32 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rustfmt-nightly" -version = "0.3.8" +name = "rustfmt-bin" +version = "0.4.0" dependencies = [ - "cargo_metadata 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfmt-config 0.4.0", + "rustfmt-core 0.4.0", +] + +[[package]] +name = "rustfmt-config" +version = "0.4.0" +dependencies = [ + "rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustfmt-core" +version = "0.4.0" +dependencies = [ + "derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", @@ -308,13 +365,23 @@ dependencies = [ "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustfmt-config 0.4.0", + "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustfmt-format-diff" +version = "0.4.0" +dependencies = [ + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -362,7 +429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -505,12 +572,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" -"checksum num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9936036cc70fe4a8b2d338ab665900323290efb03983c86cbe235ae800ad8017" +"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +"checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412" "checksum parking_lot_core 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "9f35048d735bb93dd115a0030498785971aab3234d311fbe273d020084d26bd8" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)" = "512870020642bb8c221bf68baa1b2573da814f6ccfe5c9699b1c303047abe9b1" +"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" +"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "744554e01ccbd98fff8c457c3b092cd67af62a555a43bfe97ae8a0451f7799fa" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum rustc-ap-rustc_cratesio_shim 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ad5e562044ea78a6764dd75ae8afe4b21fde49f4548024b5fdf6345c21fb524" diff --git a/Cargo.toml b/Cargo.toml index a54e1fe482da..63d3c5342219 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,58 +1,9 @@ -[package] - -name = "rustfmt-nightly" -version = "0.3.8" -authors = ["Nicholas Cameron ", "The Rustfmt developers"] -description = "Tool to find and fix Rust formatting issues" -repository = "https://github.com/rust-lang-nursery/rustfmt" -readme = "README.md" -license = "Apache-2.0/MIT" -build = "build.rs" -categories = ["development-tools"] - -[lib] -doctest = false - -[[bin]] -name = "rustfmt" - -[[bin]] -name = "cargo-fmt" - -[[bin]] -name = "rustfmt-format-diff" - -[[bin]] -name = "git-rustfmt" - -[features] -default = ["cargo-fmt", "rustfmt-format-diff"] -cargo-fmt = [] -rustfmt-format-diff = [] - -[dependencies] -toml = "0.4" -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" -unicode-segmentation = "1.0.0" -regex = "0.2" -term = "0.4" -diff = "0.1" -log = "0.3" -env_logger = "0.4" -getopts = "0.2" -derive-new = "0.5" -cargo_metadata = "0.4" -rustc-ap-syntax = "29.0.0" -rustc-ap-rustc_errors = "29.0.0" - -[dev-dependencies] -lazy_static = "1.0.0" - -[target.'cfg(unix)'.dependencies] -libc = "0.2.11" - -[target.'cfg(windows)'.dependencies] -kernel32-sys = "0.2.2" -winapi = "0.2.7" +[workspace] +members = [ + "cargo-fmt", + "git-rustfmt", + "rustfmt-bin", + "rustfmt-config", + "rustfmt-core", + "rustfmt-format-diff", +] diff --git a/appveyor.yml b/appveyor.yml index 71704c494e7e..87c1773ce8eb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -47,9 +47,6 @@ install: # ??? build: false -# Build rustfmt, run the executables as test_script: - cargo build --verbose - - cargo run --bin rustfmt -- --help - - cargo run --bin cargo-fmt -- --help - cargo test diff --git a/cargo-fmt/Cargo.toml b/cargo-fmt/Cargo.toml new file mode 100644 index 000000000000..871426572316 --- /dev/null +++ b/cargo-fmt/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "cargo-fmt" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "Cargo frontend for rustfmt" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +categories = ["development-tools"] + +[[bin]] +name = "cargo-fmt" + +[dependencies] +cargo_metadata = "0.4" +getopts = "0.2" +serde_json = "1.0" diff --git a/src/bin/cargo-fmt.rs b/cargo-fmt/src/main.rs similarity index 100% rename from src/bin/cargo-fmt.rs rename to cargo-fmt/src/main.rs diff --git a/git-rustfmt/Cargo.toml b/git-rustfmt/Cargo.toml new file mode 100644 index 000000000000..1fcd1ccc613b --- /dev/null +++ b/git-rustfmt/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "git-rustfmt" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "Run rustfmt against git diff" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +categories = ["development-tools"] + +[[bin]] +name = "git-rustfmt" + +[dependencies] +env_logger = "0.4" +getopts = "0.2" +log = "0.3" +rustfmt-config = { path = "../rustfmt-config" } +rustfmt-core = { path = "../rustfmt-core" } \ No newline at end of file diff --git a/src/bin/git-rustfmt.rs b/git-rustfmt/src/main.rs similarity index 90% rename from src/bin/git-rustfmt.rs rename to git-rustfmt/src/main.rs index 5e7cb458649b..558efbf0c0f4 100644 --- a/src/bin/git-rustfmt.rs +++ b/git-rustfmt/src/main.rs @@ -1,8 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + extern crate env_logger; extern crate getopts; #[macro_use] extern crate log; -extern crate rustfmt_nightly as rustfmt; +extern crate rustfmt_config as config; +extern crate rustfmt_core as rustfmt; use std::env; use std::path::{Path, PathBuf}; @@ -12,7 +23,6 @@ use std::str::FromStr; use getopts::{Matches, Options}; use rustfmt::{run, Input}; -use rustfmt::config; fn prune_files(files: Vec<&str>) -> Vec<&str> { let prefixes: Vec<_> = files diff --git a/rustfmt-bin/Cargo.toml b/rustfmt-bin/Cargo.toml new file mode 100644 index 000000000000..c07146dcb019 --- /dev/null +++ b/rustfmt-bin/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "rustfmt-bin" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "Tool to find and fix Rust formatting issues" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +build = "build.rs" +categories = ["development-tools"] + +[[bin]] +name = "rustfmt" +path = "src/main.rs" + +[dependencies] +env_logger = "0.4" +getopts = "0.2" +rustfmt-config = { path = "../rustfmt-config" } +rustfmt-core = { path = "../rustfmt-core" } \ No newline at end of file diff --git a/rustfmt-bin/build.rs b/rustfmt-bin/build.rs new file mode 100644 index 000000000000..2643946236d6 --- /dev/null +++ b/rustfmt-bin/build.rs @@ -0,0 +1,49 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + + File::create(out_dir.join("commit-info.txt")) + .unwrap() + .write_all(commit_info().as_bytes()) + .unwrap(); +} + +// Try to get hash and date of the last commit on a best effort basis. If anything goes wrong +// (git not installed or if this is not a git repository) just return an empty string. +fn commit_info() -> String { + match (commit_hash(), commit_date()) { + (Some(hash), Some(date)) => format!(" ({} {})", hash.trim_right(), date), + _ => String::new(), + } +} + +fn commit_hash() -> Option { + Command::new("git") + .args(&["rev-parse", "--short", "HEAD"]) + .output() + .ok() + .and_then(|r| String::from_utf8(r.stdout).ok()) +} + +fn commit_date() -> Option { + Command::new("git") + .args(&["log", "-1", "--date=short", "--pretty=format:%cd"]) + .output() + .ok() + .and_then(|r| String::from_utf8(r.stdout).ok()) +} diff --git a/src/bin/rustfmt.rs b/rustfmt-bin/src/main.rs similarity index 98% rename from src/bin/rustfmt.rs rename to rustfmt-bin/src/main.rs index 214c02f95a5e..fbaacc69bdfa 100644 --- a/src/bin/rustfmt.rs +++ b/rustfmt-bin/src/main.rs @@ -8,24 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rustc_private)] #![cfg(not(test))] extern crate env_logger; extern crate getopts; -extern crate rustfmt_nightly as rustfmt; +extern crate rustfmt_config as config; +extern crate rustfmt_core as rustfmt; use std::{env, error}; use std::fs::File; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; -use std::str::FromStr; use getopts::{Matches, Options}; +use config::{get_toml_path, Color, Config, WriteMode}; +use config::file_lines::FileLines; use rustfmt::{run, FileName, Input, Summary}; -use rustfmt::config::{get_toml_path, Color, Config, WriteMode}; -use rustfmt::file_lines::FileLines; + +use std::str::FromStr; type FmtError = Box; type FmtResult = std::result::Result; diff --git a/rustfmt-config/Cargo.toml b/rustfmt-config/Cargo.toml new file mode 100644 index 000000000000..c7e5c9d83158 --- /dev/null +++ b/rustfmt-config/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rustfmt-config" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "A library for configuring and customizing rustfmt" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +categories = ["development-tools"] + +[dependencies] +rustc-ap-syntax = "29.0.0" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" +toml = "0.4" \ No newline at end of file diff --git a/rustfmt-config/src/config_type.rs b/rustfmt-config/src/config_type.rs new file mode 100644 index 000000000000..51642570fdfd --- /dev/null +++ b/rustfmt-config/src/config_type.rs @@ -0,0 +1,380 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use file_lines::FileLines; +use options::WidthHeuristics; + +/// Trait for types that can be used in `Config`. +pub trait ConfigType: Sized { + /// Returns hint text for use in `Config::print_docs()`. For enum types, this is a + /// pipe-separated list of variants; for other types it returns "". + fn doc_hint() -> String; +} + +impl ConfigType for bool { + fn doc_hint() -> String { + String::from("") + } +} + +impl ConfigType for usize { + fn doc_hint() -> String { + String::from("") + } +} + +impl ConfigType for isize { + fn doc_hint() -> String { + String::from("") + } +} + +impl ConfigType for String { + fn doc_hint() -> String { + String::from("") + } +} + +impl ConfigType for FileLines { + fn doc_hint() -> String { + String::from("") + } +} + +impl ConfigType for WidthHeuristics { + fn doc_hint() -> String { + String::new() + } +} + +/// Check if we're in a nightly build. +/// +/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap +/// to "stable", "beta", or "nightly" depending on what toolchain is being built. +/// If we are being built as part of the stable or beta toolchains, we want +/// to disable unstable configuration options. +/// +/// If we're being built by cargo (e.g. `cargo +nightly install rustfmt-nightly`), +/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the +/// nightly compiler when installed from crates.io, default to nightly mode. +macro_rules! is_nightly_channel { + () => { + option_env!("CFG_RELEASE_CHANNEL") + .map(|c| c == "nightly") + .unwrap_or(true) + }; +} + +macro_rules! create_config { + ($($i:ident: $ty:ty, $def:expr, $stb:expr, $( $dstring:expr ),+ );+ $(;)*) => ( + #[derive(Clone)] + pub struct Config { + // For each config item, we store a bool indicating whether it has + // been accessed and the value, and a bool whether the option was + // manually initialised, or taken from the default, + $($i: (Cell, bool, $ty, bool)),+ + } + + // Just like the Config struct but with each property wrapped + // as Option. This is used to parse a rustfmt.toml that doesn't + // specify all properties of `Config`. + // We first parse into `PartialConfig`, then create a default `Config` + // and overwrite the properties with corresponding values from `PartialConfig`. + #[derive(Deserialize, Serialize, Clone)] + pub struct PartialConfig { + $(pub $i: Option<$ty>),+ + } + + impl PartialConfig { + pub fn to_toml(&self) -> Result { + // Non-user-facing options can't be specified in TOML + let mut cloned = self.clone(); + cloned.file_lines = None; + cloned.verbose = None; + cloned.width_heuristics = None; + + toml::to_string(&cloned) + .map_err(|e| format!("Could not output config: {}", e.to_string())) + } + } + + // Macro hygiene won't allow us to make `set_$i()` methods on Config + // for each item, so this struct is used to give the API to set values: + // `config.get().option(false)`. It's pretty ugly. Consider replacing + // with `config.set_option(false)` if we ever get a stable/usable + // `concat_idents!()`. + pub struct ConfigSetter<'a>(&'a mut Config); + + impl<'a> ConfigSetter<'a> { + $( + pub fn $i(&mut self, value: $ty) { + (self.0).$i.2 = value; + if stringify!($i) == "use_small_heuristics" { + self.0.set_heuristics(); + } + } + )+ + } + + // Query each option, returns true if the user set the option, false if + // a default was used. + pub struct ConfigWasSet<'a>(&'a Config); + + impl<'a> ConfigWasSet<'a> { + $( + pub fn $i(&self) -> bool { + (self.0).$i.1 + } + )+ + } + + impl Config { + pub fn version_meets_requirement(&self, error_summary: &mut Summary) -> bool { + if self.was_set().required_version() { + let version = env!("CARGO_PKG_VERSION"); + let required_version = self.required_version(); + if version != required_version { + println!( + "Error: rustfmt version ({}) doesn't match the required version ({})", + version, + required_version, + ); + error_summary.add_formatting_error(); + return false; + } + } + + true + } + + $( + pub fn $i(&self) -> $ty { + self.$i.0.set(true); + self.$i.2.clone() + } + )+ + + pub fn set<'a>(&'a mut self) -> ConfigSetter<'a> { + ConfigSetter(self) + } + + pub fn was_set<'a>(&'a self) -> ConfigWasSet<'a> { + ConfigWasSet(self) + } + + fn fill_from_parsed_config(mut self, parsed: PartialConfig) -> Config { + $( + if let Some(val) = parsed.$i { + if self.$i.3 { + self.$i.1 = true; + self.$i.2 = val; + } else { + if is_nightly_channel!() { + self.$i.1 = true; + self.$i.2 = val; + } else { + eprintln!("Warning: can't set `{} = {:?}`, unstable features are only \ + available in nightly channel.", stringify!($i), val); + } + } + } + )+ + self.set_heuristics(); + self + } + + pub fn from_toml(toml: &str) -> Result { + let parsed: toml::Value = + toml.parse().map_err(|e| format!("Could not parse TOML: {}", e))?; + let mut err: String = String::new(); + { + let table = parsed + .as_table() + .ok_or(String::from("Parsed config was not table"))?; + for key in table.keys() { + match &**key { + $( + stringify!($i) => (), + )+ + _ => { + let msg = + &format!("Warning: Unknown configuration option `{}`\n", key); + err.push_str(msg) + } + } + } + } + match parsed.try_into() { + Ok(parsed_config) => { + if !err.is_empty() { + eprint!("{}", err); + } + Ok(Config::default().fill_from_parsed_config(parsed_config)) + } + Err(e) => { + err.push_str("Error: Decoding config file failed:\n"); + err.push_str(format!("{}\n", e).as_str()); + err.push_str("Please check your config file."); + Err(err) + } + } + } + + pub fn used_options(&self) -> PartialConfig { + PartialConfig { + $( + $i: if self.$i.0.get() { + Some(self.$i.2.clone()) + } else { + None + }, + )+ + } + } + + pub fn all_options(&self) -> PartialConfig { + PartialConfig { + $( + $i: Some(self.$i.2.clone()), + )+ + } + } + + pub fn override_value(&mut self, key: &str, val: &str) + { + match key { + $( + stringify!($i) => { + self.$i.2 = val.parse::<$ty>() + .expect(&format!("Failed to parse override for {} (\"{}\") as a {}", + stringify!($i), + val, + stringify!($ty))); + } + )+ + _ => panic!("Unknown config key in override: {}", key) + } + + if key == "use_small_heuristics" { + self.set_heuristics(); + } + } + + /// Construct a `Config` from the toml file specified at `file_path`. + /// + /// This method only looks at the provided path, for a method that + /// searches parents for a `rustfmt.toml` see `from_resolved_toml_path`. + /// + /// Return a `Config` if the config could be read and parsed from + /// the file, Error otherwise. + pub fn from_toml_path(file_path: &Path) -> Result { + let mut file = File::open(&file_path)?; + let mut toml = String::new(); + file.read_to_string(&mut toml)?; + Config::from_toml(&toml).map_err(|err| Error::new(ErrorKind::InvalidData, err)) + } + + /// Resolve the config for input in `dir`. + /// + /// Searches for `rustfmt.toml` beginning with `dir`, and + /// recursively checking parents of `dir` if no config file is found. + /// If no config file exists in `dir` or in any parent, a + /// default `Config` will be returned (and the returned path will be empty). + /// + /// Returns the `Config` to use, and the path of the project file if there was + /// one. + pub fn from_resolved_toml_path(dir: &Path) -> Result<(Config, Option), Error> { + + /// Try to find a project file in the given directory and its parents. + /// Returns the path of a the nearest project file if one exists, + /// or `None` if no project file was found. + fn resolve_project_file(dir: &Path) -> Result, Error> { + let mut current = if dir.is_relative() { + env::current_dir()?.join(dir) + } else { + dir.to_path_buf() + }; + + current = fs::canonicalize(current)?; + + loop { + match get_toml_path(¤t) { + Ok(Some(path)) => return Ok(Some(path)), + Err(e) => return Err(e), + _ => () + } + + // If the current directory has no parent, we're done searching. + if !current.pop() { + return Ok(None); + } + } + } + + match resolve_project_file(dir)? { + None => Ok((Config::default(), None)), + Some(path) => Config::from_toml_path(&path).map(|config| (config, Some(path))), + } + } + + + pub fn print_docs() { + use std::cmp; + const HIDE_OPTIONS: [&str; 3] = ["verbose", "file_lines", "width_heuristics"]; + let max = 0; + $( let max = cmp::max(max, stringify!($i).len()+1); )+ + let mut space_str = String::with_capacity(max); + for _ in 0..max { + space_str.push(' '); + } + println!("Configuration Options:"); + $( + let name_raw = stringify!($i); + + if !HIDE_OPTIONS.contains(&name_raw) { + let mut name_out = String::with_capacity(max); + for _ in name_raw.len()..max-1 { + name_out.push(' ') + } + name_out.push_str(name_raw); + name_out.push(' '); + println!("{}{} Default: {:?}", + name_out, + <$ty>::doc_hint(), + $def); + $( + println!("{}{}", space_str, $dstring); + )+ + println!(); + } + )+ + } + + fn set_heuristics(&mut self) { + if self.use_small_heuristics.2 { + self.set().width_heuristics(WidthHeuristics::default()); + } else { + self.set().width_heuristics(WidthHeuristics::null()); + } + } + } + + // Template for the default configuration + impl Default for Config { + fn default() -> Config { + Config { + $( + $i: (Cell::new(false), false, $def, $stb), + )+ + } + } + } + ) +} diff --git a/src/file_lines.rs b/rustfmt-config/src/file_lines.rs similarity index 97% rename from src/file_lines.rs rename to rustfmt-config/src/file_lines.rs index 028c631b1b97..87e201345dee 100644 --- a/src/file_lines.rs +++ b/rustfmt-config/src/file_lines.rs @@ -12,12 +12,25 @@ use std::{cmp, iter, str}; use std::collections::HashMap; +use std::rc::Rc; use serde::de::{Deserialize, Deserializer}; use serde_json as json; -use codemap::LineRange; -use syntax::codemap::FileName; +use syntax::codemap::{FileMap, FileName}; + +/// A range of lines in a file, inclusive of both ends. +pub struct LineRange { + pub file: Rc, + pub lo: usize, + pub hi: usize, +} + +impl LineRange { + pub fn file_name(&self) -> &FileName { + &self.file.name + } +} /// A range that is inclusive of both ends. #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Deserialize)] diff --git a/rustfmt-config/src/lib.rs b/rustfmt-config/src/lib.rs new file mode 100644 index 000000000000..cbfd236dc37e --- /dev/null +++ b/rustfmt-config/src/lib.rs @@ -0,0 +1,252 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate serde; +#[macro_use] +extern crate serde_derive; +extern crate serde_json; +extern crate syntax; +extern crate toml; + +use std::{env, fs}; +use std::cell::Cell; +use std::default::Default; +use std::fs::File; +use std::io::{Error, ErrorKind, Read}; +use std::path::{Path, PathBuf}; + +#[macro_use] +mod config_type; +#[macro_use] +mod options; + +pub mod file_lines; +pub mod lists; +pub mod summary; + +use config_type::ConfigType; +use file_lines::FileLines; +pub use lists::*; +pub use options::*; +use summary::Summary; + +/// This macro defines configuration options used in rustfmt. Each option +/// is defined as follows: +/// +/// `name: value type, default value, is stable, description;` +create_config! { + // Fundamental stuff + max_width: usize, 100, true, "Maximum width of each line"; + hard_tabs: bool, false, true, "Use tab characters for indentation, spaces for alignment"; + tab_spaces: usize, 4, true, "Number of spaces per tab"; + newline_style: NewlineStyle, NewlineStyle::Unix, true, "Unix or Windows line endings"; + indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items."; + use_small_heuristics: bool, true, false, "Whether to use different formatting for items and\ + expressions if they satisfy a heuristic notion of 'small'."; + + // strings and comments + format_strings: bool, false, false, "Format string literals where necessary"; + wrap_comments: bool, false, true, "Break comments to fit on the line"; + comment_width: usize, 80, false, + "Maximum length of comments. No effect unless wrap_comments = true"; + normalize_comments: bool, false, true, "Convert /* */ comments to // comments where possible"; + + // Single line expressions and items. + empty_item_single_line: bool, true, false, + "Put empty-body functions and impls on a single line"; + struct_lit_single_line: bool, true, false, + "Put small struct literals on a single line"; + fn_single_line: bool, false, false, "Put single-expression functions on a single line"; + where_single_line: bool, false, false, "To force single line where layout"; + + // Imports + imports_indent: IndentStyle, IndentStyle::Visual, false, "Indent of imports"; + imports_layout: ListTactic, ListTactic::Mixed, false, "Item layout inside a import block"; + + // Ordering + reorder_extern_crates: bool, true, false, "Reorder extern crate statements alphabetically"; + reorder_extern_crates_in_group: bool, true, false, "Reorder extern crate statements in group"; + reorder_imports: bool, false, false, "Reorder import statements alphabetically"; + reorder_imports_in_group: bool, false, false, "Reorder import statements in group"; + reorder_imported_names: bool, true, false, + "Reorder lists of names in import statements alphabetically"; + reorder_modules: bool, false, false, "Reorder module statemtents alphabetically in group"; + + // Spaces around punctuation + binop_separator: SeparatorPlace, SeparatorPlace::Front, false, + "Where to put a binary operator when a binary expression goes multiline."; + type_punctuation_density: TypeDensity, TypeDensity::Wide, false, + "Determines if '+' or '=' are wrapped in spaces in the punctuation of types"; + space_before_colon: bool, false, false, "Leave a space before the colon"; + space_after_colon: bool, true, false, "Leave a space after the colon"; + spaces_around_ranges: bool, false, false, "Put spaces around the .. and ... range operators"; + spaces_within_parens_and_brackets: bool, false, false, + "Put spaces within non-empty parentheses or brackets"; + + // Misc. + combine_control_expr: bool, true, false, "Combine control expressions with function calls."; + struct_field_align_threshold: usize, 0, false, "Align struct fields if their diffs fits within \ + threshold."; + remove_blank_lines_at_start_or_end_of_block: bool, true, false, + "Remove blank lines at start or end of a block"; + match_arm_blocks: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \ + the same line with the pattern of arms"; + force_multiline_blocks: bool, false, false, + "Force multiline closure bodies and match arms to be wrapped in a block"; + fn_args_density: Density, Density::Tall, false, "Argument density in functions"; + brace_style: BraceStyle, BraceStyle::SameLineWhere, false, "Brace style for items"; + control_brace_style: ControlBraceStyle, ControlBraceStyle::AlwaysSameLine, false, + "Brace style for control flow constructs"; + trailing_comma: SeparatorTactic, SeparatorTactic::Vertical, false, + "How to handle trailing commas for lists"; + trailing_semicolon: bool, true, false, + "Add trailing semicolon after break, continue and return"; + match_block_trailing_comma: bool, false, false, + "Put a trailing comma after a block based match arm (non-block arms are not affected)"; + blank_lines_upper_bound: usize, 1, false, + "Maximum number of blank lines which can be put between items."; + blank_lines_lower_bound: usize, 0, false, + "Minimum number of blank lines which must be put between items."; + + // Options that can change the source code beyond whitespace/blocks (somewhat linty things) + merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one"; + use_try_shorthand: bool, false, false, "Replace uses of the try! macro by the ? shorthand"; + condense_wildcard_suffixes: bool, false, false, "Replace strings of _ wildcards by a single .. \ + in tuple patterns"; + force_explicit_abi: bool, true, true, "Always print the abi for extern items"; + use_field_init_shorthand: bool, false, false, "Use field initialization shorthand if possible"; + + // Control options (changes the operation of rustfmt, rather than the formatting) + write_mode: WriteMode, WriteMode::Overwrite, false, + "What Write Mode to use when none is supplied: \ + Replace, Overwrite, Display, Plain, Diff, Coverage"; + color: Color, Color::Auto, false, + "What Color option to use when none is supplied: Always, Never, Auto"; + required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false, + "Require a specific version of rustfmt."; + unstable_features: bool, false, true, + "Enables unstable features. Only available on nightly channel"; + disable_all_formatting: bool, false, false, "Don't reformat anything"; + skip_children: bool, false, false, "Don't reformat out of line modules"; + hide_parse_errors: bool, false, false, "Hide errors from the parser"; + error_on_line_overflow: bool, true, false, "Error if unable to get all lines within max_width"; + error_on_unformatted: bool, false, false, + "Error if unable to get comments or string literals within max_width, \ + or they are left with trailing whitespaces"; + report_todo: ReportTactic, ReportTactic::Never, false, + "Report all, none or unnumbered occurrences of TODO in source file comments"; + report_fixme: ReportTactic, ReportTactic::Never, false, + "Report all, none or unnumbered occurrences of FIXME in source file comments"; + + // Not user-facing. + verbose: bool, false, false, "Use verbose output"; + file_lines: FileLines, FileLines::all(), false, + "Lines to format; this is not supported in rustfmt.toml, and can only be specified \ + via the --file-lines option"; + width_heuristics: WidthHeuristics, WidthHeuristics::default(), false, + "'small' heuristic values"; +} + +/// Check for the presence of known config file names (`rustfmt.toml, `.rustfmt.toml`) in `dir` +/// +/// Return the path if a config file exists, empty if no file exists, and Error for IO errors +pub fn get_toml_path(dir: &Path) -> Result, Error> { + const CONFIG_FILE_NAMES: [&str; 2] = [".rustfmt.toml", "rustfmt.toml"]; + for config_file_name in &CONFIG_FILE_NAMES { + let config_file = dir.join(config_file_name); + match fs::metadata(&config_file) { + // Only return if it's a file to handle the unlikely situation of a directory named + // `rustfmt.toml`. + Ok(ref md) if md.is_file() => return Ok(Some(config_file)), + // Return the error if it's something other than `NotFound`; otherwise we didn't + // find the project file yet, and continue searching. + Err(e) => { + if e.kind() != ErrorKind::NotFound { + return Err(e); + } + } + _ => {} + } + } + Ok(None) +} + +#[cfg(test)] +mod test { + use super::Config; + + #[test] + fn test_config_set() { + let mut config = Config::default(); + config.set().verbose(false); + assert_eq!(config.verbose(), false); + config.set().verbose(true); + assert_eq!(config.verbose(), true); + } + + #[test] + fn test_config_used_to_toml() { + let config = Config::default(); + + let merge_derives = config.merge_derives(); + let skip_children = config.skip_children(); + + let used_options = config.used_options(); + let toml = used_options.to_toml().unwrap(); + assert_eq!( + toml, + format!( + "merge_derives = {}\nskip_children = {}\n", + merge_derives, skip_children, + ) + ); + } + + #[test] + fn test_was_set() { + let config = Config::from_toml("hard_tabs = true").unwrap(); + + assert_eq!(config.was_set().hard_tabs(), true); + assert_eq!(config.was_set().verbose(), false); + } + + // FIXME(#2183) these tests cannot be run in parallel because they use env vars + // #[test] + // fn test_as_not_nightly_channel() { + // let mut config = Config::default(); + // assert_eq!(config.was_set().unstable_features(), false); + // config.set().unstable_features(true); + // assert_eq!(config.was_set().unstable_features(), false); + // } + + // #[test] + // fn test_as_nightly_channel() { + // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from("")); + // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly"); + // let mut config = Config::default(); + // config.set().unstable_features(true); + // assert_eq!(config.was_set().unstable_features(), false); + // config.set().unstable_features(true); + // assert_eq!(config.unstable_features(), true); + // ::std::env::set_var("CFG_RELEASE_CHANNEL", v); + // } + + // #[test] + // fn test_unstable_from_toml() { + // let mut config = Config::from_toml("unstable_features = true").unwrap(); + // assert_eq!(config.was_set().unstable_features(), false); + // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from("")); + // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly"); + // config = Config::from_toml("unstable_features = true").unwrap(); + // assert_eq!(config.was_set().unstable_features(), true); + // assert_eq!(config.unstable_features(), true); + // ::std::env::set_var("CFG_RELEASE_CHANNEL", v); + // } +} diff --git a/rustfmt-config/src/lists.rs b/rustfmt-config/src/lists.rs new file mode 100644 index 000000000000..2ddc2e592612 --- /dev/null +++ b/rustfmt-config/src/lists.rs @@ -0,0 +1,105 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Configuration options related to rewriting a list. + +use IndentStyle; +use config_type::ConfigType; + +/// The definitive formatting tactic for lists. +#[derive(Eq, PartialEq, Debug, Copy, Clone)] +pub enum DefinitiveListTactic { + Vertical, + Horizontal, + Mixed, + /// Special case tactic for `format!()`, `write!()` style macros. + SpecialMacro(usize), +} + +impl DefinitiveListTactic { + pub fn ends_with_newline(&self, indent_style: IndentStyle) -> bool { + match indent_style { + IndentStyle::Block => *self != DefinitiveListTactic::Horizontal, + IndentStyle::Visual => false, + } + } +} + +/// Formatting tactic for lists. This will be cast down to a +/// `DefinitiveListTactic` depending on the number and length of the items and +/// their comments. +#[derive(Eq, PartialEq, Debug, Copy, Clone)] +pub enum ListTactic { + // One item per row. + Vertical, + // All items on one row. + Horizontal, + // Try Horizontal layout, if that fails then vertical. + HorizontalVertical, + // HorizontalVertical with a soft limit of n characters. + LimitedHorizontalVertical(usize), + // Pack as many items as possible per row over (possibly) many rows. + Mixed, +} + +impl_enum_serialize_and_deserialize!(ListTactic, Vertical, Horizontal, HorizontalVertical, Mixed); + +#[derive(Eq, PartialEq, Debug, Copy, Clone)] +pub enum SeparatorTactic { + Always, + Never, + Vertical, +} + +impl_enum_serialize_and_deserialize!(SeparatorTactic, Always, Never, Vertical); + +impl SeparatorTactic { + pub fn from_bool(b: bool) -> SeparatorTactic { + if b { + SeparatorTactic::Always + } else { + SeparatorTactic::Never + } + } +} + +/// Where to put separator. +#[derive(Eq, PartialEq, Debug, Copy, Clone)] +pub enum SeparatorPlace { + Front, + Back, +} + +impl_enum_serialize_and_deserialize!(SeparatorPlace, Front, Back); + +impl SeparatorPlace { + pub fn is_front(&self) -> bool { + *self == SeparatorPlace::Front + } + + pub fn is_back(&self) -> bool { + *self == SeparatorPlace::Back + } + + pub fn from_tactic( + default: SeparatorPlace, + tactic: DefinitiveListTactic, + sep: &str, + ) -> SeparatorPlace { + match tactic { + DefinitiveListTactic::Vertical => default, + _ => if sep == "," { + SeparatorPlace::Back + } else { + default + }, + } + } +} diff --git a/rustfmt-config/src/macros.rs b/rustfmt-config/src/macros.rs new file mode 100644 index 000000000000..6391db85dc51 --- /dev/null +++ b/rustfmt-config/src/macros.rs @@ -0,0 +1,10 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + diff --git a/rustfmt-config/src/options.rs b/rustfmt-config/src/options.rs new file mode 100644 index 000000000000..bff6d2298d3b --- /dev/null +++ b/rustfmt-config/src/options.rs @@ -0,0 +1,244 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use config_type::ConfigType; +use lists::*; + +/// Macro for deriving implementations of Serialize/Deserialize for enums +#[macro_export] +macro_rules! impl_enum_serialize_and_deserialize { + ( $e:ident, $( $x:ident ),* ) => { + impl ::serde::ser::Serialize for $e { + fn serialize(&self, serializer: S) -> Result + where S: ::serde::ser::Serializer + { + use serde::ser::Error; + + // We don't know whether the user of the macro has given us all options. + #[allow(unreachable_patterns)] + match *self { + $( + $e::$x => serializer.serialize_str(stringify!($x)), + )* + _ => { + Err(S::Error::custom(format!("Cannot serialize {:?}", self))) + } + } + } + } + + impl<'de> ::serde::de::Deserialize<'de> for $e { + fn deserialize(d: D) -> Result + where D: ::serde::Deserializer<'de> { + use serde::de::{Error, Visitor}; + use std::marker::PhantomData; + use std::fmt; + struct StringOnly(PhantomData); + impl<'de, T> Visitor<'de> for StringOnly + where T: ::serde::Deserializer<'de> { + type Value = String; + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("string") + } + fn visit_str(self, value: &str) -> Result { + Ok(String::from(value)) + } + } + let s = d.deserialize_string(StringOnly::(PhantomData))?; + $( + if stringify!($x).eq_ignore_ascii_case(&s) { + return Ok($e::$x); + } + )* + static ALLOWED: &'static[&str] = &[$(stringify!($x),)*]; + Err(D::Error::unknown_variant(&s, ALLOWED)) + } + } + + impl ::std::str::FromStr for $e { + type Err = &'static str; + + fn from_str(s: &str) -> Result { + $( + if stringify!($x).eq_ignore_ascii_case(s) { + return Ok($e::$x); + } + )* + Err("Bad variant") + } + } + + impl ConfigType for $e { + fn doc_hint() -> String { + let mut variants = Vec::new(); + $( + variants.push(stringify!($x)); + )* + format!("[{}]", variants.join("|")) + } + } + }; +} + +macro_rules! configuration_option_enum{ + ($e:ident: $( $x:ident ),+ $(,)*) => { + #[derive(Copy, Clone, Eq, PartialEq, Debug)] + pub enum $e { + $( $x ),+ + } + + impl_enum_serialize_and_deserialize!($e, $( $x ),+); + } +} + +configuration_option_enum! { NewlineStyle: + Windows, // \r\n + Unix, // \n + Native, // \r\n in Windows, \n on other platforms +} + +configuration_option_enum! { BraceStyle: + AlwaysNextLine, + PreferSameLine, + // Prefer same line except where there is a where clause, in which case force + // the brace to the next line. + SameLineWhere, +} + +configuration_option_enum! { ControlBraceStyle: + // K&R style, Rust community default + AlwaysSameLine, + // Stroustrup style + ClosingNextLine, + // Allman style + AlwaysNextLine, +} + +configuration_option_enum! { IndentStyle: + // First line on the same line as the opening brace, all lines aligned with + // the first line. + Visual, + // First line is on a new line and all lines align with block indent. + Block, +} + +configuration_option_enum! { Density: + // Fit as much on one line as possible. + Compressed, + // Use more lines. + Tall, + // Place every item on a separate line. + Vertical, +} + +configuration_option_enum! { TypeDensity: + // No spaces around "=" and "+" + Compressed, + // Spaces around " = " and " + " + Wide, +} + +impl Density { + pub fn to_list_tactic(self) -> ListTactic { + match self { + Density::Compressed => ListTactic::Mixed, + Density::Tall => ListTactic::HorizontalVertical, + Density::Vertical => ListTactic::Vertical, + } + } +} + +configuration_option_enum! { ReportTactic: + Always, + Unnumbered, + Never, +} + +configuration_option_enum! { WriteMode: + // Backs the original file up and overwrites the original. + Replace, + // Overwrites original file without backup. + Overwrite, + // Writes the output to stdout. + Display, + // Writes the diff to stdout. + Diff, + // Displays how much of the input file was processed + Coverage, + // Unfancy stdout + Plain, + // Outputs a checkstyle XML file. + Checkstyle, +} + +configuration_option_enum! { Color: + // Always use color, whether it is a piped or terminal output + Always, + // Never use color + Never, + // Automatically use color, if supported by terminal + Auto, +} + +#[derive(Deserialize, Serialize, Clone, Debug)] +pub struct WidthHeuristics { + // Maximum width of the args of a function call before falling back + // to vertical formatting. + pub fn_call_width: usize, + // Maximum width in the body of a struct lit before falling back to + // vertical formatting. + pub struct_lit_width: usize, + // Maximum width in the body of a struct variant before falling back + // to vertical formatting. + pub struct_variant_width: usize, + // Maximum width of an array literal before falling back to vertical + // formatting. + pub array_width: usize, + // Maximum length of a chain to fit on a single line. + pub chain_width: usize, + // Maximum line length for single line if-else expressions. A value + // of zero means always break if-else expressions. + pub single_line_if_else_max_width: usize, +} + +impl WidthHeuristics { + // Using this WidthHeuristics means we ignore heuristics. + pub fn null() -> WidthHeuristics { + WidthHeuristics { + fn_call_width: usize::max_value(), + struct_lit_width: 0, + struct_variant_width: 0, + array_width: usize::max_value(), + chain_width: usize::max_value(), + single_line_if_else_max_width: 0, + } + } +} + +impl Default for WidthHeuristics { + fn default() -> WidthHeuristics { + WidthHeuristics { + fn_call_width: 60, + struct_lit_width: 18, + struct_variant_width: 35, + array_width: 60, + chain_width: 60, + single_line_if_else_max_width: 50, + } + } +} + +impl ::std::str::FromStr for WidthHeuristics { + type Err = &'static str; + + fn from_str(_: &str) -> Result { + Err("WidthHeuristics is not parsable") + } +} diff --git a/src/summary.rs b/rustfmt-config/src/summary.rs similarity index 89% rename from src/summary.rs rename to rustfmt-config/src/summary.rs index 3e339fa4469f..b0be5678a0b5 100644 --- a/src/summary.rs +++ b/rustfmt-config/src/summary.rs @@ -1,3 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + use std::time::{Duration, Instant}; use std::default::Default; diff --git a/rustfmt-core/Cargo.toml b/rustfmt-core/Cargo.toml new file mode 100644 index 000000000000..2cf72e3f2106 --- /dev/null +++ b/rustfmt-core/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "rustfmt-core" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "A core library of rustfmt" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +categories = ["development-tools"] + +[lib] +doctest = false + +[dependencies] +derive-new = "0.5" +diff = "0.1" +log = "0.3" +regex = "0.2" +rustc-ap-syntax = "29.0.0" +rustc-ap-rustc_errors = "29.0.0" +rustfmt-config = { path = "../rustfmt-config" } +term = "0.4" +unicode-segmentation = "1.0.0" + +[dev-dependencies] +lazy_static = "1.0.0" + +[target.'cfg(unix)'.dependencies] +libc = "0.2.11" + +[target.'cfg(windows)'.dependencies] +kernel32-sys = "0.2.2" +winapi = "0.2.7" diff --git a/src/chains.rs b/rustfmt-core/src/chains.rs similarity index 100% rename from src/chains.rs rename to rustfmt-core/src/chains.rs diff --git a/src/checkstyle.rs b/rustfmt-core/src/checkstyle.rs similarity index 100% rename from src/checkstyle.rs rename to rustfmt-core/src/checkstyle.rs diff --git a/src/closures.rs b/rustfmt-core/src/closures.rs similarity index 98% rename from src/closures.rs rename to rustfmt-core/src/closures.rs index 61287543da91..be1681c76716 100644 --- a/src/closures.rs +++ b/rustfmt-core/src/closures.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use config::lists::*; use syntax::{ast, ptr}; use syntax::codemap::Span; use syntax::parse::classify; @@ -15,8 +16,7 @@ use syntax::parse::classify; use codemap::SpanUtils; use expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond, ToExpr}; use items::{span_hi_for_arg, span_lo_for_arg}; -use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting, - ListTactic, Separator, SeparatorPlace, SeparatorTactic}; +use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}; use rewrite::{Rewrite, RewriteContext}; use shape::Shape; use utils::{last_line_width, left_most_sub_expr, stmt_expr}; diff --git a/src/codemap.rs b/rustfmt-core/src/codemap.rs similarity index 90% rename from src/codemap.rs rename to rustfmt-core/src/codemap.rs index d74d24439d9c..85716f736155 100644 --- a/src/codemap.rs +++ b/rustfmt-core/src/codemap.rs @@ -11,25 +11,11 @@ //! This module contains utilities that work with the `CodeMap` from `libsyntax` / `syntex_syntax`. //! This includes extension traits and methods for looking up spans and line ranges for AST nodes. -use std::rc::Rc; - -use syntax::codemap::{BytePos, CodeMap, FileMap, FileName, Span}; +use config::file_lines::LineRange; +use syntax::codemap::{BytePos, CodeMap, Span}; use comment::FindUncommented; -/// A range of lines in a file, inclusive of both ends. -pub struct LineRange { - pub file: Rc, - pub lo: usize, - pub hi: usize, -} - -impl LineRange { - pub fn file_name(&self) -> &FileName { - &self.file.name - } -} - pub trait SpanUtils { fn span_after(&self, original: Span, needle: &str) -> BytePos; fn span_after_last(&self, original: Span, needle: &str) -> BytePos; diff --git a/src/comment.rs b/rustfmt-core/src/comment.rs similarity index 100% rename from src/comment.rs rename to rustfmt-core/src/comment.rs diff --git a/src/expr.rs b/rustfmt-core/src/expr.rs similarity index 99% rename from src/expr.rs rename to rustfmt-core/src/expr.rs index fb873ee26d3d..1d572f642e23 100644 --- a/src/expr.rs +++ b/rustfmt-core/src/expr.rs @@ -12,6 +12,7 @@ use std::borrow::Cow; use std::cmp::min; use std::iter::repeat; +use config::lists::*; use syntax::{ast, ptr}; use syntax::codemap::{BytePos, CodeMap, Span}; @@ -22,8 +23,7 @@ use comment::{combine_strs_with_missing_comments, contains_comment, recover_comm rewrite_comment, rewrite_missing_comment, FindUncommented}; use config::{Config, ControlBraceStyle, IndentStyle}; use lists::{definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, - struct_lit_shape, struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, - ListItem, ListTactic, Separator, SeparatorPlace, SeparatorTactic}; + struct_lit_shape, struct_lit_tactic, write_list, ListFormatting, ListItem, Separator}; use macros::{rewrite_macro, MacroArg, MacroPosition}; use patterns::{can_be_overflowed_pat, TuplePatField}; use rewrite::{Rewrite, RewriteContext}; diff --git a/src/filemap.rs b/rustfmt-core/src/filemap.rs similarity index 97% rename from src/filemap.rs rename to rustfmt-core/src/filemap.rs index 81f950cfb9b5..5986dbd6fa38 100644 --- a/src/filemap.rs +++ b/rustfmt-core/src/filemap.rs @@ -19,10 +19,7 @@ use config::{Config, NewlineStyle, WriteMode}; use rustfmt_diff::{make_diff, print_diff, Mismatch}; use syntax::codemap::FileName; -// A map of the files of a crate, with their new content -pub type FileMap = Vec; - -pub type FileRecord = (FileName, String); +use FileRecord; // Append a newline to the end of each file. pub fn append_newline(s: &mut String) { diff --git a/src/imports.rs b/rustfmt-core/src/imports.rs similarity index 99% rename from src/imports.rs rename to rustfmt-core/src/imports.rs index 0b65cafe730e..31ff4229ae20 100644 --- a/src/imports.rs +++ b/rustfmt-core/src/imports.rs @@ -10,14 +10,14 @@ use std::cmp::Ordering; +use config::lists::*; use syntax::ast; use syntax::codemap::{BytePos, Span}; use codemap::SpanUtils; use comment::combine_strs_with_missing_comments; use config::IndentStyle; -use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting, - ListItem, Separator, SeparatorPlace, SeparatorTactic}; +use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator}; use rewrite::{Rewrite, RewriteContext}; use shape::Shape; use spanned::Spanned; diff --git a/src/issues.rs b/rustfmt-core/src/issues.rs similarity index 96% rename from src/issues.rs rename to rustfmt-core/src/issues.rs index 2efd61a3d7d4..353f8349d2a1 100644 --- a/src/issues.rs +++ b/rustfmt-core/src/issues.rs @@ -14,17 +14,15 @@ use std::fmt; -pub use config::ReportTactic; +use config::ReportTactic; const TO_DO_CHARS: &[char] = &['t', 'o', 'd', 'o']; const FIX_ME_CHARS: &[char] = &['f', 'i', 'x', 'm', 'e']; // Enabled implementation detail is here because it is // irrelevant outside the issues module -impl ReportTactic { - fn is_enabled(&self) -> bool { - *self != ReportTactic::Never - } +fn is_enabled(report_tactic: ReportTactic) -> bool { + report_tactic != ReportTactic::Never } #[derive(Clone, Copy)] @@ -128,7 +126,7 @@ impl BadIssueSeeker { fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize) -> Seeking { if let Some(lower_case_c) = c.to_lowercase().next() { - if self.report_todo.is_enabled() && lower_case_c == TO_DO_CHARS[todo_idx] { + if is_enabled(self.report_todo) && lower_case_c == TO_DO_CHARS[todo_idx] { todo_idx += 1; if todo_idx == TO_DO_CHARS.len() { return Seeking::Number { @@ -144,7 +142,7 @@ impl BadIssueSeeker { }; } fixme_idx = 0; - } else if self.report_fixme.is_enabled() && lower_case_c == FIX_ME_CHARS[fixme_idx] { + } else if is_enabled(self.report_fixme) && lower_case_c == FIX_ME_CHARS[fixme_idx] { // Exploit the fact that the character sets of todo and fixme // are disjoint by adding else. fixme_idx += 1; diff --git a/src/items.rs b/rustfmt-core/src/items.rs similarity index 99% rename from src/items.rs rename to rustfmt-core/src/items.rs index 510c96681b88..9f3b0a1e6b2e 100644 --- a/src/items.rs +++ b/rustfmt-core/src/items.rs @@ -13,6 +13,7 @@ use std::borrow::Cow; use std::cmp::min; +use config::lists::*; use syntax::{abi, ast, ptr, symbol}; use syntax::ast::{CrateSugar, ImplItem}; use syntax::codemap::{BytePos, Span}; @@ -24,8 +25,7 @@ use comment::{combine_strs_with_missing_comments, contains_comment, recover_comm use config::{BraceStyle, Config, Density, IndentStyle}; use expr::{format_expr, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, rewrite_call_inner, ExprType}; -use lists::{definitive_tactic, itemize_list, write_list, DefinitiveListTactic, ListFormatting, - ListItem, ListTactic, Separator, SeparatorPlace, SeparatorTactic}; +use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator}; use rewrite::{Rewrite, RewriteContext}; use shape::{Indent, Shape}; use spanned::Spanned; diff --git a/src/lib.rs b/rustfmt-core/src/lib.rs similarity index 99% rename from src/lib.rs rename to rustfmt-core/src/lib.rs index 6aca11ab3eeb..6f471d0167f9 100644 --- a/src/lib.rs +++ b/rustfmt-core/src/lib.rs @@ -19,10 +19,7 @@ extern crate diff; extern crate log; extern crate regex; extern crate rustc_errors as errors; -extern crate serde; -#[macro_use] -extern crate serde_derive; -extern crate serde_json; +extern crate rustfmt_config as config; extern crate syntax; extern crate term; extern crate unicode_segmentation; @@ -44,14 +41,13 @@ use syntax::parse::{self, ParseSess}; use checkstyle::{output_footer, output_header}; use comment::{CharClasses, FullCodeCharKind}; -pub use config::Config; -use filemap::FileMap; use issues::{BadIssueSeeker, Issue}; use shape::Indent; use utils::use_colored_tty; use visitor::{FmtVisitor, SnippetProvider}; -pub use self::summary::Summary; +pub use config::Config; +pub use config::summary::Summary; #[macro_use] mod utils; @@ -60,9 +56,7 @@ mod checkstyle; mod closures; pub mod codemap; mod comment; -pub mod config; mod expr; -pub mod file_lines; pub mod filemap; mod imports; mod issues; @@ -77,11 +71,15 @@ pub mod rustfmt_diff; mod shape; mod spanned; mod string; -mod summary; mod types; mod vertical; pub mod visitor; +// A map of the files of a crate, with their new content +pub type FileMap = Vec; + +pub type FileRecord = (FileName, String); + #[derive(Clone, Copy)] pub enum ErrorKind { // Line has exceeded character limit (found, maximum) diff --git a/src/lists.rs b/rustfmt-core/src/lists.rs similarity index 92% rename from src/lists.rs rename to rustfmt-core/src/lists.rs index aa1e0b430ef7..a67088042c8a 100644 --- a/src/lists.rs +++ b/rustfmt-core/src/lists.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +//! Format list-like expressions and items. + use std::cmp; use std::iter::Peekable; +use config::lists::*; use syntax::codemap::{BytePos, CodeMap}; use comment::{find_comment_end, rewrite_comment, FindUncommented}; @@ -19,44 +22,6 @@ use rewrite::RewriteContext; use shape::{Indent, Shape}; use utils::{count_newlines, first_line_width, last_line_width, mk_sp, starts_with_newline}; -/// Formatting tactic for lists. This will be cast down to a -/// `DefinitiveListTactic` depending on the number and length of the items and -/// their comments. -#[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub enum ListTactic { - // One item per row. - Vertical, - // All items on one row. - Horizontal, - // Try Horizontal layout, if that fails then vertical. - HorizontalVertical, - // HorizontalVertical with a soft limit of n characters. - LimitedHorizontalVertical(usize), - // Pack as many items as possible per row over (possibly) many rows. - Mixed, -} - -impl_enum_serialize_and_deserialize!(ListTactic, Vertical, Horizontal, HorizontalVertical, Mixed); - -#[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub enum SeparatorTactic { - Always, - Never, - Vertical, -} - -impl_enum_serialize_and_deserialize!(SeparatorTactic, Always, Never, Vertical); - -impl SeparatorTactic { - pub fn from_bool(b: bool) -> SeparatorTactic { - if b { - SeparatorTactic::Always - } else { - SeparatorTactic::Never - } - } -} - pub struct ListFormatting<'a> { pub tactic: DefinitiveListTactic, pub separator: &'a str, @@ -154,25 +119,6 @@ impl ListItem { } } -/// The definitive formatting tactic for lists. -#[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub enum DefinitiveListTactic { - Vertical, - Horizontal, - Mixed, - /// Special case tactic for `format!()`, `write!()` style macros. - SpecialMacro(usize), -} - -impl DefinitiveListTactic { - pub fn ends_with_newline(&self, indent_style: IndentStyle) -> bool { - match indent_style { - IndentStyle::Block => *self != DefinitiveListTactic::Horizontal, - IndentStyle::Visual => false, - } - } -} - /// The type of separator for lists. #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Separator { @@ -191,40 +137,6 @@ impl Separator { } } -/// Where to put separator. -#[derive(Eq, PartialEq, Debug, Copy, Clone)] -pub enum SeparatorPlace { - Front, - Back, -} - -impl_enum_serialize_and_deserialize!(SeparatorPlace, Front, Back); - -impl SeparatorPlace { - pub fn is_front(&self) -> bool { - *self == SeparatorPlace::Front - } - - pub fn is_back(&self) -> bool { - *self == SeparatorPlace::Back - } - - pub fn from_tactic( - default: SeparatorPlace, - tactic: DefinitiveListTactic, - sep: &str, - ) -> SeparatorPlace { - match tactic { - DefinitiveListTactic::Vertical => default, - _ => if sep == "," { - SeparatorPlace::Back - } else { - default - }, - } - } -} - pub fn definitive_tactic( items: I, tactic: ListTactic, diff --git a/src/macros.rs b/rustfmt-core/src/macros.rs similarity index 99% rename from src/macros.rs rename to rustfmt-core/src/macros.rs index 3abfe6239fd0..535a82c81de4 100644 --- a/src/macros.rs +++ b/rustfmt-core/src/macros.rs @@ -20,6 +20,8 @@ // and those with brackets will be formatted as array literals. use std::collections::HashMap; + +use config::lists::*; use syntax::ast; use syntax::codemap::{BytePos, Span}; use syntax::parse::new_parser_from_tts; @@ -33,8 +35,7 @@ use syntax::util::ThinVec; use codemap::SpanUtils; use comment::{contains_comment, remove_trailing_white_spaces, FindUncommented}; use expr::{rewrite_array, rewrite_call_inner}; -use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorPlace, - SeparatorTactic}; +use lists::{itemize_list, write_list, ListFormatting}; use rewrite::{Rewrite, RewriteContext}; use shape::{Indent, Shape}; use utils::{format_visibility, mk_sp}; diff --git a/src/missed_spans.rs b/rustfmt-core/src/missed_spans.rs similarity index 100% rename from src/missed_spans.rs rename to rustfmt-core/src/missed_spans.rs diff --git a/src/modules.rs b/rustfmt-core/src/modules.rs similarity index 100% rename from src/modules.rs rename to rustfmt-core/src/modules.rs diff --git a/src/patterns.rs b/rustfmt-core/src/patterns.rs similarity index 99% rename from src/patterns.rs rename to rustfmt-core/src/patterns.rs index 4719160061b4..dc20a6644ff5 100644 --- a/src/patterns.rs +++ b/rustfmt-core/src/patterns.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use config::lists::*; use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax}; use syntax::codemap::{self, BytePos, Span}; use syntax::ptr; @@ -17,7 +18,7 @@ use comment::FindUncommented; use expr::{can_be_overflowed_expr, rewrite_call_inner, rewrite_pair, rewrite_unary_prefix, wrap_struct_field, PairParts}; use lists::{itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape, - struct_lit_tactic, write_list, DefinitiveListTactic, SeparatorPlace, SeparatorTactic}; + struct_lit_tactic, write_list}; use macros::{rewrite_macro, MacroPosition}; use rewrite::{Rewrite, RewriteContext}; use shape::Shape; diff --git a/src/rewrite.rs b/rustfmt-core/src/rewrite.rs similarity index 100% rename from src/rewrite.rs rename to rustfmt-core/src/rewrite.rs diff --git a/src/rustfmt_diff.rs b/rustfmt-core/src/rustfmt_diff.rs similarity index 100% rename from src/rustfmt_diff.rs rename to rustfmt-core/src/rustfmt_diff.rs diff --git a/src/shape.rs b/rustfmt-core/src/shape.rs similarity index 100% rename from src/shape.rs rename to rustfmt-core/src/shape.rs diff --git a/src/spanned.rs b/rustfmt-core/src/spanned.rs similarity index 100% rename from src/spanned.rs rename to rustfmt-core/src/spanned.rs diff --git a/src/string.rs b/rustfmt-core/src/string.rs similarity index 100% rename from src/string.rs rename to rustfmt-core/src/string.rs diff --git a/src/types.rs b/rustfmt-core/src/types.rs similarity index 99% rename from src/types.rs rename to rustfmt-core/src/types.rs index a7472567a81b..f6f80ba312be 100644 --- a/src/types.rs +++ b/rustfmt-core/src/types.rs @@ -11,6 +11,7 @@ use std::iter::ExactSizeIterator; use std::ops::Deref; +use config::lists::*; use syntax::ast::{self, FunctionRetTy, Mutability}; use syntax::codemap::{self, BytePos, Span}; use syntax::print::pprust; @@ -20,8 +21,7 @@ use codemap::SpanUtils; use config::{IndentStyle, TypeDensity}; use expr::{rewrite_pair, rewrite_tuple, rewrite_unary_prefix, wrap_args_with_parens, PairParts}; use items::{format_generics_item_list, generics_shape_from_config}; -use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic, Separator, - SeparatorPlace, SeparatorTactic}; +use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}; use macros::{rewrite_macro, MacroPosition}; use rewrite::{Rewrite, RewriteContext}; use shape::Shape; diff --git a/src/utils.rs b/rustfmt-core/src/utils.rs similarity index 80% rename from src/utils.rs rename to rustfmt-core/src/utils.rs index 20f4fdfe6d0b..d1bb7e26f5ee 100644 --- a/src/utils.rs +++ b/rustfmt-core/src/utils.rs @@ -254,82 +254,6 @@ pub fn count_newlines(input: &str) -> usize { input.chars().filter(|&c| c == '\n').count() } -// Macro for deriving implementations of Serialize/Deserialize for enums -#[macro_export] -macro_rules! impl_enum_serialize_and_deserialize { - ( $e:ident, $( $x:ident ),* ) => { - impl ::serde::ser::Serialize for $e { - fn serialize(&self, serializer: S) -> Result - where S: ::serde::ser::Serializer - { - use serde::ser::Error; - - // We don't know whether the user of the macro has given us all options. - #[allow(unreachable_patterns)] - match *self { - $( - $e::$x => serializer.serialize_str(stringify!($x)), - )* - _ => { - Err(S::Error::custom(format!("Cannot serialize {:?}", self))) - } - } - } - } - - impl<'de> ::serde::de::Deserialize<'de> for $e { - fn deserialize(d: D) -> Result - where D: ::serde::Deserializer<'de> { - use serde::de::{Error, Visitor}; - use std::marker::PhantomData; - use std::fmt; - struct StringOnly(PhantomData); - impl<'de, T> Visitor<'de> for StringOnly - where T: ::serde::Deserializer<'de> { - type Value = String; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("string") - } - fn visit_str(self, value: &str) -> Result { - Ok(String::from(value)) - } - } - let s = d.deserialize_string(StringOnly::(PhantomData))?; - $( - if stringify!($x).eq_ignore_ascii_case(&s) { - return Ok($e::$x); - } - )* - static ALLOWED: &'static[&str] = &[$(stringify!($x),)*]; - Err(D::Error::unknown_variant(&s, ALLOWED)) - } - } - - impl ::std::str::FromStr for $e { - type Err = &'static str; - - fn from_str(s: &str) -> Result { - $( - if stringify!($x).eq_ignore_ascii_case(s) { - return Ok($e::$x); - } - )* - Err("Bad variant") - } - } - - impl ::config::ConfigType for $e { - fn doc_hint() -> String { - let mut variants = Vec::new(); - $( - variants.push(stringify!($x)); - )* - format!("[{}]", variants.join("|")) - } - } - }; -} - macro_rules! msg { ($($arg:tt)*) => ( match writeln!(&mut ::std::io::stderr(), $($arg)* ) { diff --git a/src/vertical.rs b/rustfmt-core/src/vertical.rs similarity index 99% rename from src/vertical.rs rename to rustfmt-core/src/vertical.rs index 2ccb5d813393..e7fc03d41b1c 100644 --- a/src/vertical.rs +++ b/rustfmt-core/src/vertical.rs @@ -12,6 +12,7 @@ use std::cmp; +use config::lists::*; use syntax::ast; use syntax::codemap::{BytePos, Span}; @@ -19,8 +20,7 @@ use codemap::SpanUtils; use comment::{combine_strs_with_missing_comments, contains_comment}; use expr::rewrite_field; use items::{rewrite_struct_field, rewrite_struct_field_prefix}; -use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, ListTactic, Separator, - SeparatorPlace}; +use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator}; use rewrite::{Rewrite, RewriteContext}; use shape::{Indent, Shape}; use spanned::Spanned; diff --git a/src/visitor.rs b/rustfmt-core/src/visitor.rs similarity index 99% rename from src/visitor.rs rename to rustfmt-core/src/visitor.rs index cd6c0740ee6d..0a0d59d0f02c 100644 --- a/src/visitor.rs +++ b/rustfmt-core/src/visitor.rs @@ -10,6 +10,7 @@ use std::cmp; +use config::lists::*; use syntax::{ast, visit}; use syntax::attr::{self, HasAttrs}; use syntax::codemap::{self, BytePos, CodeMap, Pos, Span}; @@ -23,8 +24,7 @@ use config::{BraceStyle, Config}; use expr::rewrite_literal; use items::{format_impl, format_trait, format_trait_alias, rewrite_associated_impl_type, rewrite_associated_type, rewrite_type_alias, FnSig, StaticParts, StructParts}; -use lists::{itemize_list, write_list, DefinitiveListTactic, ListFormatting, SeparatorPlace, - SeparatorTactic}; +use lists::{itemize_list, write_list, ListFormatting}; use macros::{rewrite_macro, rewrite_macro_def, MacroPosition}; use regex::Regex; use rewrite::{Rewrite, RewriteContext}; diff --git a/tests/config/disable_all_formatting.toml b/rustfmt-core/tests/config/disable_all_formatting.toml similarity index 100% rename from tests/config/disable_all_formatting.toml rename to rustfmt-core/tests/config/disable_all_formatting.toml diff --git a/tests/config/issue-1111.toml b/rustfmt-core/tests/config/issue-1111.toml similarity index 100% rename from tests/config/issue-1111.toml rename to rustfmt-core/tests/config/issue-1111.toml diff --git a/tests/config/small_tabs.toml b/rustfmt-core/tests/config/small_tabs.toml similarity index 100% rename from tests/config/small_tabs.toml rename to rustfmt-core/tests/config/small_tabs.toml diff --git a/tests/coverage/source/comments.rs b/rustfmt-core/tests/coverage/source/comments.rs similarity index 100% rename from tests/coverage/source/comments.rs rename to rustfmt-core/tests/coverage/source/comments.rs diff --git a/tests/coverage/target/comments.rs b/rustfmt-core/tests/coverage/target/comments.rs similarity index 100% rename from tests/coverage/target/comments.rs rename to rustfmt-core/tests/coverage/target/comments.rs diff --git a/tests/system.rs b/rustfmt-core/tests/lib.rs similarity index 97% rename from tests/system.rs rename to rustfmt-core/tests/lib.rs index 06bfa1418d14..be72cb8a9efc 100644 --- a/tests/system.rs +++ b/rustfmt-core/tests/lib.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rustc_private)] - #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex; -extern crate rustfmt_nightly as rustfmt; +extern crate rustfmt_config as config; +extern crate rustfmt_core as rustfmt; extern crate term; use std::collections::HashMap; @@ -26,8 +25,10 @@ use std::path::{Path, PathBuf}; use std::str::Chars; use rustfmt::*; -use rustfmt::config::{Color, Config, ReportTactic}; -use rustfmt::filemap::{write_system_newlines, FileMap}; +use config::{Color, Config, ReportTactic}; +use config::summary::Summary; +use config::file_lines::FileLines; +use rustfmt::filemap::write_system_newlines; use rustfmt::rustfmt_diff::*; const DIFF_CONTEXT_SIZE: usize = 3; @@ -186,10 +187,26 @@ fn idempotence_tests() { // no warnings are emitted. #[test] fn self_tests() { - let mut files = get_test_files(Path::new("src/bin"), false); - files.append(&mut get_test_files(Path::new("tests"), false)); - files.push(PathBuf::from("src/lib.rs")); - files.push(PathBuf::from("build.rs")); + let mut files = get_test_files(Path::new("tests"), false); + let bin_directories = vec![ + "cargo-fmt", + "git-rustfmt", + "rustfmt-bin", + "rustfmt-format-diff", + ]; + for dir in bin_directories { + let mut path = PathBuf::from(".."); + path.push(dir); + path.push("src/main.rs"); + files.push(path); + } + let lib_directories = vec!["rustfmt-core", "rustfmt-config"]; + for dir in lib_directories { + let mut path = PathBuf::from(".."); + path.push(dir); + path.push("src/lib.rs"); + files.push(path); + } let (reports, count, fails) = check_files(files); let mut warnings = 0; diff --git a/tests/source/assignment.rs b/rustfmt-core/tests/source/assignment.rs similarity index 100% rename from tests/source/assignment.rs rename to rustfmt-core/tests/source/assignment.rs diff --git a/tests/source/associated-types-bounds-wrapping.rs b/rustfmt-core/tests/source/associated-types-bounds-wrapping.rs similarity index 100% rename from tests/source/associated-types-bounds-wrapping.rs rename to rustfmt-core/tests/source/associated-types-bounds-wrapping.rs diff --git a/tests/source/attrib.rs b/rustfmt-core/tests/source/attrib.rs similarity index 100% rename from tests/source/attrib.rs rename to rustfmt-core/tests/source/attrib.rs diff --git a/tests/source/big-impl-rfc.rs b/rustfmt-core/tests/source/big-impl-rfc.rs similarity index 100% rename from tests/source/big-impl-rfc.rs rename to rustfmt-core/tests/source/big-impl-rfc.rs diff --git a/tests/source/big-impl.rs b/rustfmt-core/tests/source/big-impl.rs similarity index 100% rename from tests/source/big-impl.rs rename to rustfmt-core/tests/source/big-impl.rs diff --git a/tests/source/break-and-continue.rs b/rustfmt-core/tests/source/break-and-continue.rs similarity index 100% rename from tests/source/break-and-continue.rs rename to rustfmt-core/tests/source/break-and-continue.rs diff --git a/tests/source/catch.rs b/rustfmt-core/tests/source/catch.rs similarity index 100% rename from tests/source/catch.rs rename to rustfmt-core/tests/source/catch.rs diff --git a/tests/source/chains-indent-tabbed.rs b/rustfmt-core/tests/source/chains-indent-tabbed.rs similarity index 100% rename from tests/source/chains-indent-tabbed.rs rename to rustfmt-core/tests/source/chains-indent-tabbed.rs diff --git a/tests/source/chains-indent-visual.rs b/rustfmt-core/tests/source/chains-indent-visual.rs similarity index 100% rename from tests/source/chains-indent-visual.rs rename to rustfmt-core/tests/source/chains-indent-visual.rs diff --git a/tests/source/chains-visual.rs b/rustfmt-core/tests/source/chains-visual.rs similarity index 100% rename from tests/source/chains-visual.rs rename to rustfmt-core/tests/source/chains-visual.rs diff --git a/tests/source/chains.rs b/rustfmt-core/tests/source/chains.rs similarity index 100% rename from tests/source/chains.rs rename to rustfmt-core/tests/source/chains.rs diff --git a/tests/source/closure-block-inside-macro.rs b/rustfmt-core/tests/source/closure-block-inside-macro.rs similarity index 100% rename from tests/source/closure-block-inside-macro.rs rename to rustfmt-core/tests/source/closure-block-inside-macro.rs diff --git a/tests/source/closure.rs b/rustfmt-core/tests/source/closure.rs similarity index 100% rename from tests/source/closure.rs rename to rustfmt-core/tests/source/closure.rs diff --git a/tests/source/comment.rs b/rustfmt-core/tests/source/comment.rs similarity index 100% rename from tests/source/comment.rs rename to rustfmt-core/tests/source/comment.rs diff --git a/tests/source/comment2.rs b/rustfmt-core/tests/source/comment2.rs similarity index 100% rename from tests/source/comment2.rs rename to rustfmt-core/tests/source/comment2.rs diff --git a/tests/source/comment3.rs b/rustfmt-core/tests/source/comment3.rs similarity index 100% rename from tests/source/comment3.rs rename to rustfmt-core/tests/source/comment3.rs diff --git a/tests/source/comment4.rs b/rustfmt-core/tests/source/comment4.rs similarity index 100% rename from tests/source/comment4.rs rename to rustfmt-core/tests/source/comment4.rs diff --git a/tests/source/comment5.rs b/rustfmt-core/tests/source/comment5.rs similarity index 100% rename from tests/source/comment5.rs rename to rustfmt-core/tests/source/comment5.rs diff --git a/tests/source/comment_crlf_newline.rs b/rustfmt-core/tests/source/comment_crlf_newline.rs similarity index 100% rename from tests/source/comment_crlf_newline.rs rename to rustfmt-core/tests/source/comment_crlf_newline.rs diff --git a/tests/source/configs/blank_lines_lower_bound/1.rs b/rustfmt-core/tests/source/configs/blank_lines_lower_bound/1.rs similarity index 100% rename from tests/source/configs/blank_lines_lower_bound/1.rs rename to rustfmt-core/tests/source/configs/blank_lines_lower_bound/1.rs diff --git a/tests/source/configs/brace_style/fn_always_next_line.rs b/rustfmt-core/tests/source/configs/brace_style/fn_always_next_line.rs similarity index 100% rename from tests/source/configs/brace_style/fn_always_next_line.rs rename to rustfmt-core/tests/source/configs/brace_style/fn_always_next_line.rs diff --git a/tests/source/configs/brace_style/fn_prefer_same_line.rs b/rustfmt-core/tests/source/configs/brace_style/fn_prefer_same_line.rs similarity index 100% rename from tests/source/configs/brace_style/fn_prefer_same_line.rs rename to rustfmt-core/tests/source/configs/brace_style/fn_prefer_same_line.rs diff --git a/tests/source/configs/brace_style/fn_same_line_where.rs b/rustfmt-core/tests/source/configs/brace_style/fn_same_line_where.rs similarity index 100% rename from tests/source/configs/brace_style/fn_same_line_where.rs rename to rustfmt-core/tests/source/configs/brace_style/fn_same_line_where.rs diff --git a/tests/source/configs/brace_style/item_always_next_line.rs b/rustfmt-core/tests/source/configs/brace_style/item_always_next_line.rs similarity index 100% rename from tests/source/configs/brace_style/item_always_next_line.rs rename to rustfmt-core/tests/source/configs/brace_style/item_always_next_line.rs diff --git a/tests/source/configs/brace_style/item_prefer_same_line.rs b/rustfmt-core/tests/source/configs/brace_style/item_prefer_same_line.rs similarity index 100% rename from tests/source/configs/brace_style/item_prefer_same_line.rs rename to rustfmt-core/tests/source/configs/brace_style/item_prefer_same_line.rs diff --git a/tests/source/configs/brace_style/item_same_line_where.rs b/rustfmt-core/tests/source/configs/brace_style/item_same_line_where.rs similarity index 100% rename from tests/source/configs/brace_style/item_same_line_where.rs rename to rustfmt-core/tests/source/configs/brace_style/item_same_line_where.rs diff --git a/tests/source/configs/comment_width/above.rs b/rustfmt-core/tests/source/configs/comment_width/above.rs similarity index 100% rename from tests/source/configs/comment_width/above.rs rename to rustfmt-core/tests/source/configs/comment_width/above.rs diff --git a/tests/source/configs/comment_width/below.rs b/rustfmt-core/tests/source/configs/comment_width/below.rs similarity index 100% rename from tests/source/configs/comment_width/below.rs rename to rustfmt-core/tests/source/configs/comment_width/below.rs diff --git a/tests/source/configs/comment_width/ignore.rs b/rustfmt-core/tests/source/configs/comment_width/ignore.rs similarity index 100% rename from tests/source/configs/comment_width/ignore.rs rename to rustfmt-core/tests/source/configs/comment_width/ignore.rs diff --git a/tests/source/configs/condense_wildcard_suffixes/false.rs b/rustfmt-core/tests/source/configs/condense_wildcard_suffixes/false.rs similarity index 100% rename from tests/source/configs/condense_wildcard_suffixes/false.rs rename to rustfmt-core/tests/source/configs/condense_wildcard_suffixes/false.rs diff --git a/tests/source/configs/condense_wildcard_suffixes/true.rs b/rustfmt-core/tests/source/configs/condense_wildcard_suffixes/true.rs similarity index 100% rename from tests/source/configs/condense_wildcard_suffixes/true.rs rename to rustfmt-core/tests/source/configs/condense_wildcard_suffixes/true.rs diff --git a/tests/source/configs/control_brace_style/always_next_line.rs b/rustfmt-core/tests/source/configs/control_brace_style/always_next_line.rs similarity index 100% rename from tests/source/configs/control_brace_style/always_next_line.rs rename to rustfmt-core/tests/source/configs/control_brace_style/always_next_line.rs diff --git a/tests/source/configs/control_brace_style/always_same_line.rs b/rustfmt-core/tests/source/configs/control_brace_style/always_same_line.rs similarity index 100% rename from tests/source/configs/control_brace_style/always_same_line.rs rename to rustfmt-core/tests/source/configs/control_brace_style/always_same_line.rs diff --git a/tests/source/configs/control_brace_style/closing_next_line.rs b/rustfmt-core/tests/source/configs/control_brace_style/closing_next_line.rs similarity index 100% rename from tests/source/configs/control_brace_style/closing_next_line.rs rename to rustfmt-core/tests/source/configs/control_brace_style/closing_next_line.rs diff --git a/tests/source/configs/disable_all_formatting/false.rs b/rustfmt-core/tests/source/configs/disable_all_formatting/false.rs similarity index 100% rename from tests/source/configs/disable_all_formatting/false.rs rename to rustfmt-core/tests/source/configs/disable_all_formatting/false.rs diff --git a/tests/source/configs/disable_all_formatting/true.rs b/rustfmt-core/tests/source/configs/disable_all_formatting/true.rs similarity index 100% rename from tests/source/configs/disable_all_formatting/true.rs rename to rustfmt-core/tests/source/configs/disable_all_formatting/true.rs diff --git a/tests/source/configs/empty_item_single_line/false.rs b/rustfmt-core/tests/source/configs/empty_item_single_line/false.rs similarity index 100% rename from tests/source/configs/empty_item_single_line/false.rs rename to rustfmt-core/tests/source/configs/empty_item_single_line/false.rs diff --git a/tests/source/configs/empty_item_single_line/true.rs b/rustfmt-core/tests/source/configs/empty_item_single_line/true.rs similarity index 100% rename from tests/source/configs/empty_item_single_line/true.rs rename to rustfmt-core/tests/source/configs/empty_item_single_line/true.rs diff --git a/tests/source/configs/error_on_line_overflow/false.rs b/rustfmt-core/tests/source/configs/error_on_line_overflow/false.rs similarity index 100% rename from tests/source/configs/error_on_line_overflow/false.rs rename to rustfmt-core/tests/source/configs/error_on_line_overflow/false.rs diff --git a/tests/source/configs/fn_args_density/compressed.rs b/rustfmt-core/tests/source/configs/fn_args_density/compressed.rs similarity index 100% rename from tests/source/configs/fn_args_density/compressed.rs rename to rustfmt-core/tests/source/configs/fn_args_density/compressed.rs diff --git a/tests/source/configs/fn_args_density/tall.rs b/rustfmt-core/tests/source/configs/fn_args_density/tall.rs similarity index 100% rename from tests/source/configs/fn_args_density/tall.rs rename to rustfmt-core/tests/source/configs/fn_args_density/tall.rs diff --git a/tests/source/configs/fn_args_density/vertical.rs b/rustfmt-core/tests/source/configs/fn_args_density/vertical.rs similarity index 100% rename from tests/source/configs/fn_args_density/vertical.rs rename to rustfmt-core/tests/source/configs/fn_args_density/vertical.rs diff --git a/tests/source/configs/fn_single_line/false.rs b/rustfmt-core/tests/source/configs/fn_single_line/false.rs similarity index 100% rename from tests/source/configs/fn_single_line/false.rs rename to rustfmt-core/tests/source/configs/fn_single_line/false.rs diff --git a/tests/source/configs/fn_single_line/true.rs b/rustfmt-core/tests/source/configs/fn_single_line/true.rs similarity index 100% rename from tests/source/configs/fn_single_line/true.rs rename to rustfmt-core/tests/source/configs/fn_single_line/true.rs diff --git a/tests/source/configs/force_explicit_abi/false.rs b/rustfmt-core/tests/source/configs/force_explicit_abi/false.rs similarity index 100% rename from tests/source/configs/force_explicit_abi/false.rs rename to rustfmt-core/tests/source/configs/force_explicit_abi/false.rs diff --git a/tests/source/configs/force_explicit_abi/true.rs b/rustfmt-core/tests/source/configs/force_explicit_abi/true.rs similarity index 100% rename from tests/source/configs/force_explicit_abi/true.rs rename to rustfmt-core/tests/source/configs/force_explicit_abi/true.rs diff --git a/tests/source/configs/force_multiline_block/false.rs b/rustfmt-core/tests/source/configs/force_multiline_block/false.rs similarity index 100% rename from tests/source/configs/force_multiline_block/false.rs rename to rustfmt-core/tests/source/configs/force_multiline_block/false.rs diff --git a/tests/source/configs/force_multiline_block/true.rs b/rustfmt-core/tests/source/configs/force_multiline_block/true.rs similarity index 100% rename from tests/source/configs/force_multiline_block/true.rs rename to rustfmt-core/tests/source/configs/force_multiline_block/true.rs diff --git a/tests/source/configs/format_strings/false.rs b/rustfmt-core/tests/source/configs/format_strings/false.rs similarity index 100% rename from tests/source/configs/format_strings/false.rs rename to rustfmt-core/tests/source/configs/format_strings/false.rs diff --git a/tests/source/configs/format_strings/true.rs b/rustfmt-core/tests/source/configs/format_strings/true.rs similarity index 100% rename from tests/source/configs/format_strings/true.rs rename to rustfmt-core/tests/source/configs/format_strings/true.rs diff --git a/tests/source/configs/hard_tabs/false.rs b/rustfmt-core/tests/source/configs/hard_tabs/false.rs similarity index 100% rename from tests/source/configs/hard_tabs/false.rs rename to rustfmt-core/tests/source/configs/hard_tabs/false.rs diff --git a/tests/source/configs/hard_tabs/true.rs b/rustfmt-core/tests/source/configs/hard_tabs/true.rs similarity index 100% rename from tests/source/configs/hard_tabs/true.rs rename to rustfmt-core/tests/source/configs/hard_tabs/true.rs diff --git a/tests/source/configs/indent_style/block_args.rs b/rustfmt-core/tests/source/configs/indent_style/block_args.rs similarity index 100% rename from tests/source/configs/indent_style/block_args.rs rename to rustfmt-core/tests/source/configs/indent_style/block_args.rs diff --git a/tests/source/configs/indent_style/block_array.rs b/rustfmt-core/tests/source/configs/indent_style/block_array.rs similarity index 100% rename from tests/source/configs/indent_style/block_array.rs rename to rustfmt-core/tests/source/configs/indent_style/block_array.rs diff --git a/tests/source/configs/indent_style/block_call.rs b/rustfmt-core/tests/source/configs/indent_style/block_call.rs similarity index 100% rename from tests/source/configs/indent_style/block_call.rs rename to rustfmt-core/tests/source/configs/indent_style/block_call.rs diff --git a/tests/source/configs/indent_style/block_chain.rs b/rustfmt-core/tests/source/configs/indent_style/block_chain.rs similarity index 100% rename from tests/source/configs/indent_style/block_chain.rs rename to rustfmt-core/tests/source/configs/indent_style/block_chain.rs diff --git a/tests/source/configs/indent_style/block_generic.rs b/rustfmt-core/tests/source/configs/indent_style/block_generic.rs similarity index 100% rename from tests/source/configs/indent_style/block_generic.rs rename to rustfmt-core/tests/source/configs/indent_style/block_generic.rs diff --git a/tests/source/configs/indent_style/block_struct_lit.rs b/rustfmt-core/tests/source/configs/indent_style/block_struct_lit.rs similarity index 100% rename from tests/source/configs/indent_style/block_struct_lit.rs rename to rustfmt-core/tests/source/configs/indent_style/block_struct_lit.rs diff --git a/tests/source/configs/indent_style/block_trailing_comma_call.rs b/rustfmt-core/tests/source/configs/indent_style/block_trailing_comma_call.rs similarity index 100% rename from tests/source/configs/indent_style/block_trailing_comma_call.rs rename to rustfmt-core/tests/source/configs/indent_style/block_trailing_comma_call.rs diff --git a/tests/source/configs/indent_style/block_where_pred.rs b/rustfmt-core/tests/source/configs/indent_style/block_where_pred.rs similarity index 100% rename from tests/source/configs/indent_style/block_where_pred.rs rename to rustfmt-core/tests/source/configs/indent_style/block_where_pred.rs diff --git a/tests/source/configs/indent_style/default.rs b/rustfmt-core/tests/source/configs/indent_style/default.rs similarity index 100% rename from tests/source/configs/indent_style/default.rs rename to rustfmt-core/tests/source/configs/indent_style/default.rs diff --git a/tests/source/configs/indent_style/rfc_where.rs b/rustfmt-core/tests/source/configs/indent_style/rfc_where.rs similarity index 100% rename from tests/source/configs/indent_style/rfc_where.rs rename to rustfmt-core/tests/source/configs/indent_style/rfc_where.rs diff --git a/tests/source/configs/indent_style/visual_args.rs b/rustfmt-core/tests/source/configs/indent_style/visual_args.rs similarity index 100% rename from tests/source/configs/indent_style/visual_args.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_args.rs diff --git a/tests/source/configs/indent_style/visual_array.rs b/rustfmt-core/tests/source/configs/indent_style/visual_array.rs similarity index 100% rename from tests/source/configs/indent_style/visual_array.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_array.rs diff --git a/tests/source/configs/indent_style/visual_call.rs b/rustfmt-core/tests/source/configs/indent_style/visual_call.rs similarity index 100% rename from tests/source/configs/indent_style/visual_call.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_call.rs diff --git a/tests/source/configs/indent_style/visual_chain.rs b/rustfmt-core/tests/source/configs/indent_style/visual_chain.rs similarity index 100% rename from tests/source/configs/indent_style/visual_chain.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_chain.rs diff --git a/tests/source/configs/indent_style/visual_generics.rs b/rustfmt-core/tests/source/configs/indent_style/visual_generics.rs similarity index 100% rename from tests/source/configs/indent_style/visual_generics.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_generics.rs diff --git a/tests/source/configs/indent_style/visual_struct_lit.rs b/rustfmt-core/tests/source/configs/indent_style/visual_struct_lit.rs similarity index 100% rename from tests/source/configs/indent_style/visual_struct_lit.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_struct_lit.rs diff --git a/tests/source/configs/indent_style/visual_trailing_comma.rs b/rustfmt-core/tests/source/configs/indent_style/visual_trailing_comma.rs similarity index 100% rename from tests/source/configs/indent_style/visual_trailing_comma.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_trailing_comma.rs diff --git a/tests/source/configs/indent_style/visual_where_pred.rs b/rustfmt-core/tests/source/configs/indent_style/visual_where_pred.rs similarity index 100% rename from tests/source/configs/indent_style/visual_where_pred.rs rename to rustfmt-core/tests/source/configs/indent_style/visual_where_pred.rs diff --git a/tests/source/configs/match_arm_blocks/false.rs b/rustfmt-core/tests/source/configs/match_arm_blocks/false.rs similarity index 100% rename from tests/source/configs/match_arm_blocks/false.rs rename to rustfmt-core/tests/source/configs/match_arm_blocks/false.rs diff --git a/tests/source/configs/match_arm_blocks/true.rs b/rustfmt-core/tests/source/configs/match_arm_blocks/true.rs similarity index 100% rename from tests/source/configs/match_arm_blocks/true.rs rename to rustfmt-core/tests/source/configs/match_arm_blocks/true.rs diff --git a/tests/source/configs/match_block_trailing_comma/false.rs b/rustfmt-core/tests/source/configs/match_block_trailing_comma/false.rs similarity index 100% rename from tests/source/configs/match_block_trailing_comma/false.rs rename to rustfmt-core/tests/source/configs/match_block_trailing_comma/false.rs diff --git a/tests/source/configs/match_block_trailing_comma/true.rs b/rustfmt-core/tests/source/configs/match_block_trailing_comma/true.rs similarity index 100% rename from tests/source/configs/match_block_trailing_comma/true.rs rename to rustfmt-core/tests/source/configs/match_block_trailing_comma/true.rs diff --git a/tests/source/configs/merge_derives/true.rs b/rustfmt-core/tests/source/configs/merge_derives/true.rs similarity index 100% rename from tests/source/configs/merge_derives/true.rs rename to rustfmt-core/tests/source/configs/merge_derives/true.rs diff --git a/tests/source/configs/normalize_comments/false.rs b/rustfmt-core/tests/source/configs/normalize_comments/false.rs similarity index 100% rename from tests/source/configs/normalize_comments/false.rs rename to rustfmt-core/tests/source/configs/normalize_comments/false.rs diff --git a/tests/source/configs/normalize_comments/true.rs b/rustfmt-core/tests/source/configs/normalize_comments/true.rs similarity index 100% rename from tests/source/configs/normalize_comments/true.rs rename to rustfmt-core/tests/source/configs/normalize_comments/true.rs diff --git a/tests/source/configs/reorder_extern_crates/false.rs b/rustfmt-core/tests/source/configs/reorder_extern_crates/false.rs similarity index 100% rename from tests/source/configs/reorder_extern_crates/false.rs rename to rustfmt-core/tests/source/configs/reorder_extern_crates/false.rs diff --git a/tests/source/configs/reorder_extern_crates/true.rs b/rustfmt-core/tests/source/configs/reorder_extern_crates/true.rs similarity index 100% rename from tests/source/configs/reorder_extern_crates/true.rs rename to rustfmt-core/tests/source/configs/reorder_extern_crates/true.rs diff --git a/tests/source/configs/reorder_imported_names/false.rs b/rustfmt-core/tests/source/configs/reorder_imported_names/false.rs similarity index 100% rename from tests/source/configs/reorder_imported_names/false.rs rename to rustfmt-core/tests/source/configs/reorder_imported_names/false.rs diff --git a/tests/source/configs/reorder_imported_names/true.rs b/rustfmt-core/tests/source/configs/reorder_imported_names/true.rs similarity index 100% rename from tests/source/configs/reorder_imported_names/true.rs rename to rustfmt-core/tests/source/configs/reorder_imported_names/true.rs diff --git a/tests/source/configs/reorder_imports/false.rs b/rustfmt-core/tests/source/configs/reorder_imports/false.rs similarity index 100% rename from tests/source/configs/reorder_imports/false.rs rename to rustfmt-core/tests/source/configs/reorder_imports/false.rs diff --git a/tests/source/configs/reorder_imports/true.rs b/rustfmt-core/tests/source/configs/reorder_imports/true.rs similarity index 100% rename from tests/source/configs/reorder_imports/true.rs rename to rustfmt-core/tests/source/configs/reorder_imports/true.rs diff --git a/tests/source/configs/reorder_imports_in_group/false.rs b/rustfmt-core/tests/source/configs/reorder_imports_in_group/false.rs similarity index 100% rename from tests/source/configs/reorder_imports_in_group/false.rs rename to rustfmt-core/tests/source/configs/reorder_imports_in_group/false.rs diff --git a/tests/source/configs/reorder_imports_in_group/true.rs b/rustfmt-core/tests/source/configs/reorder_imports_in_group/true.rs similarity index 100% rename from tests/source/configs/reorder_imports_in_group/true.rs rename to rustfmt-core/tests/source/configs/reorder_imports_in_group/true.rs diff --git a/tests/source/configs/reorder_modules/dolor/mod.rs b/rustfmt-core/tests/source/configs/reorder_modules/dolor/mod.rs similarity index 100% rename from tests/source/configs/reorder_modules/dolor/mod.rs rename to rustfmt-core/tests/source/configs/reorder_modules/dolor/mod.rs diff --git a/tests/source/configs/reorder_modules/false.rs b/rustfmt-core/tests/source/configs/reorder_modules/false.rs similarity index 100% rename from tests/source/configs/reorder_modules/false.rs rename to rustfmt-core/tests/source/configs/reorder_modules/false.rs diff --git a/tests/source/configs/reorder_modules/ipsum/mod.rs b/rustfmt-core/tests/source/configs/reorder_modules/ipsum/mod.rs similarity index 100% rename from tests/source/configs/reorder_modules/ipsum/mod.rs rename to rustfmt-core/tests/source/configs/reorder_modules/ipsum/mod.rs diff --git a/tests/source/configs/reorder_modules/lorem/mod.rs b/rustfmt-core/tests/source/configs/reorder_modules/lorem/mod.rs similarity index 100% rename from tests/source/configs/reorder_modules/lorem/mod.rs rename to rustfmt-core/tests/source/configs/reorder_modules/lorem/mod.rs diff --git a/tests/source/configs/reorder_modules/sit/mod.rs b/rustfmt-core/tests/source/configs/reorder_modules/sit/mod.rs similarity index 100% rename from tests/source/configs/reorder_modules/sit/mod.rs rename to rustfmt-core/tests/source/configs/reorder_modules/sit/mod.rs diff --git a/tests/source/configs/reorder_modules/true.rs b/rustfmt-core/tests/source/configs/reorder_modules/true.rs similarity index 100% rename from tests/source/configs/reorder_modules/true.rs rename to rustfmt-core/tests/source/configs/reorder_modules/true.rs diff --git a/tests/source/configs/space_before_colon/true.rs b/rustfmt-core/tests/source/configs/space_before_colon/true.rs similarity index 100% rename from tests/source/configs/space_before_colon/true.rs rename to rustfmt-core/tests/source/configs/space_before_colon/true.rs diff --git a/tests/source/configs/spaces_around_ranges/false.rs b/rustfmt-core/tests/source/configs/spaces_around_ranges/false.rs similarity index 100% rename from tests/source/configs/spaces_around_ranges/false.rs rename to rustfmt-core/tests/source/configs/spaces_around_ranges/false.rs diff --git a/tests/source/configs/spaces_around_ranges/true.rs b/rustfmt-core/tests/source/configs/spaces_around_ranges/true.rs similarity index 100% rename from tests/source/configs/spaces_around_ranges/true.rs rename to rustfmt-core/tests/source/configs/spaces_around_ranges/true.rs diff --git a/tests/source/configs/spaces_within_parens_and_brackets/false.rs b/rustfmt-core/tests/source/configs/spaces_within_parens_and_brackets/false.rs similarity index 100% rename from tests/source/configs/spaces_within_parens_and_brackets/false.rs rename to rustfmt-core/tests/source/configs/spaces_within_parens_and_brackets/false.rs diff --git a/tests/source/configs/spaces_within_parens_and_brackets/true.rs b/rustfmt-core/tests/source/configs/spaces_within_parens_and_brackets/true.rs similarity index 100% rename from tests/source/configs/spaces_within_parens_and_brackets/true.rs rename to rustfmt-core/tests/source/configs/spaces_within_parens_and_brackets/true.rs diff --git a/tests/source/configs/struct_field_align_threshold/20.rs b/rustfmt-core/tests/source/configs/struct_field_align_threshold/20.rs similarity index 100% rename from tests/source/configs/struct_field_align_threshold/20.rs rename to rustfmt-core/tests/source/configs/struct_field_align_threshold/20.rs diff --git a/tests/source/configs/struct_lit_single_line/false.rs b/rustfmt-core/tests/source/configs/struct_lit_single_line/false.rs similarity index 100% rename from tests/source/configs/struct_lit_single_line/false.rs rename to rustfmt-core/tests/source/configs/struct_lit_single_line/false.rs diff --git a/tests/source/configs/tab_spaces/2.rs b/rustfmt-core/tests/source/configs/tab_spaces/2.rs similarity index 100% rename from tests/source/configs/tab_spaces/2.rs rename to rustfmt-core/tests/source/configs/tab_spaces/2.rs diff --git a/tests/source/configs/tab_spaces/4.rs b/rustfmt-core/tests/source/configs/tab_spaces/4.rs similarity index 100% rename from tests/source/configs/tab_spaces/4.rs rename to rustfmt-core/tests/source/configs/tab_spaces/4.rs diff --git a/tests/source/configs/trailing_comma/always.rs b/rustfmt-core/tests/source/configs/trailing_comma/always.rs similarity index 100% rename from tests/source/configs/trailing_comma/always.rs rename to rustfmt-core/tests/source/configs/trailing_comma/always.rs diff --git a/tests/source/configs/trailing_comma/never.rs b/rustfmt-core/tests/source/configs/trailing_comma/never.rs similarity index 100% rename from tests/source/configs/trailing_comma/never.rs rename to rustfmt-core/tests/source/configs/trailing_comma/never.rs diff --git a/tests/source/configs/trailing_comma/vertical.rs b/rustfmt-core/tests/source/configs/trailing_comma/vertical.rs similarity index 100% rename from tests/source/configs/trailing_comma/vertical.rs rename to rustfmt-core/tests/source/configs/trailing_comma/vertical.rs diff --git a/tests/source/configs/type_punctuation_density/compressed.rs b/rustfmt-core/tests/source/configs/type_punctuation_density/compressed.rs similarity index 100% rename from tests/source/configs/type_punctuation_density/compressed.rs rename to rustfmt-core/tests/source/configs/type_punctuation_density/compressed.rs diff --git a/tests/source/configs/type_punctuation_density/wide.rs b/rustfmt-core/tests/source/configs/type_punctuation_density/wide.rs similarity index 100% rename from tests/source/configs/type_punctuation_density/wide.rs rename to rustfmt-core/tests/source/configs/type_punctuation_density/wide.rs diff --git a/tests/source/configs/use_field_init_shorthand/false.rs b/rustfmt-core/tests/source/configs/use_field_init_shorthand/false.rs similarity index 100% rename from tests/source/configs/use_field_init_shorthand/false.rs rename to rustfmt-core/tests/source/configs/use_field_init_shorthand/false.rs diff --git a/tests/source/configs/use_field_init_shorthand/true.rs b/rustfmt-core/tests/source/configs/use_field_init_shorthand/true.rs similarity index 100% rename from tests/source/configs/use_field_init_shorthand/true.rs rename to rustfmt-core/tests/source/configs/use_field_init_shorthand/true.rs diff --git a/tests/source/configs/use_try_shorthand/false.rs b/rustfmt-core/tests/source/configs/use_try_shorthand/false.rs similarity index 100% rename from tests/source/configs/use_try_shorthand/false.rs rename to rustfmt-core/tests/source/configs/use_try_shorthand/false.rs diff --git a/tests/source/configs/use_try_shorthand/true.rs b/rustfmt-core/tests/source/configs/use_try_shorthand/true.rs similarity index 100% rename from tests/source/configs/use_try_shorthand/true.rs rename to rustfmt-core/tests/source/configs/use_try_shorthand/true.rs diff --git a/tests/source/configs/where_single_line/true.rs b/rustfmt-core/tests/source/configs/where_single_line/true.rs similarity index 100% rename from tests/source/configs/where_single_line/true.rs rename to rustfmt-core/tests/source/configs/where_single_line/true.rs diff --git a/tests/source/configs/wrap_comments/false.rs b/rustfmt-core/tests/source/configs/wrap_comments/false.rs similarity index 100% rename from tests/source/configs/wrap_comments/false.rs rename to rustfmt-core/tests/source/configs/wrap_comments/false.rs diff --git a/tests/source/configs/wrap_comments/true.rs b/rustfmt-core/tests/source/configs/wrap_comments/true.rs similarity index 100% rename from tests/source/configs/wrap_comments/true.rs rename to rustfmt-core/tests/source/configs/wrap_comments/true.rs diff --git a/tests/source/control-brace-style-always-next-line.rs b/rustfmt-core/tests/source/control-brace-style-always-next-line.rs similarity index 100% rename from tests/source/control-brace-style-always-next-line.rs rename to rustfmt-core/tests/source/control-brace-style-always-next-line.rs diff --git a/tests/source/control-brace-style-always-same-line.rs b/rustfmt-core/tests/source/control-brace-style-always-same-line.rs similarity index 100% rename from tests/source/control-brace-style-always-same-line.rs rename to rustfmt-core/tests/source/control-brace-style-always-same-line.rs diff --git a/tests/source/doc.rs b/rustfmt-core/tests/source/doc.rs similarity index 100% rename from tests/source/doc.rs rename to rustfmt-core/tests/source/doc.rs diff --git a/tests/source/else-if-brace-style-always-next-line.rs b/rustfmt-core/tests/source/else-if-brace-style-always-next-line.rs similarity index 100% rename from tests/source/else-if-brace-style-always-next-line.rs rename to rustfmt-core/tests/source/else-if-brace-style-always-next-line.rs diff --git a/tests/source/else-if-brace-style-always-same-line.rs b/rustfmt-core/tests/source/else-if-brace-style-always-same-line.rs similarity index 100% rename from tests/source/else-if-brace-style-always-same-line.rs rename to rustfmt-core/tests/source/else-if-brace-style-always-same-line.rs diff --git a/tests/source/else-if-brace-style-closing-next-line.rs b/rustfmt-core/tests/source/else-if-brace-style-closing-next-line.rs similarity index 100% rename from tests/source/else-if-brace-style-closing-next-line.rs rename to rustfmt-core/tests/source/else-if-brace-style-closing-next-line.rs diff --git a/tests/source/empty_file.rs b/rustfmt-core/tests/source/empty_file.rs similarity index 100% rename from tests/source/empty_file.rs rename to rustfmt-core/tests/source/empty_file.rs diff --git a/tests/source/enum.rs b/rustfmt-core/tests/source/enum.rs similarity index 100% rename from tests/source/enum.rs rename to rustfmt-core/tests/source/enum.rs diff --git a/tests/source/expr-block.rs b/rustfmt-core/tests/source/expr-block.rs similarity index 100% rename from tests/source/expr-block.rs rename to rustfmt-core/tests/source/expr-block.rs diff --git a/tests/source/expr.rs b/rustfmt-core/tests/source/expr.rs similarity index 100% rename from tests/source/expr.rs rename to rustfmt-core/tests/source/expr.rs diff --git a/tests/source/extern.rs b/rustfmt-core/tests/source/extern.rs similarity index 100% rename from tests/source/extern.rs rename to rustfmt-core/tests/source/extern.rs diff --git a/tests/source/extern_not_explicit.rs b/rustfmt-core/tests/source/extern_not_explicit.rs similarity index 100% rename from tests/source/extern_not_explicit.rs rename to rustfmt-core/tests/source/extern_not_explicit.rs diff --git a/tests/source/file-lines-1.rs b/rustfmt-core/tests/source/file-lines-1.rs similarity index 100% rename from tests/source/file-lines-1.rs rename to rustfmt-core/tests/source/file-lines-1.rs diff --git a/tests/source/file-lines-2.rs b/rustfmt-core/tests/source/file-lines-2.rs similarity index 100% rename from tests/source/file-lines-2.rs rename to rustfmt-core/tests/source/file-lines-2.rs diff --git a/tests/source/file-lines-3.rs b/rustfmt-core/tests/source/file-lines-3.rs similarity index 100% rename from tests/source/file-lines-3.rs rename to rustfmt-core/tests/source/file-lines-3.rs diff --git a/tests/source/file-lines-4.rs b/rustfmt-core/tests/source/file-lines-4.rs similarity index 100% rename from tests/source/file-lines-4.rs rename to rustfmt-core/tests/source/file-lines-4.rs diff --git a/tests/source/file-lines-5.rs b/rustfmt-core/tests/source/file-lines-5.rs similarity index 100% rename from tests/source/file-lines-5.rs rename to rustfmt-core/tests/source/file-lines-5.rs diff --git a/tests/source/file-lines-6.rs b/rustfmt-core/tests/source/file-lines-6.rs similarity index 100% rename from tests/source/file-lines-6.rs rename to rustfmt-core/tests/source/file-lines-6.rs diff --git a/tests/source/file-lines-item.rs b/rustfmt-core/tests/source/file-lines-item.rs similarity index 100% rename from tests/source/file-lines-item.rs rename to rustfmt-core/tests/source/file-lines-item.rs diff --git a/tests/source/fn-custom-2.rs b/rustfmt-core/tests/source/fn-custom-2.rs similarity index 100% rename from tests/source/fn-custom-2.rs rename to rustfmt-core/tests/source/fn-custom-2.rs diff --git a/tests/source/fn-custom-3.rs b/rustfmt-core/tests/source/fn-custom-3.rs similarity index 100% rename from tests/source/fn-custom-3.rs rename to rustfmt-core/tests/source/fn-custom-3.rs diff --git a/tests/source/fn-custom-4.rs b/rustfmt-core/tests/source/fn-custom-4.rs similarity index 100% rename from tests/source/fn-custom-4.rs rename to rustfmt-core/tests/source/fn-custom-4.rs diff --git a/tests/source/fn-custom-6.rs b/rustfmt-core/tests/source/fn-custom-6.rs similarity index 100% rename from tests/source/fn-custom-6.rs rename to rustfmt-core/tests/source/fn-custom-6.rs diff --git a/tests/source/fn-custom-7.rs b/rustfmt-core/tests/source/fn-custom-7.rs similarity index 100% rename from tests/source/fn-custom-7.rs rename to rustfmt-core/tests/source/fn-custom-7.rs diff --git a/tests/source/fn-custom-8.rs b/rustfmt-core/tests/source/fn-custom-8.rs similarity index 100% rename from tests/source/fn-custom-8.rs rename to rustfmt-core/tests/source/fn-custom-8.rs diff --git a/tests/source/fn-custom.rs b/rustfmt-core/tests/source/fn-custom.rs similarity index 100% rename from tests/source/fn-custom.rs rename to rustfmt-core/tests/source/fn-custom.rs diff --git a/tests/source/fn-simple.rs b/rustfmt-core/tests/source/fn-simple.rs similarity index 100% rename from tests/source/fn-simple.rs rename to rustfmt-core/tests/source/fn-simple.rs diff --git a/tests/source/fn-single-line.rs b/rustfmt-core/tests/source/fn-single-line.rs similarity index 100% rename from tests/source/fn-single-line.rs rename to rustfmt-core/tests/source/fn-single-line.rs diff --git a/tests/source/fn_args_density-vertical.rs b/rustfmt-core/tests/source/fn_args_density-vertical.rs similarity index 100% rename from tests/source/fn_args_density-vertical.rs rename to rustfmt-core/tests/source/fn_args_density-vertical.rs diff --git a/tests/source/fn_args_indent-block.rs b/rustfmt-core/tests/source/fn_args_indent-block.rs similarity index 100% rename from tests/source/fn_args_indent-block.rs rename to rustfmt-core/tests/source/fn_args_indent-block.rs diff --git a/tests/source/hard-tabs.rs b/rustfmt-core/tests/source/hard-tabs.rs similarity index 100% rename from tests/source/hard-tabs.rs rename to rustfmt-core/tests/source/hard-tabs.rs diff --git a/tests/source/hello.rs b/rustfmt-core/tests/source/hello.rs similarity index 100% rename from tests/source/hello.rs rename to rustfmt-core/tests/source/hello.rs diff --git a/tests/source/hello2.rs b/rustfmt-core/tests/source/hello2.rs similarity index 100% rename from tests/source/hello2.rs rename to rustfmt-core/tests/source/hello2.rs diff --git a/tests/source/immovable_generators.rs b/rustfmt-core/tests/source/immovable_generators.rs similarity index 100% rename from tests/source/immovable_generators.rs rename to rustfmt-core/tests/source/immovable_generators.rs diff --git a/tests/source/impls.rs b/rustfmt-core/tests/source/impls.rs similarity index 100% rename from tests/source/impls.rs rename to rustfmt-core/tests/source/impls.rs diff --git a/tests/source/imports-reorder-lines-and-items.rs b/rustfmt-core/tests/source/imports-reorder-lines-and-items.rs similarity index 100% rename from tests/source/imports-reorder-lines-and-items.rs rename to rustfmt-core/tests/source/imports-reorder-lines-and-items.rs diff --git a/tests/source/imports-reorder-lines.rs b/rustfmt-core/tests/source/imports-reorder-lines.rs similarity index 100% rename from tests/source/imports-reorder-lines.rs rename to rustfmt-core/tests/source/imports-reorder-lines.rs diff --git a/tests/source/imports-reorder.rs b/rustfmt-core/tests/source/imports-reorder.rs similarity index 100% rename from tests/source/imports-reorder.rs rename to rustfmt-core/tests/source/imports-reorder.rs diff --git a/tests/source/imports.rs b/rustfmt-core/tests/source/imports.rs similarity index 100% rename from tests/source/imports.rs rename to rustfmt-core/tests/source/imports.rs diff --git a/tests/source/issue-1021.rs b/rustfmt-core/tests/source/issue-1021.rs similarity index 100% rename from tests/source/issue-1021.rs rename to rustfmt-core/tests/source/issue-1021.rs diff --git a/tests/source/issue-1049.rs b/rustfmt-core/tests/source/issue-1049.rs similarity index 100% rename from tests/source/issue-1049.rs rename to rustfmt-core/tests/source/issue-1049.rs diff --git a/tests/source/issue-1111.rs b/rustfmt-core/tests/source/issue-1111.rs similarity index 100% rename from tests/source/issue-1111.rs rename to rustfmt-core/tests/source/issue-1111.rs diff --git a/tests/source/issue-1120.rs b/rustfmt-core/tests/source/issue-1120.rs similarity index 100% rename from tests/source/issue-1120.rs rename to rustfmt-core/tests/source/issue-1120.rs diff --git a/tests/source/issue-1124.rs b/rustfmt-core/tests/source/issue-1124.rs similarity index 100% rename from tests/source/issue-1124.rs rename to rustfmt-core/tests/source/issue-1124.rs diff --git a/tests/source/issue-1127.rs b/rustfmt-core/tests/source/issue-1127.rs similarity index 100% rename from tests/source/issue-1127.rs rename to rustfmt-core/tests/source/issue-1127.rs diff --git a/tests/source/issue-1158.rs b/rustfmt-core/tests/source/issue-1158.rs similarity index 100% rename from tests/source/issue-1158.rs rename to rustfmt-core/tests/source/issue-1158.rs diff --git a/tests/source/issue-1177.rs b/rustfmt-core/tests/source/issue-1177.rs similarity index 100% rename from tests/source/issue-1177.rs rename to rustfmt-core/tests/source/issue-1177.rs diff --git a/tests/source/issue-1192.rs b/rustfmt-core/tests/source/issue-1192.rs similarity index 100% rename from tests/source/issue-1192.rs rename to rustfmt-core/tests/source/issue-1192.rs diff --git a/tests/source/issue-1211.rs b/rustfmt-core/tests/source/issue-1211.rs similarity index 100% rename from tests/source/issue-1211.rs rename to rustfmt-core/tests/source/issue-1211.rs diff --git a/tests/source/issue-1216.rs b/rustfmt-core/tests/source/issue-1216.rs similarity index 100% rename from tests/source/issue-1216.rs rename to rustfmt-core/tests/source/issue-1216.rs diff --git a/tests/source/issue-1239.rs b/rustfmt-core/tests/source/issue-1239.rs similarity index 100% rename from tests/source/issue-1239.rs rename to rustfmt-core/tests/source/issue-1239.rs diff --git a/tests/source/issue-1278.rs b/rustfmt-core/tests/source/issue-1278.rs similarity index 100% rename from tests/source/issue-1278.rs rename to rustfmt-core/tests/source/issue-1278.rs diff --git a/tests/source/issue-1350.rs b/rustfmt-core/tests/source/issue-1350.rs similarity index 100% rename from tests/source/issue-1350.rs rename to rustfmt-core/tests/source/issue-1350.rs diff --git a/tests/source/issue-1366.rs b/rustfmt-core/tests/source/issue-1366.rs similarity index 100% rename from tests/source/issue-1366.rs rename to rustfmt-core/tests/source/issue-1366.rs diff --git a/tests/source/issue-1468.rs b/rustfmt-core/tests/source/issue-1468.rs similarity index 100% rename from tests/source/issue-1468.rs rename to rustfmt-core/tests/source/issue-1468.rs diff --git a/tests/source/issue-1693.rs b/rustfmt-core/tests/source/issue-1693.rs similarity index 100% rename from tests/source/issue-1693.rs rename to rustfmt-core/tests/source/issue-1693.rs diff --git a/tests/source/issue-1800.rs b/rustfmt-core/tests/source/issue-1800.rs similarity index 100% rename from tests/source/issue-1800.rs rename to rustfmt-core/tests/source/issue-1800.rs diff --git a/tests/source/issue-1914.rs b/rustfmt-core/tests/source/issue-1914.rs similarity index 100% rename from tests/source/issue-1914.rs rename to rustfmt-core/tests/source/issue-1914.rs diff --git a/tests/source/issue-2025.rs b/rustfmt-core/tests/source/issue-2025.rs similarity index 100% rename from tests/source/issue-2025.rs rename to rustfmt-core/tests/source/issue-2025.rs diff --git a/tests/source/issue-2111.rs b/rustfmt-core/tests/source/issue-2111.rs similarity index 100% rename from tests/source/issue-2111.rs rename to rustfmt-core/tests/source/issue-2111.rs diff --git a/tests/source/issue-2164.rs b/rustfmt-core/tests/source/issue-2164.rs similarity index 100% rename from tests/source/issue-2164.rs rename to rustfmt-core/tests/source/issue-2164.rs diff --git a/tests/source/issue-2179.rs b/rustfmt-core/tests/source/issue-2179.rs similarity index 100% rename from tests/source/issue-2179.rs rename to rustfmt-core/tests/source/issue-2179.rs diff --git a/tests/source/issue-2256.rs b/rustfmt-core/tests/source/issue-2256.rs similarity index 100% rename from tests/source/issue-2256.rs rename to rustfmt-core/tests/source/issue-2256.rs diff --git a/tests/source/issue-2342.rs b/rustfmt-core/tests/source/issue-2342.rs similarity index 100% rename from tests/source/issue-2342.rs rename to rustfmt-core/tests/source/issue-2342.rs diff --git a/tests/source/issue-447.rs b/rustfmt-core/tests/source/issue-447.rs similarity index 100% rename from tests/source/issue-447.rs rename to rustfmt-core/tests/source/issue-447.rs diff --git a/tests/source/issue-510.rs b/rustfmt-core/tests/source/issue-510.rs similarity index 100% rename from tests/source/issue-510.rs rename to rustfmt-core/tests/source/issue-510.rs diff --git a/tests/source/issue-811.rs b/rustfmt-core/tests/source/issue-811.rs similarity index 100% rename from tests/source/issue-811.rs rename to rustfmt-core/tests/source/issue-811.rs diff --git a/tests/source/issue-850.rs b/rustfmt-core/tests/source/issue-850.rs similarity index 100% rename from tests/source/issue-850.rs rename to rustfmt-core/tests/source/issue-850.rs diff --git a/tests/source/issue-855.rs b/rustfmt-core/tests/source/issue-855.rs similarity index 100% rename from tests/source/issue-855.rs rename to rustfmt-core/tests/source/issue-855.rs diff --git a/tests/source/issue-913.rs b/rustfmt-core/tests/source/issue-913.rs similarity index 100% rename from tests/source/issue-913.rs rename to rustfmt-core/tests/source/issue-913.rs diff --git a/tests/source/issue-945.rs b/rustfmt-core/tests/source/issue-945.rs similarity index 100% rename from tests/source/issue-945.rs rename to rustfmt-core/tests/source/issue-945.rs diff --git a/tests/source/issue-977.rs b/rustfmt-core/tests/source/issue-977.rs similarity index 100% rename from tests/source/issue-977.rs rename to rustfmt-core/tests/source/issue-977.rs diff --git a/tests/source/item-brace-style-always-next-line.rs b/rustfmt-core/tests/source/item-brace-style-always-next-line.rs similarity index 100% rename from tests/source/item-brace-style-always-next-line.rs rename to rustfmt-core/tests/source/item-brace-style-always-next-line.rs diff --git a/tests/source/item-brace-style-prefer-same-line.rs b/rustfmt-core/tests/source/item-brace-style-prefer-same-line.rs similarity index 100% rename from tests/source/item-brace-style-prefer-same-line.rs rename to rustfmt-core/tests/source/item-brace-style-prefer-same-line.rs diff --git a/tests/source/item-brace-style-same-line-where.rs b/rustfmt-core/tests/source/item-brace-style-same-line-where.rs similarity index 100% rename from tests/source/item-brace-style-same-line-where.rs rename to rustfmt-core/tests/source/item-brace-style-same-line-where.rs diff --git a/tests/source/large-block.rs b/rustfmt-core/tests/source/large-block.rs similarity index 100% rename from tests/source/large-block.rs rename to rustfmt-core/tests/source/large-block.rs diff --git a/tests/source/large_vec.rs b/rustfmt-core/tests/source/large_vec.rs similarity index 100% rename from tests/source/large_vec.rs rename to rustfmt-core/tests/source/large_vec.rs diff --git a/tests/source/long-match-arms-brace-newline.rs b/rustfmt-core/tests/source/long-match-arms-brace-newline.rs similarity index 100% rename from tests/source/long-match-arms-brace-newline.rs rename to rustfmt-core/tests/source/long-match-arms-brace-newline.rs diff --git a/tests/source/long_field_access.rs b/rustfmt-core/tests/source/long_field_access.rs similarity index 100% rename from tests/source/long_field_access.rs rename to rustfmt-core/tests/source/long_field_access.rs diff --git a/tests/source/loop.rs b/rustfmt-core/tests/source/loop.rs similarity index 100% rename from tests/source/loop.rs rename to rustfmt-core/tests/source/loop.rs diff --git a/tests/source/macro_not_expr.rs b/rustfmt-core/tests/source/macro_not_expr.rs similarity index 100% rename from tests/source/macro_not_expr.rs rename to rustfmt-core/tests/source/macro_not_expr.rs diff --git a/tests/source/macro_rules.rs b/rustfmt-core/tests/source/macro_rules.rs similarity index 100% rename from tests/source/macro_rules.rs rename to rustfmt-core/tests/source/macro_rules.rs diff --git a/tests/source/macros.rs b/rustfmt-core/tests/source/macros.rs similarity index 100% rename from tests/source/macros.rs rename to rustfmt-core/tests/source/macros.rs diff --git a/tests/source/match-block-trailing-comma.rs b/rustfmt-core/tests/source/match-block-trailing-comma.rs similarity index 100% rename from tests/source/match-block-trailing-comma.rs rename to rustfmt-core/tests/source/match-block-trailing-comma.rs diff --git a/tests/source/match-nowrap-trailing-comma.rs b/rustfmt-core/tests/source/match-nowrap-trailing-comma.rs similarity index 100% rename from tests/source/match-nowrap-trailing-comma.rs rename to rustfmt-core/tests/source/match-nowrap-trailing-comma.rs diff --git a/tests/source/match-nowrap.rs b/rustfmt-core/tests/source/match-nowrap.rs similarity index 100% rename from tests/source/match-nowrap.rs rename to rustfmt-core/tests/source/match-nowrap.rs diff --git a/tests/source/match.rs b/rustfmt-core/tests/source/match.rs similarity index 100% rename from tests/source/match.rs rename to rustfmt-core/tests/source/match.rs diff --git a/tests/source/max-line-length-in-chars.rs b/rustfmt-core/tests/source/max-line-length-in-chars.rs similarity index 100% rename from tests/source/max-line-length-in-chars.rs rename to rustfmt-core/tests/source/max-line-length-in-chars.rs diff --git a/tests/source/mod-1.rs b/rustfmt-core/tests/source/mod-1.rs similarity index 100% rename from tests/source/mod-1.rs rename to rustfmt-core/tests/source/mod-1.rs diff --git a/tests/source/mod-2.rs b/rustfmt-core/tests/source/mod-2.rs similarity index 100% rename from tests/source/mod-2.rs rename to rustfmt-core/tests/source/mod-2.rs diff --git a/tests/source/mod_skip_child.rs b/rustfmt-core/tests/source/mod_skip_child.rs similarity index 100% rename from tests/source/mod_skip_child.rs rename to rustfmt-core/tests/source/mod_skip_child.rs diff --git a/tests/source/multiple.rs b/rustfmt-core/tests/source/multiple.rs similarity index 100% rename from tests/source/multiple.rs rename to rustfmt-core/tests/source/multiple.rs diff --git a/tests/source/nested-if-else.rs b/rustfmt-core/tests/source/nested-if-else.rs similarity index 100% rename from tests/source/nested-if-else.rs rename to rustfmt-core/tests/source/nested-if-else.rs diff --git a/tests/source/nested_skipped/mod.rs b/rustfmt-core/tests/source/nested_skipped/mod.rs similarity index 100% rename from tests/source/nested_skipped/mod.rs rename to rustfmt-core/tests/source/nested_skipped/mod.rs diff --git a/tests/source/nestedmod/mod.rs b/rustfmt-core/tests/source/nestedmod/mod.rs similarity index 100% rename from tests/source/nestedmod/mod.rs rename to rustfmt-core/tests/source/nestedmod/mod.rs diff --git a/tests/source/nestedmod/mod2a.rs b/rustfmt-core/tests/source/nestedmod/mod2a.rs similarity index 100% rename from tests/source/nestedmod/mod2a.rs rename to rustfmt-core/tests/source/nestedmod/mod2a.rs diff --git a/tests/source/nestedmod/mod2b.rs b/rustfmt-core/tests/source/nestedmod/mod2b.rs similarity index 100% rename from tests/source/nestedmod/mod2b.rs rename to rustfmt-core/tests/source/nestedmod/mod2b.rs diff --git a/tests/source/nestedmod/mod2c.rs b/rustfmt-core/tests/source/nestedmod/mod2c.rs similarity index 100% rename from tests/source/nestedmod/mod2c.rs rename to rustfmt-core/tests/source/nestedmod/mod2c.rs diff --git a/tests/source/nestedmod/mymod1/mod3a.rs b/rustfmt-core/tests/source/nestedmod/mymod1/mod3a.rs similarity index 100% rename from tests/source/nestedmod/mymod1/mod3a.rs rename to rustfmt-core/tests/source/nestedmod/mymod1/mod3a.rs diff --git a/tests/source/nestedmod/submod2/a.rs b/rustfmt-core/tests/source/nestedmod/submod2/a.rs similarity index 100% rename from tests/source/nestedmod/submod2/a.rs rename to rustfmt-core/tests/source/nestedmod/submod2/a.rs diff --git a/tests/source/nestedmod/submod2/mod.rs b/rustfmt-core/tests/source/nestedmod/submod2/mod.rs similarity index 100% rename from tests/source/nestedmod/submod2/mod.rs rename to rustfmt-core/tests/source/nestedmod/submod2/mod.rs diff --git a/tests/source/no_new_line_beginning.rs b/rustfmt-core/tests/source/no_new_line_beginning.rs similarity index 100% rename from tests/source/no_new_line_beginning.rs rename to rustfmt-core/tests/source/no_new_line_beginning.rs diff --git a/tests/source/other.rs b/rustfmt-core/tests/source/other.rs similarity index 100% rename from tests/source/other.rs rename to rustfmt-core/tests/source/other.rs diff --git a/tests/source/paths.rs b/rustfmt-core/tests/source/paths.rs similarity index 100% rename from tests/source/paths.rs rename to rustfmt-core/tests/source/paths.rs diff --git a/tests/source/pattern-condense-wildcards.rs b/rustfmt-core/tests/source/pattern-condense-wildcards.rs similarity index 100% rename from tests/source/pattern-condense-wildcards.rs rename to rustfmt-core/tests/source/pattern-condense-wildcards.rs diff --git a/tests/source/pattern.rs b/rustfmt-core/tests/source/pattern.rs similarity index 100% rename from tests/source/pattern.rs rename to rustfmt-core/tests/source/pattern.rs diff --git a/tests/source/pub-restricted.rs b/rustfmt-core/tests/source/pub-restricted.rs similarity index 100% rename from tests/source/pub-restricted.rs rename to rustfmt-core/tests/source/pub-restricted.rs diff --git a/tests/source/remove_blank_lines.rs b/rustfmt-core/tests/source/remove_blank_lines.rs similarity index 100% rename from tests/source/remove_blank_lines.rs rename to rustfmt-core/tests/source/remove_blank_lines.rs diff --git a/tests/source/single-line-if-else.rs b/rustfmt-core/tests/source/single-line-if-else.rs similarity index 100% rename from tests/source/single-line-if-else.rs rename to rustfmt-core/tests/source/single-line-if-else.rs diff --git a/tests/source/soft-wrapping.rs b/rustfmt-core/tests/source/soft-wrapping.rs similarity index 100% rename from tests/source/soft-wrapping.rs rename to rustfmt-core/tests/source/soft-wrapping.rs diff --git a/tests/source/space-not-before-newline.rs b/rustfmt-core/tests/source/space-not-before-newline.rs similarity index 100% rename from tests/source/space-not-before-newline.rs rename to rustfmt-core/tests/source/space-not-before-newline.rs diff --git a/tests/source/spaces-around-ranges.rs b/rustfmt-core/tests/source/spaces-around-ranges.rs similarity index 100% rename from tests/source/spaces-around-ranges.rs rename to rustfmt-core/tests/source/spaces-around-ranges.rs diff --git a/tests/source/static.rs b/rustfmt-core/tests/source/static.rs similarity index 100% rename from tests/source/static.rs rename to rustfmt-core/tests/source/static.rs diff --git a/tests/source/string-lit-2.rs b/rustfmt-core/tests/source/string-lit-2.rs similarity index 100% rename from tests/source/string-lit-2.rs rename to rustfmt-core/tests/source/string-lit-2.rs diff --git a/tests/source/string-lit.rs b/rustfmt-core/tests/source/string-lit.rs similarity index 100% rename from tests/source/string-lit.rs rename to rustfmt-core/tests/source/string-lit.rs diff --git a/tests/source/string_punctuation.rs b/rustfmt-core/tests/source/string_punctuation.rs similarity index 100% rename from tests/source/string_punctuation.rs rename to rustfmt-core/tests/source/string_punctuation.rs diff --git a/tests/source/struct-field-attributes.rs b/rustfmt-core/tests/source/struct-field-attributes.rs similarity index 100% rename from tests/source/struct-field-attributes.rs rename to rustfmt-core/tests/source/struct-field-attributes.rs diff --git a/tests/source/struct_lits.rs b/rustfmt-core/tests/source/struct_lits.rs similarity index 100% rename from tests/source/struct_lits.rs rename to rustfmt-core/tests/source/struct_lits.rs diff --git a/tests/source/struct_lits_multiline.rs b/rustfmt-core/tests/source/struct_lits_multiline.rs similarity index 100% rename from tests/source/struct_lits_multiline.rs rename to rustfmt-core/tests/source/struct_lits_multiline.rs diff --git a/tests/source/struct_lits_visual.rs b/rustfmt-core/tests/source/struct_lits_visual.rs similarity index 100% rename from tests/source/struct_lits_visual.rs rename to rustfmt-core/tests/source/struct_lits_visual.rs diff --git a/tests/source/struct_lits_visual_multiline.rs b/rustfmt-core/tests/source/struct_lits_visual_multiline.rs similarity index 100% rename from tests/source/struct_lits_visual_multiline.rs rename to rustfmt-core/tests/source/struct_lits_visual_multiline.rs diff --git a/tests/source/struct_tuple_visual.rs b/rustfmt-core/tests/source/struct_tuple_visual.rs similarity index 100% rename from tests/source/struct_tuple_visual.rs rename to rustfmt-core/tests/source/struct_tuple_visual.rs diff --git a/tests/source/structs.rs b/rustfmt-core/tests/source/structs.rs similarity index 100% rename from tests/source/structs.rs rename to rustfmt-core/tests/source/structs.rs diff --git a/tests/source/trailing-comma-never.rs b/rustfmt-core/tests/source/trailing-comma-never.rs similarity index 100% rename from tests/source/trailing-comma-never.rs rename to rustfmt-core/tests/source/trailing-comma-never.rs diff --git a/tests/source/trailing_commas.rs b/rustfmt-core/tests/source/trailing_commas.rs similarity index 100% rename from tests/source/trailing_commas.rs rename to rustfmt-core/tests/source/trailing_commas.rs diff --git a/tests/source/trait.rs b/rustfmt-core/tests/source/trait.rs similarity index 100% rename from tests/source/trait.rs rename to rustfmt-core/tests/source/trait.rs diff --git a/tests/source/try-conversion.rs b/rustfmt-core/tests/source/try-conversion.rs similarity index 100% rename from tests/source/try-conversion.rs rename to rustfmt-core/tests/source/try-conversion.rs diff --git a/tests/source/tuple.rs b/rustfmt-core/tests/source/tuple.rs similarity index 100% rename from tests/source/tuple.rs rename to rustfmt-core/tests/source/tuple.rs diff --git a/tests/source/type-ascription.rs b/rustfmt-core/tests/source/type-ascription.rs similarity index 100% rename from tests/source/type-ascription.rs rename to rustfmt-core/tests/source/type-ascription.rs diff --git a/tests/source/type-punctuation.rs b/rustfmt-core/tests/source/type-punctuation.rs similarity index 100% rename from tests/source/type-punctuation.rs rename to rustfmt-core/tests/source/type-punctuation.rs diff --git a/tests/source/type.rs b/rustfmt-core/tests/source/type.rs similarity index 100% rename from tests/source/type.rs rename to rustfmt-core/tests/source/type.rs diff --git a/tests/source/type_alias.rs b/rustfmt-core/tests/source/type_alias.rs similarity index 100% rename from tests/source/type_alias.rs rename to rustfmt-core/tests/source/type_alias.rs diff --git a/tests/source/unions.rs b/rustfmt-core/tests/source/unions.rs similarity index 100% rename from tests/source/unions.rs rename to rustfmt-core/tests/source/unions.rs diff --git a/tests/source/where-clause-rfc.rs b/rustfmt-core/tests/source/where-clause-rfc.rs similarity index 100% rename from tests/source/where-clause-rfc.rs rename to rustfmt-core/tests/source/where-clause-rfc.rs diff --git a/tests/source/where-clause.rs b/rustfmt-core/tests/source/where-clause.rs similarity index 100% rename from tests/source/where-clause.rs rename to rustfmt-core/tests/source/where-clause.rs diff --git a/tests/target/assignment.rs b/rustfmt-core/tests/target/assignment.rs similarity index 100% rename from tests/target/assignment.rs rename to rustfmt-core/tests/target/assignment.rs diff --git a/tests/target/associated-items.rs b/rustfmt-core/tests/target/associated-items.rs similarity index 100% rename from tests/target/associated-items.rs rename to rustfmt-core/tests/target/associated-items.rs diff --git a/tests/target/associated-types-bounds-wrapping.rs b/rustfmt-core/tests/target/associated-types-bounds-wrapping.rs similarity index 100% rename from tests/target/associated-types-bounds-wrapping.rs rename to rustfmt-core/tests/target/associated-types-bounds-wrapping.rs diff --git a/tests/target/associated_type_defaults.rs b/rustfmt-core/tests/target/associated_type_defaults.rs similarity index 100% rename from tests/target/associated_type_defaults.rs rename to rustfmt-core/tests/target/associated_type_defaults.rs diff --git a/tests/target/attrib-extern-crate.rs b/rustfmt-core/tests/target/attrib-extern-crate.rs similarity index 100% rename from tests/target/attrib-extern-crate.rs rename to rustfmt-core/tests/target/attrib-extern-crate.rs diff --git a/tests/target/attrib.rs b/rustfmt-core/tests/target/attrib.rs similarity index 100% rename from tests/target/attrib.rs rename to rustfmt-core/tests/target/attrib.rs diff --git a/tests/target/big-impl-rfc.rs b/rustfmt-core/tests/target/big-impl-rfc.rs similarity index 100% rename from tests/target/big-impl-rfc.rs rename to rustfmt-core/tests/target/big-impl-rfc.rs diff --git a/tests/target/big-impl.rs b/rustfmt-core/tests/target/big-impl.rs similarity index 100% rename from tests/target/big-impl.rs rename to rustfmt-core/tests/target/big-impl.rs diff --git a/tests/target/break-and-continue.rs b/rustfmt-core/tests/target/break-and-continue.rs similarity index 100% rename from tests/target/break-and-continue.rs rename to rustfmt-core/tests/target/break-and-continue.rs diff --git a/tests/target/catch.rs b/rustfmt-core/tests/target/catch.rs similarity index 100% rename from tests/target/catch.rs rename to rustfmt-core/tests/target/catch.rs diff --git a/tests/target/chains-indent-tabbed.rs b/rustfmt-core/tests/target/chains-indent-tabbed.rs similarity index 100% rename from tests/target/chains-indent-tabbed.rs rename to rustfmt-core/tests/target/chains-indent-tabbed.rs diff --git a/tests/target/chains-indent-visual.rs b/rustfmt-core/tests/target/chains-indent-visual.rs similarity index 100% rename from tests/target/chains-indent-visual.rs rename to rustfmt-core/tests/target/chains-indent-visual.rs diff --git a/tests/target/chains-visual.rs b/rustfmt-core/tests/target/chains-visual.rs similarity index 100% rename from tests/target/chains-visual.rs rename to rustfmt-core/tests/target/chains-visual.rs diff --git a/tests/target/chains.rs b/rustfmt-core/tests/target/chains.rs similarity index 100% rename from tests/target/chains.rs rename to rustfmt-core/tests/target/chains.rs diff --git a/tests/target/closure-block-inside-macro.rs b/rustfmt-core/tests/target/closure-block-inside-macro.rs similarity index 100% rename from tests/target/closure-block-inside-macro.rs rename to rustfmt-core/tests/target/closure-block-inside-macro.rs diff --git a/tests/target/closure.rs b/rustfmt-core/tests/target/closure.rs similarity index 100% rename from tests/target/closure.rs rename to rustfmt-core/tests/target/closure.rs diff --git a/tests/target/comment-inside-const.rs b/rustfmt-core/tests/target/comment-inside-const.rs similarity index 100% rename from tests/target/comment-inside-const.rs rename to rustfmt-core/tests/target/comment-inside-const.rs diff --git a/tests/target/comment-not-disappear.rs b/rustfmt-core/tests/target/comment-not-disappear.rs similarity index 100% rename from tests/target/comment-not-disappear.rs rename to rustfmt-core/tests/target/comment-not-disappear.rs diff --git a/tests/target/comment.rs b/rustfmt-core/tests/target/comment.rs similarity index 100% rename from tests/target/comment.rs rename to rustfmt-core/tests/target/comment.rs diff --git a/tests/target/comment2.rs b/rustfmt-core/tests/target/comment2.rs similarity index 100% rename from tests/target/comment2.rs rename to rustfmt-core/tests/target/comment2.rs diff --git a/tests/target/comment3.rs b/rustfmt-core/tests/target/comment3.rs similarity index 100% rename from tests/target/comment3.rs rename to rustfmt-core/tests/target/comment3.rs diff --git a/tests/target/comment4.rs b/rustfmt-core/tests/target/comment4.rs similarity index 100% rename from tests/target/comment4.rs rename to rustfmt-core/tests/target/comment4.rs diff --git a/tests/target/comment5.rs b/rustfmt-core/tests/target/comment5.rs similarity index 100% rename from tests/target/comment5.rs rename to rustfmt-core/tests/target/comment5.rs diff --git a/tests/target/comment_crlf_newline.rs b/rustfmt-core/tests/target/comment_crlf_newline.rs similarity index 100% rename from tests/target/comment_crlf_newline.rs rename to rustfmt-core/tests/target/comment_crlf_newline.rs diff --git a/tests/target/comments-fn.rs b/rustfmt-core/tests/target/comments-fn.rs similarity index 100% rename from tests/target/comments-fn.rs rename to rustfmt-core/tests/target/comments-fn.rs diff --git a/tests/target/configs/blank_lines_lower_bound/1.rs b/rustfmt-core/tests/target/configs/blank_lines_lower_bound/1.rs similarity index 100% rename from tests/target/configs/blank_lines_lower_bound/1.rs rename to rustfmt-core/tests/target/configs/blank_lines_lower_bound/1.rs diff --git a/tests/target/configs/brace_style/fn_always_next_line.rs b/rustfmt-core/tests/target/configs/brace_style/fn_always_next_line.rs similarity index 100% rename from tests/target/configs/brace_style/fn_always_next_line.rs rename to rustfmt-core/tests/target/configs/brace_style/fn_always_next_line.rs diff --git a/tests/target/configs/brace_style/fn_prefer_same_line.rs b/rustfmt-core/tests/target/configs/brace_style/fn_prefer_same_line.rs similarity index 100% rename from tests/target/configs/brace_style/fn_prefer_same_line.rs rename to rustfmt-core/tests/target/configs/brace_style/fn_prefer_same_line.rs diff --git a/tests/target/configs/brace_style/fn_same_line_where.rs b/rustfmt-core/tests/target/configs/brace_style/fn_same_line_where.rs similarity index 100% rename from tests/target/configs/brace_style/fn_same_line_where.rs rename to rustfmt-core/tests/target/configs/brace_style/fn_same_line_where.rs diff --git a/tests/target/configs/brace_style/item_always_next_line.rs b/rustfmt-core/tests/target/configs/brace_style/item_always_next_line.rs similarity index 100% rename from tests/target/configs/brace_style/item_always_next_line.rs rename to rustfmt-core/tests/target/configs/brace_style/item_always_next_line.rs diff --git a/tests/target/configs/brace_style/item_prefer_same_line.rs b/rustfmt-core/tests/target/configs/brace_style/item_prefer_same_line.rs similarity index 100% rename from tests/target/configs/brace_style/item_prefer_same_line.rs rename to rustfmt-core/tests/target/configs/brace_style/item_prefer_same_line.rs diff --git a/tests/target/configs/brace_style/item_same_line_where.rs b/rustfmt-core/tests/target/configs/brace_style/item_same_line_where.rs similarity index 100% rename from tests/target/configs/brace_style/item_same_line_where.rs rename to rustfmt-core/tests/target/configs/brace_style/item_same_line_where.rs diff --git a/tests/target/configs/combine_control_expr/false.rs b/rustfmt-core/tests/target/configs/combine_control_expr/false.rs similarity index 100% rename from tests/target/configs/combine_control_expr/false.rs rename to rustfmt-core/tests/target/configs/combine_control_expr/false.rs diff --git a/tests/target/configs/combine_control_expr/true.rs b/rustfmt-core/tests/target/configs/combine_control_expr/true.rs similarity index 100% rename from tests/target/configs/combine_control_expr/true.rs rename to rustfmt-core/tests/target/configs/combine_control_expr/true.rs diff --git a/tests/target/configs/comment_width/above.rs b/rustfmt-core/tests/target/configs/comment_width/above.rs similarity index 100% rename from tests/target/configs/comment_width/above.rs rename to rustfmt-core/tests/target/configs/comment_width/above.rs diff --git a/tests/target/configs/comment_width/below.rs b/rustfmt-core/tests/target/configs/comment_width/below.rs similarity index 100% rename from tests/target/configs/comment_width/below.rs rename to rustfmt-core/tests/target/configs/comment_width/below.rs diff --git a/tests/target/configs/comment_width/ignore.rs b/rustfmt-core/tests/target/configs/comment_width/ignore.rs similarity index 100% rename from tests/target/configs/comment_width/ignore.rs rename to rustfmt-core/tests/target/configs/comment_width/ignore.rs diff --git a/tests/target/configs/condense_wildcard_suffixes/false.rs b/rustfmt-core/tests/target/configs/condense_wildcard_suffixes/false.rs similarity index 100% rename from tests/target/configs/condense_wildcard_suffixes/false.rs rename to rustfmt-core/tests/target/configs/condense_wildcard_suffixes/false.rs diff --git a/tests/target/configs/condense_wildcard_suffixes/true.rs b/rustfmt-core/tests/target/configs/condense_wildcard_suffixes/true.rs similarity index 100% rename from tests/target/configs/condense_wildcard_suffixes/true.rs rename to rustfmt-core/tests/target/configs/condense_wildcard_suffixes/true.rs diff --git a/tests/target/configs/control_brace_style/always_next_line.rs b/rustfmt-core/tests/target/configs/control_brace_style/always_next_line.rs similarity index 100% rename from tests/target/configs/control_brace_style/always_next_line.rs rename to rustfmt-core/tests/target/configs/control_brace_style/always_next_line.rs diff --git a/tests/target/configs/control_brace_style/always_same_line.rs b/rustfmt-core/tests/target/configs/control_brace_style/always_same_line.rs similarity index 100% rename from tests/target/configs/control_brace_style/always_same_line.rs rename to rustfmt-core/tests/target/configs/control_brace_style/always_same_line.rs diff --git a/tests/target/configs/control_brace_style/closing_next_line.rs b/rustfmt-core/tests/target/configs/control_brace_style/closing_next_line.rs similarity index 100% rename from tests/target/configs/control_brace_style/closing_next_line.rs rename to rustfmt-core/tests/target/configs/control_brace_style/closing_next_line.rs diff --git a/tests/target/configs/disable_all_formatting/false.rs b/rustfmt-core/tests/target/configs/disable_all_formatting/false.rs similarity index 100% rename from tests/target/configs/disable_all_formatting/false.rs rename to rustfmt-core/tests/target/configs/disable_all_formatting/false.rs diff --git a/tests/target/configs/disable_all_formatting/true.rs b/rustfmt-core/tests/target/configs/disable_all_formatting/true.rs similarity index 100% rename from tests/target/configs/disable_all_formatting/true.rs rename to rustfmt-core/tests/target/configs/disable_all_formatting/true.rs diff --git a/tests/target/configs/empty_item_single_line/false.rs b/rustfmt-core/tests/target/configs/empty_item_single_line/false.rs similarity index 100% rename from tests/target/configs/empty_item_single_line/false.rs rename to rustfmt-core/tests/target/configs/empty_item_single_line/false.rs diff --git a/tests/target/configs/empty_item_single_line/true.rs b/rustfmt-core/tests/target/configs/empty_item_single_line/true.rs similarity index 100% rename from tests/target/configs/empty_item_single_line/true.rs rename to rustfmt-core/tests/target/configs/empty_item_single_line/true.rs diff --git a/tests/target/configs/error_on_line_overflow/false.rs b/rustfmt-core/tests/target/configs/error_on_line_overflow/false.rs similarity index 100% rename from tests/target/configs/error_on_line_overflow/false.rs rename to rustfmt-core/tests/target/configs/error_on_line_overflow/false.rs diff --git a/tests/target/configs/error_on_unformatted/false.rs b/rustfmt-core/tests/target/configs/error_on_unformatted/false.rs similarity index 100% rename from tests/target/configs/error_on_unformatted/false.rs rename to rustfmt-core/tests/target/configs/error_on_unformatted/false.rs diff --git a/tests/target/configs/fn_args_density/compressed.rs b/rustfmt-core/tests/target/configs/fn_args_density/compressed.rs similarity index 100% rename from tests/target/configs/fn_args_density/compressed.rs rename to rustfmt-core/tests/target/configs/fn_args_density/compressed.rs diff --git a/tests/target/configs/fn_args_density/tall.rs b/rustfmt-core/tests/target/configs/fn_args_density/tall.rs similarity index 100% rename from tests/target/configs/fn_args_density/tall.rs rename to rustfmt-core/tests/target/configs/fn_args_density/tall.rs diff --git a/tests/target/configs/fn_args_density/vertical.rs b/rustfmt-core/tests/target/configs/fn_args_density/vertical.rs similarity index 100% rename from tests/target/configs/fn_args_density/vertical.rs rename to rustfmt-core/tests/target/configs/fn_args_density/vertical.rs diff --git a/tests/target/configs/fn_single_line/false.rs b/rustfmt-core/tests/target/configs/fn_single_line/false.rs similarity index 100% rename from tests/target/configs/fn_single_line/false.rs rename to rustfmt-core/tests/target/configs/fn_single_line/false.rs diff --git a/tests/target/configs/fn_single_line/true.rs b/rustfmt-core/tests/target/configs/fn_single_line/true.rs similarity index 100% rename from tests/target/configs/fn_single_line/true.rs rename to rustfmt-core/tests/target/configs/fn_single_line/true.rs diff --git a/tests/target/configs/force_explicit_abi/false.rs b/rustfmt-core/tests/target/configs/force_explicit_abi/false.rs similarity index 100% rename from tests/target/configs/force_explicit_abi/false.rs rename to rustfmt-core/tests/target/configs/force_explicit_abi/false.rs diff --git a/tests/target/configs/force_explicit_abi/true.rs b/rustfmt-core/tests/target/configs/force_explicit_abi/true.rs similarity index 100% rename from tests/target/configs/force_explicit_abi/true.rs rename to rustfmt-core/tests/target/configs/force_explicit_abi/true.rs diff --git a/tests/target/configs/force_multiline_block/false.rs b/rustfmt-core/tests/target/configs/force_multiline_block/false.rs similarity index 100% rename from tests/target/configs/force_multiline_block/false.rs rename to rustfmt-core/tests/target/configs/force_multiline_block/false.rs diff --git a/tests/target/configs/force_multiline_block/true.rs b/rustfmt-core/tests/target/configs/force_multiline_block/true.rs similarity index 100% rename from tests/target/configs/force_multiline_block/true.rs rename to rustfmt-core/tests/target/configs/force_multiline_block/true.rs diff --git a/tests/target/configs/format_strings/false.rs b/rustfmt-core/tests/target/configs/format_strings/false.rs similarity index 100% rename from tests/target/configs/format_strings/false.rs rename to rustfmt-core/tests/target/configs/format_strings/false.rs diff --git a/tests/target/configs/format_strings/true.rs b/rustfmt-core/tests/target/configs/format_strings/true.rs similarity index 100% rename from tests/target/configs/format_strings/true.rs rename to rustfmt-core/tests/target/configs/format_strings/true.rs diff --git a/tests/target/configs/hard_tabs/false.rs b/rustfmt-core/tests/target/configs/hard_tabs/false.rs similarity index 100% rename from tests/target/configs/hard_tabs/false.rs rename to rustfmt-core/tests/target/configs/hard_tabs/false.rs diff --git a/tests/target/configs/hard_tabs/true.rs b/rustfmt-core/tests/target/configs/hard_tabs/true.rs similarity index 100% rename from tests/target/configs/hard_tabs/true.rs rename to rustfmt-core/tests/target/configs/hard_tabs/true.rs diff --git a/tests/target/configs/imports_indent/block.rs b/rustfmt-core/tests/target/configs/imports_indent/block.rs similarity index 100% rename from tests/target/configs/imports_indent/block.rs rename to rustfmt-core/tests/target/configs/imports_indent/block.rs diff --git a/tests/target/configs/imports_layout/horizontal_vertical.rs b/rustfmt-core/tests/target/configs/imports_layout/horizontal_vertical.rs similarity index 100% rename from tests/target/configs/imports_layout/horizontal_vertical.rs rename to rustfmt-core/tests/target/configs/imports_layout/horizontal_vertical.rs diff --git a/tests/target/configs/imports_layout/mixed.rs b/rustfmt-core/tests/target/configs/imports_layout/mixed.rs similarity index 100% rename from tests/target/configs/imports_layout/mixed.rs rename to rustfmt-core/tests/target/configs/imports_layout/mixed.rs diff --git a/tests/target/configs/indent_style/block_args.rs b/rustfmt-core/tests/target/configs/indent_style/block_args.rs similarity index 100% rename from tests/target/configs/indent_style/block_args.rs rename to rustfmt-core/tests/target/configs/indent_style/block_args.rs diff --git a/tests/target/configs/indent_style/block_array.rs b/rustfmt-core/tests/target/configs/indent_style/block_array.rs similarity index 100% rename from tests/target/configs/indent_style/block_array.rs rename to rustfmt-core/tests/target/configs/indent_style/block_array.rs diff --git a/tests/target/configs/indent_style/block_call.rs b/rustfmt-core/tests/target/configs/indent_style/block_call.rs similarity index 100% rename from tests/target/configs/indent_style/block_call.rs rename to rustfmt-core/tests/target/configs/indent_style/block_call.rs diff --git a/tests/target/configs/indent_style/block_chain.rs b/rustfmt-core/tests/target/configs/indent_style/block_chain.rs similarity index 100% rename from tests/target/configs/indent_style/block_chain.rs rename to rustfmt-core/tests/target/configs/indent_style/block_chain.rs diff --git a/tests/target/configs/indent_style/block_generic.rs b/rustfmt-core/tests/target/configs/indent_style/block_generic.rs similarity index 100% rename from tests/target/configs/indent_style/block_generic.rs rename to rustfmt-core/tests/target/configs/indent_style/block_generic.rs diff --git a/tests/target/configs/indent_style/block_struct_lit.rs b/rustfmt-core/tests/target/configs/indent_style/block_struct_lit.rs similarity index 100% rename from tests/target/configs/indent_style/block_struct_lit.rs rename to rustfmt-core/tests/target/configs/indent_style/block_struct_lit.rs diff --git a/tests/target/configs/indent_style/block_tab_spaces_call.rs b/rustfmt-core/tests/target/configs/indent_style/block_tab_spaces_call.rs similarity index 100% rename from tests/target/configs/indent_style/block_tab_spaces_call.rs rename to rustfmt-core/tests/target/configs/indent_style/block_tab_spaces_call.rs diff --git a/tests/target/configs/indent_style/block_trailing_comma_call.rs b/rustfmt-core/tests/target/configs/indent_style/block_trailing_comma_call.rs similarity index 100% rename from tests/target/configs/indent_style/block_trailing_comma_call.rs rename to rustfmt-core/tests/target/configs/indent_style/block_trailing_comma_call.rs diff --git a/tests/target/configs/indent_style/block_where_pred.rs b/rustfmt-core/tests/target/configs/indent_style/block_where_pred.rs similarity index 100% rename from tests/target/configs/indent_style/block_where_pred.rs rename to rustfmt-core/tests/target/configs/indent_style/block_where_pred.rs diff --git a/tests/target/configs/indent_style/default.rs b/rustfmt-core/tests/target/configs/indent_style/default.rs similarity index 100% rename from tests/target/configs/indent_style/default.rs rename to rustfmt-core/tests/target/configs/indent_style/default.rs diff --git a/tests/target/configs/indent_style/rfc_control.rs b/rustfmt-core/tests/target/configs/indent_style/rfc_control.rs similarity index 100% rename from tests/target/configs/indent_style/rfc_control.rs rename to rustfmt-core/tests/target/configs/indent_style/rfc_control.rs diff --git a/tests/target/configs/indent_style/rfc_where.rs b/rustfmt-core/tests/target/configs/indent_style/rfc_where.rs similarity index 100% rename from tests/target/configs/indent_style/rfc_where.rs rename to rustfmt-core/tests/target/configs/indent_style/rfc_where.rs diff --git a/tests/target/configs/indent_style/visual_args.rs b/rustfmt-core/tests/target/configs/indent_style/visual_args.rs similarity index 100% rename from tests/target/configs/indent_style/visual_args.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_args.rs diff --git a/tests/target/configs/indent_style/visual_array.rs b/rustfmt-core/tests/target/configs/indent_style/visual_array.rs similarity index 100% rename from tests/target/configs/indent_style/visual_array.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_array.rs diff --git a/tests/target/configs/indent_style/visual_call.rs b/rustfmt-core/tests/target/configs/indent_style/visual_call.rs similarity index 100% rename from tests/target/configs/indent_style/visual_call.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_call.rs diff --git a/tests/target/configs/indent_style/visual_chain.rs b/rustfmt-core/tests/target/configs/indent_style/visual_chain.rs similarity index 100% rename from tests/target/configs/indent_style/visual_chain.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_chain.rs diff --git a/tests/target/configs/indent_style/visual_generics.rs b/rustfmt-core/tests/target/configs/indent_style/visual_generics.rs similarity index 100% rename from tests/target/configs/indent_style/visual_generics.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_generics.rs diff --git a/tests/target/configs/indent_style/visual_struct_lit.rs b/rustfmt-core/tests/target/configs/indent_style/visual_struct_lit.rs similarity index 100% rename from tests/target/configs/indent_style/visual_struct_lit.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_struct_lit.rs diff --git a/tests/target/configs/indent_style/visual_trailing_comma.rs b/rustfmt-core/tests/target/configs/indent_style/visual_trailing_comma.rs similarity index 100% rename from tests/target/configs/indent_style/visual_trailing_comma.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_trailing_comma.rs diff --git a/tests/target/configs/indent_style/visual_where_pred.rs b/rustfmt-core/tests/target/configs/indent_style/visual_where_pred.rs similarity index 100% rename from tests/target/configs/indent_style/visual_where_pred.rs rename to rustfmt-core/tests/target/configs/indent_style/visual_where_pred.rs diff --git a/tests/target/configs/match_arm_blocks/false.rs b/rustfmt-core/tests/target/configs/match_arm_blocks/false.rs similarity index 100% rename from tests/target/configs/match_arm_blocks/false.rs rename to rustfmt-core/tests/target/configs/match_arm_blocks/false.rs diff --git a/tests/target/configs/match_arm_blocks/true.rs b/rustfmt-core/tests/target/configs/match_arm_blocks/true.rs similarity index 100% rename from tests/target/configs/match_arm_blocks/true.rs rename to rustfmt-core/tests/target/configs/match_arm_blocks/true.rs diff --git a/tests/target/configs/match_block_trailing_comma/false.rs b/rustfmt-core/tests/target/configs/match_block_trailing_comma/false.rs similarity index 100% rename from tests/target/configs/match_block_trailing_comma/false.rs rename to rustfmt-core/tests/target/configs/match_block_trailing_comma/false.rs diff --git a/tests/target/configs/match_block_trailing_comma/true.rs b/rustfmt-core/tests/target/configs/match_block_trailing_comma/true.rs similarity index 100% rename from tests/target/configs/match_block_trailing_comma/true.rs rename to rustfmt-core/tests/target/configs/match_block_trailing_comma/true.rs diff --git a/tests/target/configs/merge_derives/true.rs b/rustfmt-core/tests/target/configs/merge_derives/true.rs similarity index 100% rename from tests/target/configs/merge_derives/true.rs rename to rustfmt-core/tests/target/configs/merge_derives/true.rs diff --git a/tests/target/configs/normalize_comments/false.rs b/rustfmt-core/tests/target/configs/normalize_comments/false.rs similarity index 100% rename from tests/target/configs/normalize_comments/false.rs rename to rustfmt-core/tests/target/configs/normalize_comments/false.rs diff --git a/tests/target/configs/normalize_comments/true.rs b/rustfmt-core/tests/target/configs/normalize_comments/true.rs similarity index 100% rename from tests/target/configs/normalize_comments/true.rs rename to rustfmt-core/tests/target/configs/normalize_comments/true.rs diff --git a/tests/target/configs/reorder_extern_crates/false.rs b/rustfmt-core/tests/target/configs/reorder_extern_crates/false.rs similarity index 100% rename from tests/target/configs/reorder_extern_crates/false.rs rename to rustfmt-core/tests/target/configs/reorder_extern_crates/false.rs diff --git a/tests/target/configs/reorder_extern_crates/true.rs b/rustfmt-core/tests/target/configs/reorder_extern_crates/true.rs similarity index 100% rename from tests/target/configs/reorder_extern_crates/true.rs rename to rustfmt-core/tests/target/configs/reorder_extern_crates/true.rs diff --git a/tests/target/configs/reorder_imported_names/false.rs b/rustfmt-core/tests/target/configs/reorder_imported_names/false.rs similarity index 100% rename from tests/target/configs/reorder_imported_names/false.rs rename to rustfmt-core/tests/target/configs/reorder_imported_names/false.rs diff --git a/tests/target/configs/reorder_imported_names/true.rs b/rustfmt-core/tests/target/configs/reorder_imported_names/true.rs similarity index 100% rename from tests/target/configs/reorder_imported_names/true.rs rename to rustfmt-core/tests/target/configs/reorder_imported_names/true.rs diff --git a/tests/target/configs/reorder_imports/false.rs b/rustfmt-core/tests/target/configs/reorder_imports/false.rs similarity index 100% rename from tests/target/configs/reorder_imports/false.rs rename to rustfmt-core/tests/target/configs/reorder_imports/false.rs diff --git a/tests/target/configs/reorder_imports/true.rs b/rustfmt-core/tests/target/configs/reorder_imports/true.rs similarity index 100% rename from tests/target/configs/reorder_imports/true.rs rename to rustfmt-core/tests/target/configs/reorder_imports/true.rs diff --git a/tests/target/configs/reorder_imports_in_group/false.rs b/rustfmt-core/tests/target/configs/reorder_imports_in_group/false.rs similarity index 100% rename from tests/target/configs/reorder_imports_in_group/false.rs rename to rustfmt-core/tests/target/configs/reorder_imports_in_group/false.rs diff --git a/tests/target/configs/reorder_imports_in_group/true.rs b/rustfmt-core/tests/target/configs/reorder_imports_in_group/true.rs similarity index 100% rename from tests/target/configs/reorder_imports_in_group/true.rs rename to rustfmt-core/tests/target/configs/reorder_imports_in_group/true.rs diff --git a/tests/target/configs/reorder_modules/dolor/mod.rs b/rustfmt-core/tests/target/configs/reorder_modules/dolor/mod.rs similarity index 100% rename from tests/target/configs/reorder_modules/dolor/mod.rs rename to rustfmt-core/tests/target/configs/reorder_modules/dolor/mod.rs diff --git a/tests/target/configs/reorder_modules/false.rs b/rustfmt-core/tests/target/configs/reorder_modules/false.rs similarity index 100% rename from tests/target/configs/reorder_modules/false.rs rename to rustfmt-core/tests/target/configs/reorder_modules/false.rs diff --git a/tests/target/configs/reorder_modules/ipsum/mod.rs b/rustfmt-core/tests/target/configs/reorder_modules/ipsum/mod.rs similarity index 100% rename from tests/target/configs/reorder_modules/ipsum/mod.rs rename to rustfmt-core/tests/target/configs/reorder_modules/ipsum/mod.rs diff --git a/tests/target/configs/reorder_modules/lorem/mod.rs b/rustfmt-core/tests/target/configs/reorder_modules/lorem/mod.rs similarity index 100% rename from tests/target/configs/reorder_modules/lorem/mod.rs rename to rustfmt-core/tests/target/configs/reorder_modules/lorem/mod.rs diff --git a/tests/target/configs/reorder_modules/sit/mod.rs b/rustfmt-core/tests/target/configs/reorder_modules/sit/mod.rs similarity index 100% rename from tests/target/configs/reorder_modules/sit/mod.rs rename to rustfmt-core/tests/target/configs/reorder_modules/sit/mod.rs diff --git a/tests/target/configs/reorder_modules/true.rs b/rustfmt-core/tests/target/configs/reorder_modules/true.rs similarity index 100% rename from tests/target/configs/reorder_modules/true.rs rename to rustfmt-core/tests/target/configs/reorder_modules/true.rs diff --git a/tests/target/configs/space_before_colon/true.rs b/rustfmt-core/tests/target/configs/space_before_colon/true.rs similarity index 100% rename from tests/target/configs/space_before_colon/true.rs rename to rustfmt-core/tests/target/configs/space_before_colon/true.rs diff --git a/tests/target/configs/spaces_around_ranges/false.rs b/rustfmt-core/tests/target/configs/spaces_around_ranges/false.rs similarity index 100% rename from tests/target/configs/spaces_around_ranges/false.rs rename to rustfmt-core/tests/target/configs/spaces_around_ranges/false.rs diff --git a/tests/target/configs/spaces_around_ranges/true.rs b/rustfmt-core/tests/target/configs/spaces_around_ranges/true.rs similarity index 100% rename from tests/target/configs/spaces_around_ranges/true.rs rename to rustfmt-core/tests/target/configs/spaces_around_ranges/true.rs diff --git a/tests/target/configs/spaces_within_parens_and_brackets/false.rs b/rustfmt-core/tests/target/configs/spaces_within_parens_and_brackets/false.rs similarity index 100% rename from tests/target/configs/spaces_within_parens_and_brackets/false.rs rename to rustfmt-core/tests/target/configs/spaces_within_parens_and_brackets/false.rs diff --git a/tests/target/configs/spaces_within_parens_and_brackets/true.rs b/rustfmt-core/tests/target/configs/spaces_within_parens_and_brackets/true.rs similarity index 100% rename from tests/target/configs/spaces_within_parens_and_brackets/true.rs rename to rustfmt-core/tests/target/configs/spaces_within_parens_and_brackets/true.rs diff --git a/tests/target/configs/struct_field_align_threshold/20.rs b/rustfmt-core/tests/target/configs/struct_field_align_threshold/20.rs similarity index 100% rename from tests/target/configs/struct_field_align_threshold/20.rs rename to rustfmt-core/tests/target/configs/struct_field_align_threshold/20.rs diff --git a/tests/target/configs/struct_lit_single_line/false.rs b/rustfmt-core/tests/target/configs/struct_lit_single_line/false.rs similarity index 100% rename from tests/target/configs/struct_lit_single_line/false.rs rename to rustfmt-core/tests/target/configs/struct_lit_single_line/false.rs diff --git a/tests/target/configs/tab_spaces/2.rs b/rustfmt-core/tests/target/configs/tab_spaces/2.rs similarity index 100% rename from tests/target/configs/tab_spaces/2.rs rename to rustfmt-core/tests/target/configs/tab_spaces/2.rs diff --git a/tests/target/configs/tab_spaces/4.rs b/rustfmt-core/tests/target/configs/tab_spaces/4.rs similarity index 100% rename from tests/target/configs/tab_spaces/4.rs rename to rustfmt-core/tests/target/configs/tab_spaces/4.rs diff --git a/tests/target/configs/trailing_comma/always.rs b/rustfmt-core/tests/target/configs/trailing_comma/always.rs similarity index 100% rename from tests/target/configs/trailing_comma/always.rs rename to rustfmt-core/tests/target/configs/trailing_comma/always.rs diff --git a/tests/target/configs/trailing_comma/never.rs b/rustfmt-core/tests/target/configs/trailing_comma/never.rs similarity index 100% rename from tests/target/configs/trailing_comma/never.rs rename to rustfmt-core/tests/target/configs/trailing_comma/never.rs diff --git a/tests/target/configs/trailing_comma/vertical.rs b/rustfmt-core/tests/target/configs/trailing_comma/vertical.rs similarity index 100% rename from tests/target/configs/trailing_comma/vertical.rs rename to rustfmt-core/tests/target/configs/trailing_comma/vertical.rs diff --git a/tests/target/configs/trailing_semicolon/false.rs b/rustfmt-core/tests/target/configs/trailing_semicolon/false.rs similarity index 100% rename from tests/target/configs/trailing_semicolon/false.rs rename to rustfmt-core/tests/target/configs/trailing_semicolon/false.rs diff --git a/tests/target/configs/trailing_semicolon/true.rs b/rustfmt-core/tests/target/configs/trailing_semicolon/true.rs similarity index 100% rename from tests/target/configs/trailing_semicolon/true.rs rename to rustfmt-core/tests/target/configs/trailing_semicolon/true.rs diff --git a/tests/target/configs/type_punctuation_density/compressed.rs b/rustfmt-core/tests/target/configs/type_punctuation_density/compressed.rs similarity index 100% rename from tests/target/configs/type_punctuation_density/compressed.rs rename to rustfmt-core/tests/target/configs/type_punctuation_density/compressed.rs diff --git a/tests/target/configs/type_punctuation_density/wide.rs b/rustfmt-core/tests/target/configs/type_punctuation_density/wide.rs similarity index 100% rename from tests/target/configs/type_punctuation_density/wide.rs rename to rustfmt-core/tests/target/configs/type_punctuation_density/wide.rs diff --git a/tests/target/configs/use_field_init_shorthand/false.rs b/rustfmt-core/tests/target/configs/use_field_init_shorthand/false.rs similarity index 100% rename from tests/target/configs/use_field_init_shorthand/false.rs rename to rustfmt-core/tests/target/configs/use_field_init_shorthand/false.rs diff --git a/tests/target/configs/use_field_init_shorthand/true.rs b/rustfmt-core/tests/target/configs/use_field_init_shorthand/true.rs similarity index 100% rename from tests/target/configs/use_field_init_shorthand/true.rs rename to rustfmt-core/tests/target/configs/use_field_init_shorthand/true.rs diff --git a/tests/target/configs/use_try_shorthand/false.rs b/rustfmt-core/tests/target/configs/use_try_shorthand/false.rs similarity index 100% rename from tests/target/configs/use_try_shorthand/false.rs rename to rustfmt-core/tests/target/configs/use_try_shorthand/false.rs diff --git a/tests/target/configs/use_try_shorthand/true.rs b/rustfmt-core/tests/target/configs/use_try_shorthand/true.rs similarity index 100% rename from tests/target/configs/use_try_shorthand/true.rs rename to rustfmt-core/tests/target/configs/use_try_shorthand/true.rs diff --git a/tests/target/configs/where_single_line/true.rs b/rustfmt-core/tests/target/configs/where_single_line/true.rs similarity index 100% rename from tests/target/configs/where_single_line/true.rs rename to rustfmt-core/tests/target/configs/where_single_line/true.rs diff --git a/tests/target/configs/wrap_comments/false.rs b/rustfmt-core/tests/target/configs/wrap_comments/false.rs similarity index 100% rename from tests/target/configs/wrap_comments/false.rs rename to rustfmt-core/tests/target/configs/wrap_comments/false.rs diff --git a/tests/target/configs/wrap_comments/true.rs b/rustfmt-core/tests/target/configs/wrap_comments/true.rs similarity index 100% rename from tests/target/configs/wrap_comments/true.rs rename to rustfmt-core/tests/target/configs/wrap_comments/true.rs diff --git a/tests/target/control-brace-style-always-next-line.rs b/rustfmt-core/tests/target/control-brace-style-always-next-line.rs similarity index 100% rename from tests/target/control-brace-style-always-next-line.rs rename to rustfmt-core/tests/target/control-brace-style-always-next-line.rs diff --git a/tests/target/control-brace-style-always-same-line.rs b/rustfmt-core/tests/target/control-brace-style-always-same-line.rs similarity index 100% rename from tests/target/control-brace-style-always-same-line.rs rename to rustfmt-core/tests/target/control-brace-style-always-same-line.rs diff --git a/tests/target/doc.rs b/rustfmt-core/tests/target/doc.rs similarity index 100% rename from tests/target/doc.rs rename to rustfmt-core/tests/target/doc.rs diff --git a/tests/target/else-if-brace-style-always-next-line.rs b/rustfmt-core/tests/target/else-if-brace-style-always-next-line.rs similarity index 100% rename from tests/target/else-if-brace-style-always-next-line.rs rename to rustfmt-core/tests/target/else-if-brace-style-always-next-line.rs diff --git a/tests/target/else-if-brace-style-always-same-line.rs b/rustfmt-core/tests/target/else-if-brace-style-always-same-line.rs similarity index 100% rename from tests/target/else-if-brace-style-always-same-line.rs rename to rustfmt-core/tests/target/else-if-brace-style-always-same-line.rs diff --git a/tests/target/else-if-brace-style-closing-next-line.rs b/rustfmt-core/tests/target/else-if-brace-style-closing-next-line.rs similarity index 100% rename from tests/target/else-if-brace-style-closing-next-line.rs rename to rustfmt-core/tests/target/else-if-brace-style-closing-next-line.rs diff --git a/tests/target/empty-tuple-no-conversion-to-unit-struct.rs b/rustfmt-core/tests/target/empty-tuple-no-conversion-to-unit-struct.rs similarity index 100% rename from tests/target/empty-tuple-no-conversion-to-unit-struct.rs rename to rustfmt-core/tests/target/empty-tuple-no-conversion-to-unit-struct.rs diff --git a/tests/target/empty_file.rs b/rustfmt-core/tests/target/empty_file.rs similarity index 100% rename from tests/target/empty_file.rs rename to rustfmt-core/tests/target/empty_file.rs diff --git a/tests/target/enum.rs b/rustfmt-core/tests/target/enum.rs similarity index 100% rename from tests/target/enum.rs rename to rustfmt-core/tests/target/enum.rs diff --git a/tests/target/expr-block.rs b/rustfmt-core/tests/target/expr-block.rs similarity index 100% rename from tests/target/expr-block.rs rename to rustfmt-core/tests/target/expr-block.rs diff --git a/tests/target/expr.rs b/rustfmt-core/tests/target/expr.rs similarity index 100% rename from tests/target/expr.rs rename to rustfmt-core/tests/target/expr.rs diff --git a/tests/target/extern.rs b/rustfmt-core/tests/target/extern.rs similarity index 100% rename from tests/target/extern.rs rename to rustfmt-core/tests/target/extern.rs diff --git a/tests/target/extern_not_explicit.rs b/rustfmt-core/tests/target/extern_not_explicit.rs similarity index 100% rename from tests/target/extern_not_explicit.rs rename to rustfmt-core/tests/target/extern_not_explicit.rs diff --git a/tests/target/file-lines-1.rs b/rustfmt-core/tests/target/file-lines-1.rs similarity index 100% rename from tests/target/file-lines-1.rs rename to rustfmt-core/tests/target/file-lines-1.rs diff --git a/tests/target/file-lines-2.rs b/rustfmt-core/tests/target/file-lines-2.rs similarity index 100% rename from tests/target/file-lines-2.rs rename to rustfmt-core/tests/target/file-lines-2.rs diff --git a/tests/target/file-lines-3.rs b/rustfmt-core/tests/target/file-lines-3.rs similarity index 100% rename from tests/target/file-lines-3.rs rename to rustfmt-core/tests/target/file-lines-3.rs diff --git a/tests/target/file-lines-4.rs b/rustfmt-core/tests/target/file-lines-4.rs similarity index 100% rename from tests/target/file-lines-4.rs rename to rustfmt-core/tests/target/file-lines-4.rs diff --git a/tests/target/file-lines-5.rs b/rustfmt-core/tests/target/file-lines-5.rs similarity index 100% rename from tests/target/file-lines-5.rs rename to rustfmt-core/tests/target/file-lines-5.rs diff --git a/tests/target/file-lines-6.rs b/rustfmt-core/tests/target/file-lines-6.rs similarity index 100% rename from tests/target/file-lines-6.rs rename to rustfmt-core/tests/target/file-lines-6.rs diff --git a/tests/target/file-lines-item.rs b/rustfmt-core/tests/target/file-lines-item.rs similarity index 100% rename from tests/target/file-lines-item.rs rename to rustfmt-core/tests/target/file-lines-item.rs diff --git a/tests/target/fn-args-with-last-line-comment.rs b/rustfmt-core/tests/target/fn-args-with-last-line-comment.rs similarity index 100% rename from tests/target/fn-args-with-last-line-comment.rs rename to rustfmt-core/tests/target/fn-args-with-last-line-comment.rs diff --git a/tests/target/fn-custom-2.rs b/rustfmt-core/tests/target/fn-custom-2.rs similarity index 100% rename from tests/target/fn-custom-2.rs rename to rustfmt-core/tests/target/fn-custom-2.rs diff --git a/tests/target/fn-custom-3.rs b/rustfmt-core/tests/target/fn-custom-3.rs similarity index 100% rename from tests/target/fn-custom-3.rs rename to rustfmt-core/tests/target/fn-custom-3.rs diff --git a/tests/target/fn-custom-4.rs b/rustfmt-core/tests/target/fn-custom-4.rs similarity index 100% rename from tests/target/fn-custom-4.rs rename to rustfmt-core/tests/target/fn-custom-4.rs diff --git a/tests/target/fn-custom-6.rs b/rustfmt-core/tests/target/fn-custom-6.rs similarity index 100% rename from tests/target/fn-custom-6.rs rename to rustfmt-core/tests/target/fn-custom-6.rs diff --git a/tests/target/fn-custom-7.rs b/rustfmt-core/tests/target/fn-custom-7.rs similarity index 100% rename from tests/target/fn-custom-7.rs rename to rustfmt-core/tests/target/fn-custom-7.rs diff --git a/tests/target/fn-custom-8.rs b/rustfmt-core/tests/target/fn-custom-8.rs similarity index 100% rename from tests/target/fn-custom-8.rs rename to rustfmt-core/tests/target/fn-custom-8.rs diff --git a/tests/target/fn-custom.rs b/rustfmt-core/tests/target/fn-custom.rs similarity index 100% rename from tests/target/fn-custom.rs rename to rustfmt-core/tests/target/fn-custom.rs diff --git a/tests/target/fn-simple.rs b/rustfmt-core/tests/target/fn-simple.rs similarity index 100% rename from tests/target/fn-simple.rs rename to rustfmt-core/tests/target/fn-simple.rs diff --git a/tests/target/fn-single-line.rs b/rustfmt-core/tests/target/fn-single-line.rs similarity index 100% rename from tests/target/fn-single-line.rs rename to rustfmt-core/tests/target/fn-single-line.rs diff --git a/tests/target/fn-ty.rs b/rustfmt-core/tests/target/fn-ty.rs similarity index 100% rename from tests/target/fn-ty.rs rename to rustfmt-core/tests/target/fn-ty.rs diff --git a/tests/target/fn.rs b/rustfmt-core/tests/target/fn.rs similarity index 100% rename from tests/target/fn.rs rename to rustfmt-core/tests/target/fn.rs diff --git a/tests/target/fn_args_density-vertical.rs b/rustfmt-core/tests/target/fn_args_density-vertical.rs similarity index 100% rename from tests/target/fn_args_density-vertical.rs rename to rustfmt-core/tests/target/fn_args_density-vertical.rs diff --git a/tests/target/fn_args_indent-block.rs b/rustfmt-core/tests/target/fn_args_indent-block.rs similarity index 100% rename from tests/target/fn_args_indent-block.rs rename to rustfmt-core/tests/target/fn_args_indent-block.rs diff --git a/tests/target/fn_once.rs b/rustfmt-core/tests/target/fn_once.rs similarity index 100% rename from tests/target/fn_once.rs rename to rustfmt-core/tests/target/fn_once.rs diff --git a/tests/target/hard-tabs.rs b/rustfmt-core/tests/target/hard-tabs.rs similarity index 100% rename from tests/target/hard-tabs.rs rename to rustfmt-core/tests/target/hard-tabs.rs diff --git a/tests/target/hello.rs b/rustfmt-core/tests/target/hello.rs similarity index 100% rename from tests/target/hello.rs rename to rustfmt-core/tests/target/hello.rs diff --git a/tests/target/immovable_generators.rs b/rustfmt-core/tests/target/immovable_generators.rs similarity index 100% rename from tests/target/immovable_generators.rs rename to rustfmt-core/tests/target/immovable_generators.rs diff --git a/tests/target/impl.rs b/rustfmt-core/tests/target/impl.rs similarity index 100% rename from tests/target/impl.rs rename to rustfmt-core/tests/target/impl.rs diff --git a/tests/target/impls.rs b/rustfmt-core/tests/target/impls.rs similarity index 100% rename from tests/target/impls.rs rename to rustfmt-core/tests/target/impls.rs diff --git a/tests/target/import-fencepost-length.rs b/rustfmt-core/tests/target/import-fencepost-length.rs similarity index 100% rename from tests/target/import-fencepost-length.rs rename to rustfmt-core/tests/target/import-fencepost-length.rs diff --git a/tests/target/imports-reorder-lines-and-items.rs b/rustfmt-core/tests/target/imports-reorder-lines-and-items.rs similarity index 100% rename from tests/target/imports-reorder-lines-and-items.rs rename to rustfmt-core/tests/target/imports-reorder-lines-and-items.rs diff --git a/tests/target/imports-reorder-lines.rs b/rustfmt-core/tests/target/imports-reorder-lines.rs similarity index 100% rename from tests/target/imports-reorder-lines.rs rename to rustfmt-core/tests/target/imports-reorder-lines.rs diff --git a/tests/target/imports-reorder.rs b/rustfmt-core/tests/target/imports-reorder.rs similarity index 100% rename from tests/target/imports-reorder.rs rename to rustfmt-core/tests/target/imports-reorder.rs diff --git a/tests/target/imports.rs b/rustfmt-core/tests/target/imports.rs similarity index 100% rename from tests/target/imports.rs rename to rustfmt-core/tests/target/imports.rs diff --git a/tests/target/indented-impl.rs b/rustfmt-core/tests/target/indented-impl.rs similarity index 100% rename from tests/target/indented-impl.rs rename to rustfmt-core/tests/target/indented-impl.rs diff --git a/tests/target/issue-1021.rs b/rustfmt-core/tests/target/issue-1021.rs similarity index 100% rename from tests/target/issue-1021.rs rename to rustfmt-core/tests/target/issue-1021.rs diff --git a/tests/target/issue-1049.rs b/rustfmt-core/tests/target/issue-1049.rs similarity index 100% rename from tests/target/issue-1049.rs rename to rustfmt-core/tests/target/issue-1049.rs diff --git a/tests/target/issue-1055.rs b/rustfmt-core/tests/target/issue-1055.rs similarity index 100% rename from tests/target/issue-1055.rs rename to rustfmt-core/tests/target/issue-1055.rs diff --git a/tests/target/issue-1111.rs b/rustfmt-core/tests/target/issue-1111.rs similarity index 100% rename from tests/target/issue-1111.rs rename to rustfmt-core/tests/target/issue-1111.rs diff --git a/tests/target/issue-1113.rs b/rustfmt-core/tests/target/issue-1113.rs similarity index 100% rename from tests/target/issue-1113.rs rename to rustfmt-core/tests/target/issue-1113.rs diff --git a/tests/target/issue-1120.rs b/rustfmt-core/tests/target/issue-1120.rs similarity index 100% rename from tests/target/issue-1120.rs rename to rustfmt-core/tests/target/issue-1120.rs diff --git a/tests/target/issue-1124.rs b/rustfmt-core/tests/target/issue-1124.rs similarity index 100% rename from tests/target/issue-1124.rs rename to rustfmt-core/tests/target/issue-1124.rs diff --git a/tests/target/issue-1127.rs b/rustfmt-core/tests/target/issue-1127.rs similarity index 100% rename from tests/target/issue-1127.rs rename to rustfmt-core/tests/target/issue-1127.rs diff --git a/tests/target/issue-1158.rs b/rustfmt-core/tests/target/issue-1158.rs similarity index 100% rename from tests/target/issue-1158.rs rename to rustfmt-core/tests/target/issue-1158.rs diff --git a/tests/target/issue-1177.rs b/rustfmt-core/tests/target/issue-1177.rs similarity index 100% rename from tests/target/issue-1177.rs rename to rustfmt-core/tests/target/issue-1177.rs diff --git a/tests/target/issue-1192.rs b/rustfmt-core/tests/target/issue-1192.rs similarity index 100% rename from tests/target/issue-1192.rs rename to rustfmt-core/tests/target/issue-1192.rs diff --git a/tests/target/issue-1211.rs b/rustfmt-core/tests/target/issue-1211.rs similarity index 100% rename from tests/target/issue-1211.rs rename to rustfmt-core/tests/target/issue-1211.rs diff --git a/tests/target/issue-1214.rs b/rustfmt-core/tests/target/issue-1214.rs similarity index 100% rename from tests/target/issue-1214.rs rename to rustfmt-core/tests/target/issue-1214.rs diff --git a/tests/target/issue-1216.rs b/rustfmt-core/tests/target/issue-1216.rs similarity index 100% rename from tests/target/issue-1216.rs rename to rustfmt-core/tests/target/issue-1216.rs diff --git a/tests/target/issue-1239.rs b/rustfmt-core/tests/target/issue-1239.rs similarity index 100% rename from tests/target/issue-1239.rs rename to rustfmt-core/tests/target/issue-1239.rs diff --git a/tests/target/issue-1247.rs b/rustfmt-core/tests/target/issue-1247.rs similarity index 100% rename from tests/target/issue-1247.rs rename to rustfmt-core/tests/target/issue-1247.rs diff --git a/tests/target/issue-1255.rs b/rustfmt-core/tests/target/issue-1255.rs similarity index 100% rename from tests/target/issue-1255.rs rename to rustfmt-core/tests/target/issue-1255.rs diff --git a/tests/target/issue-1278.rs b/rustfmt-core/tests/target/issue-1278.rs similarity index 100% rename from tests/target/issue-1278.rs rename to rustfmt-core/tests/target/issue-1278.rs diff --git a/tests/target/issue-1350.rs b/rustfmt-core/tests/target/issue-1350.rs similarity index 100% rename from tests/target/issue-1350.rs rename to rustfmt-core/tests/target/issue-1350.rs diff --git a/tests/target/issue-1366.rs b/rustfmt-core/tests/target/issue-1366.rs similarity index 100% rename from tests/target/issue-1366.rs rename to rustfmt-core/tests/target/issue-1366.rs diff --git a/tests/target/issue-1397.rs b/rustfmt-core/tests/target/issue-1397.rs similarity index 100% rename from tests/target/issue-1397.rs rename to rustfmt-core/tests/target/issue-1397.rs diff --git a/tests/target/issue-1468.rs b/rustfmt-core/tests/target/issue-1468.rs similarity index 100% rename from tests/target/issue-1468.rs rename to rustfmt-core/tests/target/issue-1468.rs diff --git a/tests/target/issue-1598.rs b/rustfmt-core/tests/target/issue-1598.rs similarity index 100% rename from tests/target/issue-1598.rs rename to rustfmt-core/tests/target/issue-1598.rs diff --git a/tests/target/issue-1624.rs b/rustfmt-core/tests/target/issue-1624.rs similarity index 100% rename from tests/target/issue-1624.rs rename to rustfmt-core/tests/target/issue-1624.rs diff --git a/tests/target/issue-1681.rs b/rustfmt-core/tests/target/issue-1681.rs similarity index 100% rename from tests/target/issue-1681.rs rename to rustfmt-core/tests/target/issue-1681.rs diff --git a/tests/target/issue-1693.rs b/rustfmt-core/tests/target/issue-1693.rs similarity index 100% rename from tests/target/issue-1693.rs rename to rustfmt-core/tests/target/issue-1693.rs diff --git a/tests/target/issue-1703.rs b/rustfmt-core/tests/target/issue-1703.rs similarity index 100% rename from tests/target/issue-1703.rs rename to rustfmt-core/tests/target/issue-1703.rs diff --git a/tests/target/issue-1800.rs b/rustfmt-core/tests/target/issue-1800.rs similarity index 100% rename from tests/target/issue-1800.rs rename to rustfmt-core/tests/target/issue-1800.rs diff --git a/tests/target/issue-1802.rs b/rustfmt-core/tests/target/issue-1802.rs similarity index 100% rename from tests/target/issue-1802.rs rename to rustfmt-core/tests/target/issue-1802.rs diff --git a/tests/target/issue-1824.rs b/rustfmt-core/tests/target/issue-1824.rs similarity index 100% rename from tests/target/issue-1824.rs rename to rustfmt-core/tests/target/issue-1824.rs diff --git a/tests/target/issue-1914.rs b/rustfmt-core/tests/target/issue-1914.rs similarity index 100% rename from tests/target/issue-1914.rs rename to rustfmt-core/tests/target/issue-1914.rs diff --git a/tests/target/issue-2025.rs b/rustfmt-core/tests/target/issue-2025.rs similarity index 100% rename from tests/target/issue-2025.rs rename to rustfmt-core/tests/target/issue-2025.rs diff --git a/tests/target/issue-2103.rs b/rustfmt-core/tests/target/issue-2103.rs similarity index 100% rename from tests/target/issue-2103.rs rename to rustfmt-core/tests/target/issue-2103.rs diff --git a/tests/target/issue-2111.rs b/rustfmt-core/tests/target/issue-2111.rs similarity index 100% rename from tests/target/issue-2111.rs rename to rustfmt-core/tests/target/issue-2111.rs diff --git a/tests/target/issue-2123.rs b/rustfmt-core/tests/target/issue-2123.rs similarity index 100% rename from tests/target/issue-2123.rs rename to rustfmt-core/tests/target/issue-2123.rs diff --git a/tests/target/issue-2164.rs b/rustfmt-core/tests/target/issue-2164.rs similarity index 100% rename from tests/target/issue-2164.rs rename to rustfmt-core/tests/target/issue-2164.rs diff --git a/tests/target/issue-2179.rs b/rustfmt-core/tests/target/issue-2179.rs similarity index 100% rename from tests/target/issue-2179.rs rename to rustfmt-core/tests/target/issue-2179.rs diff --git a/tests/target/issue-2197.rs b/rustfmt-core/tests/target/issue-2197.rs similarity index 100% rename from tests/target/issue-2197.rs rename to rustfmt-core/tests/target/issue-2197.rs diff --git a/tests/target/issue-2256.rs b/rustfmt-core/tests/target/issue-2256.rs similarity index 100% rename from tests/target/issue-2256.rs rename to rustfmt-core/tests/target/issue-2256.rs diff --git a/tests/target/issue-2324.rs b/rustfmt-core/tests/target/issue-2324.rs similarity index 100% rename from tests/target/issue-2324.rs rename to rustfmt-core/tests/target/issue-2324.rs diff --git a/tests/target/issue-2329.rs b/rustfmt-core/tests/target/issue-2329.rs similarity index 100% rename from tests/target/issue-2329.rs rename to rustfmt-core/tests/target/issue-2329.rs diff --git a/tests/target/issue-2342.rs b/rustfmt-core/tests/target/issue-2342.rs similarity index 100% rename from tests/target/issue-2342.rs rename to rustfmt-core/tests/target/issue-2342.rs diff --git a/tests/target/issue-2401.rs b/rustfmt-core/tests/target/issue-2401.rs similarity index 100% rename from tests/target/issue-2401.rs rename to rustfmt-core/tests/target/issue-2401.rs diff --git a/tests/target/issue-447.rs b/rustfmt-core/tests/target/issue-447.rs similarity index 100% rename from tests/target/issue-447.rs rename to rustfmt-core/tests/target/issue-447.rs diff --git a/tests/target/issue-510.rs b/rustfmt-core/tests/target/issue-510.rs similarity index 100% rename from tests/target/issue-510.rs rename to rustfmt-core/tests/target/issue-510.rs diff --git a/tests/target/issue-64.rs b/rustfmt-core/tests/target/issue-64.rs similarity index 100% rename from tests/target/issue-64.rs rename to rustfmt-core/tests/target/issue-64.rs diff --git a/tests/target/issue-691.rs b/rustfmt-core/tests/target/issue-691.rs similarity index 100% rename from tests/target/issue-691.rs rename to rustfmt-core/tests/target/issue-691.rs diff --git a/tests/target/issue-770.rs b/rustfmt-core/tests/target/issue-770.rs similarity index 100% rename from tests/target/issue-770.rs rename to rustfmt-core/tests/target/issue-770.rs diff --git a/tests/target/issue-811.rs b/rustfmt-core/tests/target/issue-811.rs similarity index 100% rename from tests/target/issue-811.rs rename to rustfmt-core/tests/target/issue-811.rs diff --git a/tests/target/issue-831.rs b/rustfmt-core/tests/target/issue-831.rs similarity index 100% rename from tests/target/issue-831.rs rename to rustfmt-core/tests/target/issue-831.rs diff --git a/tests/target/issue-850.rs b/rustfmt-core/tests/target/issue-850.rs similarity index 100% rename from tests/target/issue-850.rs rename to rustfmt-core/tests/target/issue-850.rs diff --git a/tests/target/issue-855.rs b/rustfmt-core/tests/target/issue-855.rs similarity index 100% rename from tests/target/issue-855.rs rename to rustfmt-core/tests/target/issue-855.rs diff --git a/tests/target/issue-913.rs b/rustfmt-core/tests/target/issue-913.rs similarity index 100% rename from tests/target/issue-913.rs rename to rustfmt-core/tests/target/issue-913.rs diff --git a/tests/target/issue-945.rs b/rustfmt-core/tests/target/issue-945.rs similarity index 100% rename from tests/target/issue-945.rs rename to rustfmt-core/tests/target/issue-945.rs diff --git a/tests/target/issue-977.rs b/rustfmt-core/tests/target/issue-977.rs similarity index 100% rename from tests/target/issue-977.rs rename to rustfmt-core/tests/target/issue-977.rs diff --git a/tests/target/item-brace-style-always-next-line.rs b/rustfmt-core/tests/target/item-brace-style-always-next-line.rs similarity index 100% rename from tests/target/item-brace-style-always-next-line.rs rename to rustfmt-core/tests/target/item-brace-style-always-next-line.rs diff --git a/tests/target/item-brace-style-prefer-same-line.rs b/rustfmt-core/tests/target/item-brace-style-prefer-same-line.rs similarity index 100% rename from tests/target/item-brace-style-prefer-same-line.rs rename to rustfmt-core/tests/target/item-brace-style-prefer-same-line.rs diff --git a/tests/target/item-brace-style-same-line-where.rs b/rustfmt-core/tests/target/item-brace-style-same-line-where.rs similarity index 100% rename from tests/target/item-brace-style-same-line-where.rs rename to rustfmt-core/tests/target/item-brace-style-same-line-where.rs diff --git a/tests/target/large-block.rs b/rustfmt-core/tests/target/large-block.rs similarity index 100% rename from tests/target/large-block.rs rename to rustfmt-core/tests/target/large-block.rs diff --git a/tests/target/large_vec.rs b/rustfmt-core/tests/target/large_vec.rs similarity index 100% rename from tests/target/large_vec.rs rename to rustfmt-core/tests/target/large_vec.rs diff --git a/tests/target/long-fn-1.rs b/rustfmt-core/tests/target/long-fn-1.rs similarity index 100% rename from tests/target/long-fn-1.rs rename to rustfmt-core/tests/target/long-fn-1.rs diff --git a/tests/target/long-match-arms-brace-newline.rs b/rustfmt-core/tests/target/long-match-arms-brace-newline.rs similarity index 100% rename from tests/target/long-match-arms-brace-newline.rs rename to rustfmt-core/tests/target/long-match-arms-brace-newline.rs diff --git a/tests/target/long_field_access.rs b/rustfmt-core/tests/target/long_field_access.rs similarity index 100% rename from tests/target/long_field_access.rs rename to rustfmt-core/tests/target/long_field_access.rs diff --git a/tests/target/loop.rs b/rustfmt-core/tests/target/loop.rs similarity index 100% rename from tests/target/loop.rs rename to rustfmt-core/tests/target/loop.rs diff --git a/tests/target/macro_not_expr.rs b/rustfmt-core/tests/target/macro_not_expr.rs similarity index 100% rename from tests/target/macro_not_expr.rs rename to rustfmt-core/tests/target/macro_not_expr.rs diff --git a/tests/target/macro_rules.rs b/rustfmt-core/tests/target/macro_rules.rs similarity index 100% rename from tests/target/macro_rules.rs rename to rustfmt-core/tests/target/macro_rules.rs diff --git a/tests/target/macros.rs b/rustfmt-core/tests/target/macros.rs similarity index 100% rename from tests/target/macros.rs rename to rustfmt-core/tests/target/macros.rs diff --git a/tests/target/match-block-trailing-comma.rs b/rustfmt-core/tests/target/match-block-trailing-comma.rs similarity index 100% rename from tests/target/match-block-trailing-comma.rs rename to rustfmt-core/tests/target/match-block-trailing-comma.rs diff --git a/tests/target/match-nowrap-trailing-comma.rs b/rustfmt-core/tests/target/match-nowrap-trailing-comma.rs similarity index 100% rename from tests/target/match-nowrap-trailing-comma.rs rename to rustfmt-core/tests/target/match-nowrap-trailing-comma.rs diff --git a/tests/target/match-nowrap.rs b/rustfmt-core/tests/target/match-nowrap.rs similarity index 100% rename from tests/target/match-nowrap.rs rename to rustfmt-core/tests/target/match-nowrap.rs diff --git a/tests/target/match.rs b/rustfmt-core/tests/target/match.rs similarity index 100% rename from tests/target/match.rs rename to rustfmt-core/tests/target/match.rs diff --git a/tests/target/max-line-length-in-chars.rs b/rustfmt-core/tests/target/max-line-length-in-chars.rs similarity index 100% rename from tests/target/max-line-length-in-chars.rs rename to rustfmt-core/tests/target/max-line-length-in-chars.rs diff --git a/tests/target/mod-1.rs b/rustfmt-core/tests/target/mod-1.rs similarity index 100% rename from tests/target/mod-1.rs rename to rustfmt-core/tests/target/mod-1.rs diff --git a/tests/target/mod-2.rs b/rustfmt-core/tests/target/mod-2.rs similarity index 100% rename from tests/target/mod-2.rs rename to rustfmt-core/tests/target/mod-2.rs diff --git a/tests/target/mod_skip_child.rs b/rustfmt-core/tests/target/mod_skip_child.rs similarity index 100% rename from tests/target/mod_skip_child.rs rename to rustfmt-core/tests/target/mod_skip_child.rs diff --git a/tests/target/mulit-file.rs b/rustfmt-core/tests/target/mulit-file.rs similarity index 100% rename from tests/target/mulit-file.rs rename to rustfmt-core/tests/target/mulit-file.rs diff --git a/tests/target/multiple.rs b/rustfmt-core/tests/target/multiple.rs similarity index 100% rename from tests/target/multiple.rs rename to rustfmt-core/tests/target/multiple.rs diff --git a/tests/target/nested-if-else.rs b/rustfmt-core/tests/target/nested-if-else.rs similarity index 100% rename from tests/target/nested-if-else.rs rename to rustfmt-core/tests/target/nested-if-else.rs diff --git a/tests/target/nested-visual-block.rs b/rustfmt-core/tests/target/nested-visual-block.rs similarity index 100% rename from tests/target/nested-visual-block.rs rename to rustfmt-core/tests/target/nested-visual-block.rs diff --git a/tests/target/nested_skipped/mod.rs b/rustfmt-core/tests/target/nested_skipped/mod.rs similarity index 100% rename from tests/target/nested_skipped/mod.rs rename to rustfmt-core/tests/target/nested_skipped/mod.rs diff --git a/tests/target/nestedmod/mod.rs b/rustfmt-core/tests/target/nestedmod/mod.rs similarity index 100% rename from tests/target/nestedmod/mod.rs rename to rustfmt-core/tests/target/nestedmod/mod.rs diff --git a/tests/target/nestedmod/mod2a.rs b/rustfmt-core/tests/target/nestedmod/mod2a.rs similarity index 100% rename from tests/target/nestedmod/mod2a.rs rename to rustfmt-core/tests/target/nestedmod/mod2a.rs diff --git a/tests/target/nestedmod/mod2b.rs b/rustfmt-core/tests/target/nestedmod/mod2b.rs similarity index 100% rename from tests/target/nestedmod/mod2b.rs rename to rustfmt-core/tests/target/nestedmod/mod2b.rs diff --git a/tests/target/nestedmod/mod2c.rs b/rustfmt-core/tests/target/nestedmod/mod2c.rs similarity index 100% rename from tests/target/nestedmod/mod2c.rs rename to rustfmt-core/tests/target/nestedmod/mod2c.rs diff --git a/tests/target/nestedmod/mymod1/mod3a.rs b/rustfmt-core/tests/target/nestedmod/mymod1/mod3a.rs similarity index 100% rename from tests/target/nestedmod/mymod1/mod3a.rs rename to rustfmt-core/tests/target/nestedmod/mymod1/mod3a.rs diff --git a/tests/target/nestedmod/submod2/a.rs b/rustfmt-core/tests/target/nestedmod/submod2/a.rs similarity index 100% rename from tests/target/nestedmod/submod2/a.rs rename to rustfmt-core/tests/target/nestedmod/submod2/a.rs diff --git a/tests/target/nestedmod/submod2/mod.rs b/rustfmt-core/tests/target/nestedmod/submod2/mod.rs similarity index 100% rename from tests/target/nestedmod/submod2/mod.rs rename to rustfmt-core/tests/target/nestedmod/submod2/mod.rs diff --git a/tests/target/no_new_line_beginning.rs b/rustfmt-core/tests/target/no_new_line_beginning.rs similarity index 100% rename from tests/target/no_new_line_beginning.rs rename to rustfmt-core/tests/target/no_new_line_beginning.rs diff --git a/tests/target/other.rs b/rustfmt-core/tests/target/other.rs similarity index 100% rename from tests/target/other.rs rename to rustfmt-core/tests/target/other.rs diff --git a/tests/target/paths.rs b/rustfmt-core/tests/target/paths.rs similarity index 100% rename from tests/target/paths.rs rename to rustfmt-core/tests/target/paths.rs diff --git a/tests/target/pattern-condense-wildcards.rs b/rustfmt-core/tests/target/pattern-condense-wildcards.rs similarity index 100% rename from tests/target/pattern-condense-wildcards.rs rename to rustfmt-core/tests/target/pattern-condense-wildcards.rs diff --git a/tests/target/pattern.rs b/rustfmt-core/tests/target/pattern.rs similarity index 100% rename from tests/target/pattern.rs rename to rustfmt-core/tests/target/pattern.rs diff --git a/tests/target/pub-restricted.rs b/rustfmt-core/tests/target/pub-restricted.rs similarity index 100% rename from tests/target/pub-restricted.rs rename to rustfmt-core/tests/target/pub-restricted.rs diff --git a/tests/target/remove_blank_lines.rs b/rustfmt-core/tests/target/remove_blank_lines.rs similarity index 100% rename from tests/target/remove_blank_lines.rs rename to rustfmt-core/tests/target/remove_blank_lines.rs diff --git a/tests/target/single-line-if-else.rs b/rustfmt-core/tests/target/single-line-if-else.rs similarity index 100% rename from tests/target/single-line-if-else.rs rename to rustfmt-core/tests/target/single-line-if-else.rs diff --git a/tests/target/skip.rs b/rustfmt-core/tests/target/skip.rs similarity index 100% rename from tests/target/skip.rs rename to rustfmt-core/tests/target/skip.rs diff --git a/tests/target/skip_mod.rs b/rustfmt-core/tests/target/skip_mod.rs similarity index 100% rename from tests/target/skip_mod.rs rename to rustfmt-core/tests/target/skip_mod.rs diff --git a/tests/target/soft-wrapping.rs b/rustfmt-core/tests/target/soft-wrapping.rs similarity index 100% rename from tests/target/soft-wrapping.rs rename to rustfmt-core/tests/target/soft-wrapping.rs diff --git a/tests/target/space-not-before-newline.rs b/rustfmt-core/tests/target/space-not-before-newline.rs similarity index 100% rename from tests/target/space-not-before-newline.rs rename to rustfmt-core/tests/target/space-not-before-newline.rs diff --git a/tests/target/spaces-around-ranges.rs b/rustfmt-core/tests/target/spaces-around-ranges.rs similarity index 100% rename from tests/target/spaces-around-ranges.rs rename to rustfmt-core/tests/target/spaces-around-ranges.rs diff --git a/tests/target/static.rs b/rustfmt-core/tests/target/static.rs similarity index 100% rename from tests/target/static.rs rename to rustfmt-core/tests/target/static.rs diff --git a/tests/target/string-lit-2.rs b/rustfmt-core/tests/target/string-lit-2.rs similarity index 100% rename from tests/target/string-lit-2.rs rename to rustfmt-core/tests/target/string-lit-2.rs diff --git a/tests/target/string-lit-custom.rs b/rustfmt-core/tests/target/string-lit-custom.rs similarity index 100% rename from tests/target/string-lit-custom.rs rename to rustfmt-core/tests/target/string-lit-custom.rs diff --git a/tests/target/string-lit.rs b/rustfmt-core/tests/target/string-lit.rs similarity index 100% rename from tests/target/string-lit.rs rename to rustfmt-core/tests/target/string-lit.rs diff --git a/tests/target/string_punctuation.rs b/rustfmt-core/tests/target/string_punctuation.rs similarity index 100% rename from tests/target/string_punctuation.rs rename to rustfmt-core/tests/target/string_punctuation.rs diff --git a/tests/target/struct-field-attributes.rs b/rustfmt-core/tests/target/struct-field-attributes.rs similarity index 100% rename from tests/target/struct-field-attributes.rs rename to rustfmt-core/tests/target/struct-field-attributes.rs diff --git a/tests/target/struct_lits.rs b/rustfmt-core/tests/target/struct_lits.rs similarity index 100% rename from tests/target/struct_lits.rs rename to rustfmt-core/tests/target/struct_lits.rs diff --git a/tests/target/struct_lits_multiline.rs b/rustfmt-core/tests/target/struct_lits_multiline.rs similarity index 100% rename from tests/target/struct_lits_multiline.rs rename to rustfmt-core/tests/target/struct_lits_multiline.rs diff --git a/tests/target/struct_lits_visual.rs b/rustfmt-core/tests/target/struct_lits_visual.rs similarity index 100% rename from tests/target/struct_lits_visual.rs rename to rustfmt-core/tests/target/struct_lits_visual.rs diff --git a/tests/target/struct_lits_visual_multiline.rs b/rustfmt-core/tests/target/struct_lits_visual_multiline.rs similarity index 100% rename from tests/target/struct_lits_visual_multiline.rs rename to rustfmt-core/tests/target/struct_lits_visual_multiline.rs diff --git a/tests/target/struct_tuple_visual.rs b/rustfmt-core/tests/target/struct_tuple_visual.rs similarity index 100% rename from tests/target/struct_tuple_visual.rs rename to rustfmt-core/tests/target/struct_tuple_visual.rs diff --git a/tests/target/structs.rs b/rustfmt-core/tests/target/structs.rs similarity index 100% rename from tests/target/structs.rs rename to rustfmt-core/tests/target/structs.rs diff --git a/tests/target/trailing-comma-never.rs b/rustfmt-core/tests/target/trailing-comma-never.rs similarity index 100% rename from tests/target/trailing-comma-never.rs rename to rustfmt-core/tests/target/trailing-comma-never.rs diff --git a/tests/target/trailing_commas.rs b/rustfmt-core/tests/target/trailing_commas.rs similarity index 100% rename from tests/target/trailing_commas.rs rename to rustfmt-core/tests/target/trailing_commas.rs diff --git a/tests/target/trait.rs b/rustfmt-core/tests/target/trait.rs similarity index 100% rename from tests/target/trait.rs rename to rustfmt-core/tests/target/trait.rs diff --git a/tests/target/try-conversion.rs b/rustfmt-core/tests/target/try-conversion.rs similarity index 100% rename from tests/target/try-conversion.rs rename to rustfmt-core/tests/target/try-conversion.rs diff --git a/tests/target/tuple.rs b/rustfmt-core/tests/target/tuple.rs similarity index 100% rename from tests/target/tuple.rs rename to rustfmt-core/tests/target/tuple.rs diff --git a/tests/target/type-ascription.rs b/rustfmt-core/tests/target/type-ascription.rs similarity index 100% rename from tests/target/type-ascription.rs rename to rustfmt-core/tests/target/type-ascription.rs diff --git a/tests/target/type-punctuation.rs b/rustfmt-core/tests/target/type-punctuation.rs similarity index 100% rename from tests/target/type-punctuation.rs rename to rustfmt-core/tests/target/type-punctuation.rs diff --git a/tests/target/type.rs b/rustfmt-core/tests/target/type.rs similarity index 100% rename from tests/target/type.rs rename to rustfmt-core/tests/target/type.rs diff --git a/tests/target/type_alias.rs b/rustfmt-core/tests/target/type_alias.rs similarity index 100% rename from tests/target/type_alias.rs rename to rustfmt-core/tests/target/type_alias.rs diff --git a/tests/target/unindent_if_else_cond_comment.rs b/rustfmt-core/tests/target/unindent_if_else_cond_comment.rs similarity index 100% rename from tests/target/unindent_if_else_cond_comment.rs rename to rustfmt-core/tests/target/unindent_if_else_cond_comment.rs diff --git a/tests/target/unions.rs b/rustfmt-core/tests/target/unions.rs similarity index 100% rename from tests/target/unions.rs rename to rustfmt-core/tests/target/unions.rs diff --git a/tests/target/where-clause-rfc.rs b/rustfmt-core/tests/target/where-clause-rfc.rs similarity index 100% rename from tests/target/where-clause-rfc.rs rename to rustfmt-core/tests/target/where-clause-rfc.rs diff --git a/tests/target/where-clause.rs b/rustfmt-core/tests/target/where-clause.rs similarity index 100% rename from tests/target/where-clause.rs rename to rustfmt-core/tests/target/where-clause.rs diff --git a/tests/writemode/source/fn-single-line.rs b/rustfmt-core/tests/writemode/source/fn-single-line.rs similarity index 100% rename from tests/writemode/source/fn-single-line.rs rename to rustfmt-core/tests/writemode/source/fn-single-line.rs diff --git a/tests/writemode/target/checkstyle.xml b/rustfmt-core/tests/writemode/target/checkstyle.xml similarity index 100% rename from tests/writemode/target/checkstyle.xml rename to rustfmt-core/tests/writemode/target/checkstyle.xml diff --git a/rustfmt-format-diff/Cargo.toml b/rustfmt-format-diff/Cargo.toml new file mode 100644 index 000000000000..a74c08616bd0 --- /dev/null +++ b/rustfmt-format-diff/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "rustfmt-format-diff" +version = "0.4.0" +authors = ["Nicholas Cameron ", "The Rustfmt developers"] +description = "Run rustfmt against diff" +repository = "https://github.com/rust-lang-nursery/rustfmt" +readme = "README.md" +license = "Apache-2.0/MIT" +categories = ["development-tools"] + +[[bin]] +name = "rustfmt-format-diff" + +[dependencies] +env_logger = "0.4" +getopts = "0.2" +log = "0.3" +regex = "0.2" +serde = "1.0" +serde_derive = "1.0" +serde_json = "1.0" \ No newline at end of file diff --git a/src/bin/rustfmt-format-diff.rs b/rustfmt-format-diff/src/main.rs similarity index 100% rename from src/bin/rustfmt-format-diff.rs rename to rustfmt-format-diff/src/main.rs diff --git a/src/bin/test/bindgen.diff b/rustfmt-format-diff/src/test/bindgen.diff similarity index 100% rename from src/bin/test/bindgen.diff rename to rustfmt-format-diff/src/test/bindgen.diff diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index cca1779a4a8d..000000000000 --- a/src/config.rs +++ /dev/null @@ -1,781 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate toml; - -use std::{env, fs}; -use std::cell::Cell; -use std::default::Default; -use std::fs::File; -use std::io::{Error, ErrorKind, Read}; -use std::path::{Path, PathBuf}; - -use Summary; -use file_lines::FileLines; -use lists::{ListTactic, SeparatorPlace, SeparatorTactic}; - -/// Check if we're in a nightly build. -/// -/// The environment variable `CFG_RELEASE_CHANNEL` is set during the rustc bootstrap -/// to "stable", "beta", or "nightly" depending on what toolchain is being built. -/// If we are being built as part of the stable or beta toolchains, we want -/// to disable unstable configuration options. -/// -/// If we're being built by cargo (e.g. `cargo +nightly install rustfmt-nightly`), -/// `CFG_RELEASE_CHANNEL` is not set. As we only support being built against the -/// nightly compiler when installed from crates.io, default to nightly mode. -macro_rules! is_nightly_channel { - () => { - option_env!("CFG_RELEASE_CHANNEL") - .map(|c| c == "nightly") - .unwrap_or(true) - }; -} - -macro_rules! configuration_option_enum{ - ($e:ident: $( $x:ident ),+ $(,)*) => { - #[derive(Copy, Clone, Eq, PartialEq, Debug)] - pub enum $e { - $( $x ),+ - } - - impl_enum_serialize_and_deserialize!($e, $( $x ),+); - } -} - -configuration_option_enum! { NewlineStyle: - Windows, // \r\n - Unix, // \n - Native, // \r\n in Windows, \n on other platforms -} - -configuration_option_enum! { BraceStyle: - AlwaysNextLine, - PreferSameLine, - // Prefer same line except where there is a where clause, in which case force - // the brace to the next line. - SameLineWhere, -} - -configuration_option_enum! { ControlBraceStyle: - // K&R style, Rust community default - AlwaysSameLine, - // Stroustrup style - ClosingNextLine, - // Allman style - AlwaysNextLine, -} - -configuration_option_enum! { IndentStyle: - // First line on the same line as the opening brace, all lines aligned with - // the first line. - Visual, - // First line is on a new line and all lines align with block indent. - Block, -} - -configuration_option_enum! { Density: - // Fit as much on one line as possible. - Compressed, - // Use more lines. - Tall, - // Place every item on a separate line. - Vertical, -} - -configuration_option_enum! { TypeDensity: - // No spaces around "=" and "+" - Compressed, - // Spaces around " = " and " + " - Wide, -} - -impl Density { - pub fn to_list_tactic(self) -> ListTactic { - match self { - Density::Compressed => ListTactic::Mixed, - Density::Tall => ListTactic::HorizontalVertical, - Density::Vertical => ListTactic::Vertical, - } - } -} - -configuration_option_enum! { ReportTactic: - Always, - Unnumbered, - Never, -} - -configuration_option_enum! { WriteMode: - // Backs the original file up and overwrites the original. - Replace, - // Overwrites original file without backup. - Overwrite, - // Writes the output to stdout. - Display, - // Writes the diff to stdout. - Diff, - // Displays how much of the input file was processed - Coverage, - // Unfancy stdout - Plain, - // Outputs a checkstyle XML file. - Checkstyle, -} - -configuration_option_enum! { Color: - // Always use color, whether it is a piped or terminal output - Always, - // Never use color - Never, - // Automatically use color, if supported by terminal - Auto, -} - -#[derive(Deserialize, Serialize, Clone, Debug)] -pub struct WidthHeuristics { - // Maximum width of the args of a function call before falling back - // to vertical formatting. - pub fn_call_width: usize, - // Maximum width in the body of a struct lit before falling back to - // vertical formatting. - pub struct_lit_width: usize, - // Maximum width in the body of a struct variant before falling back - // to vertical formatting. - pub struct_variant_width: usize, - // Maximum width of an array literal before falling back to vertical - // formatting. - pub array_width: usize, - // Maximum length of a chain to fit on a single line. - pub chain_width: usize, - // Maximum line length for single line if-else expressions. A value - // of zero means always break if-else expressions. - pub single_line_if_else_max_width: usize, -} - -impl WidthHeuristics { - // Using this WidthHeuristics means we ignore heuristics. - fn null() -> WidthHeuristics { - WidthHeuristics { - fn_call_width: usize::max_value(), - struct_lit_width: 0, - struct_variant_width: 0, - array_width: usize::max_value(), - chain_width: usize::max_value(), - single_line_if_else_max_width: 0, - } - } -} - -impl Default for WidthHeuristics { - fn default() -> WidthHeuristics { - WidthHeuristics { - fn_call_width: 60, - struct_lit_width: 18, - struct_variant_width: 35, - array_width: 60, - chain_width: 60, - single_line_if_else_max_width: 50, - } - } -} - -impl ::std::str::FromStr for WidthHeuristics { - type Err = &'static str; - - fn from_str(_: &str) -> Result { - Err("WidthHeuristics is not parsable") - } -} - -impl ::config::ConfigType for WidthHeuristics { - fn doc_hint() -> String { - String::new() - } -} - -/// Trait for types that can be used in `Config`. -pub trait ConfigType: Sized { - /// Returns hint text for use in `Config::print_docs()`. For enum types, this is a - /// pipe-separated list of variants; for other types it returns "". - fn doc_hint() -> String; -} - -impl ConfigType for bool { - fn doc_hint() -> String { - String::from("") - } -} - -impl ConfigType for usize { - fn doc_hint() -> String { - String::from("") - } -} - -impl ConfigType for isize { - fn doc_hint() -> String { - String::from("") - } -} - -impl ConfigType for String { - fn doc_hint() -> String { - String::from("") - } -} - -impl ConfigType for FileLines { - fn doc_hint() -> String { - String::from("") - } -} - -pub struct ConfigHelpItem { - option_name: &'static str, - doc_string: &'static str, - variant_names: String, - default: &'static str, -} - -impl ConfigHelpItem { - pub fn option_name(&self) -> &'static str { - self.option_name - } - - pub fn doc_string(&self) -> &'static str { - self.doc_string - } - - pub fn variant_names(&self) -> &String { - &self.variant_names - } - - pub fn default(&self) -> &'static str { - self.default - } -} - -macro_rules! create_config { - ($($i:ident: $ty:ty, $def:expr, $stb:expr, $( $dstring:expr ),+ );+ $(;)*) => ( - #[derive(Clone)] - pub struct Config { - // For each config item, we store a bool indicating whether it has - // been accessed and the value, and a bool whether the option was - // manually initialised, or taken from the default, - $($i: (Cell, bool, $ty, bool)),+ - } - - // Just like the Config struct but with each property wrapped - // as Option. This is used to parse a rustfmt.toml that doesn't - // specify all properties of `Config`. - // We first parse into `PartialConfig`, then create a default `Config` - // and overwrite the properties with corresponding values from `PartialConfig`. - #[derive(Deserialize, Serialize, Clone)] - pub struct PartialConfig { - $(pub $i: Option<$ty>),+ - } - - impl PartialConfig { - pub fn to_toml(&self) -> Result { - // Non-user-facing options can't be specified in TOML - let mut cloned = self.clone(); - cloned.file_lines = None; - cloned.verbose = None; - cloned.width_heuristics = None; - - toml::to_string(&cloned) - .map_err(|e| format!("Could not output config: {}", e.to_string())) - } - } - - // Macro hygiene won't allow us to make `set_$i()` methods on Config - // for each item, so this struct is used to give the API to set values: - // `config.get().option(false)`. It's pretty ugly. Consider replacing - // with `config.set_option(false)` if we ever get a stable/usable - // `concat_idents!()`. - pub struct ConfigSetter<'a>(&'a mut Config); - - impl<'a> ConfigSetter<'a> { - $( - pub fn $i(&mut self, value: $ty) { - (self.0).$i.2 = value; - if stringify!($i) == "use_small_heuristics" { - self.0.set_heuristics(); - } - } - )+ - } - - // Query each option, returns true if the user set the option, false if - // a default was used. - pub struct ConfigWasSet<'a>(&'a Config); - - impl<'a> ConfigWasSet<'a> { - $( - pub fn $i(&self) -> bool { - (self.0).$i.1 - } - )+ - } - - impl Config { - pub fn version_meets_requirement(&self, error_summary: &mut Summary) -> bool { - if self.was_set().required_version() { - let version = env!("CARGO_PKG_VERSION"); - let required_version = self.required_version(); - if version != required_version { - println!( - "Error: rustfmt version ({}) doesn't match the required version ({})", - version, - required_version, - ); - error_summary.add_formatting_error(); - return false; - } - } - - true - } - - $( - pub fn $i(&self) -> $ty { - self.$i.0.set(true); - self.$i.2.clone() - } - )+ - - pub fn set<'a>(&'a mut self) -> ConfigSetter<'a> { - ConfigSetter(self) - } - - pub fn was_set<'a>(&'a self) -> ConfigWasSet<'a> { - ConfigWasSet(self) - } - - fn fill_from_parsed_config(mut self, parsed: PartialConfig) -> Config { - $( - if let Some(val) = parsed.$i { - if self.$i.3 { - self.$i.1 = true; - self.$i.2 = val; - } else { - if is_nightly_channel!() { - self.$i.1 = true; - self.$i.2 = val; - } else { - eprintln!("Warning: can't set `{} = {:?}`, unstable features are only \ - available in nightly channel.", stringify!($i), val); - } - } - } - )+ - self.set_heuristics(); - self - } - - pub fn from_toml(toml: &str) -> Result { - let parsed: toml::Value = - toml.parse().map_err(|e| format!("Could not parse TOML: {}", e))?; - let mut err: String = String::new(); - { - let table = parsed - .as_table() - .ok_or(String::from("Parsed config was not table"))?; - for key in table.keys() { - match &**key { - $( - stringify!($i) => (), - )+ - _ => { - let msg = - &format!("Warning: Unknown configuration option `{}`\n", key); - err.push_str(msg) - } - } - } - } - match parsed.try_into() { - Ok(parsed_config) => { - if !err.is_empty() { - eprint!("{}", err); - } - Ok(Config::default().fill_from_parsed_config(parsed_config)) - } - Err(e) => { - err.push_str("Error: Decoding config file failed:\n"); - err.push_str(format!("{}\n", e).as_str()); - err.push_str("Please check your config file."); - Err(err) - } - } - } - - pub fn used_options(&self) -> PartialConfig { - PartialConfig { - $( - $i: if self.$i.0.get() { - Some(self.$i.2.clone()) - } else { - None - }, - )+ - } - } - - pub fn all_options(&self) -> PartialConfig { - PartialConfig { - $( - $i: Some(self.$i.2.clone()), - )+ - } - } - - pub fn override_value(&mut self, key: &str, val: &str) - { - match key { - $( - stringify!($i) => { - self.$i.2 = val.parse::<$ty>() - .expect(&format!("Failed to parse override for {} (\"{}\") as a {}", - stringify!($i), - val, - stringify!($ty))); - } - )+ - _ => panic!("Unknown config key in override: {}", key) - } - - if key == "use_small_heuristics" { - self.set_heuristics(); - } - } - - /// Construct a `Config` from the toml file specified at `file_path`. - /// - /// This method only looks at the provided path, for a method that - /// searches parents for a `rustfmt.toml` see `from_resolved_toml_path`. - /// - /// Return a `Config` if the config could be read and parsed from - /// the file, Error otherwise. - pub fn from_toml_path(file_path: &Path) -> Result { - let mut file = File::open(&file_path)?; - let mut toml = String::new(); - file.read_to_string(&mut toml)?; - Config::from_toml(&toml).map_err(|err| Error::new(ErrorKind::InvalidData, err)) - } - - /// Resolve the config for input in `dir`. - /// - /// Searches for `rustfmt.toml` beginning with `dir`, and - /// recursively checking parents of `dir` if no config file is found. - /// If no config file exists in `dir` or in any parent, a - /// default `Config` will be returned (and the returned path will be empty). - /// - /// Returns the `Config` to use, and the path of the project file if there was - /// one. - pub fn from_resolved_toml_path(dir: &Path) -> Result<(Config, Option), Error> { - - /// Try to find a project file in the given directory and its parents. - /// Returns the path of a the nearest project file if one exists, - /// or `None` if no project file was found. - fn resolve_project_file(dir: &Path) -> Result, Error> { - let mut current = if dir.is_relative() { - env::current_dir()?.join(dir) - } else { - dir.to_path_buf() - }; - - current = fs::canonicalize(current)?; - - loop { - match get_toml_path(¤t) { - Ok(Some(path)) => return Ok(Some(path)), - Err(e) => return Err(e), - _ => () - } - - // If the current directory has no parent, we're done searching. - if !current.pop() { - return Ok(None); - } - } - } - - match resolve_project_file(dir)? { - None => Ok((Config::default(), None)), - Some(path) => Config::from_toml_path(&path).map(|config| (config, Some(path))), - } - } - - - pub fn print_docs() { - use std::cmp; - const HIDE_OPTIONS: [&str; 3] = ["verbose", "file_lines", "width_heuristics"]; - let max = 0; - $( let max = cmp::max(max, stringify!($i).len()+1); )+ - let mut space_str = String::with_capacity(max); - for _ in 0..max { - space_str.push(' '); - } - println!("Configuration Options:"); - $( - let name_raw = stringify!($i); - - if !HIDE_OPTIONS.contains(&name_raw) { - let mut name_out = String::with_capacity(max); - for _ in name_raw.len()..max-1 { - name_out.push(' ') - } - name_out.push_str(name_raw); - name_out.push(' '); - println!("{}{} Default: {:?}", - name_out, - <$ty>::doc_hint(), - $def); - $( - println!("{}{}", space_str, $dstring); - )+ - println!(); - } - )+ - } - - fn set_heuristics(&mut self) { - if self.use_small_heuristics.2 { - self.set().width_heuristics(WidthHeuristics::default()); - } else { - self.set().width_heuristics(WidthHeuristics::null()); - } - } - } - - // Template for the default configuration - impl Default for Config { - fn default() -> Config { - Config { - $( - $i: (Cell::new(false), false, $def, $stb), - )+ - } - } - } - ) -} - -/// Check for the presence of known config file names (`rustfmt.toml, `.rustfmt.toml`) in `dir` -/// -/// Return the path if a config file exists, empty if no file exists, and Error for IO errors -pub fn get_toml_path(dir: &Path) -> Result, Error> { - const CONFIG_FILE_NAMES: [&str; 2] = [".rustfmt.toml", "rustfmt.toml"]; - for config_file_name in &CONFIG_FILE_NAMES { - let config_file = dir.join(config_file_name); - match fs::metadata(&config_file) { - // Only return if it's a file to handle the unlikely situation of a directory named - // `rustfmt.toml`. - Ok(ref md) if md.is_file() => return Ok(Some(config_file)), - // Return the error if it's something other than `NotFound`; otherwise we didn't - // find the project file yet, and continue searching. - Err(e) => { - if e.kind() != ErrorKind::NotFound { - return Err(e); - } - } - _ => {} - } - } - Ok(None) -} - -create_config! { - // Fundamental stuff - max_width: usize, 100, true, "Maximum width of each line"; - hard_tabs: bool, false, true, "Use tab characters for indentation, spaces for alignment"; - tab_spaces: usize, 4, true, "Number of spaces per tab"; - newline_style: NewlineStyle, NewlineStyle::Unix, true, "Unix or Windows line endings"; - indent_style: IndentStyle, IndentStyle::Block, false, "How do we indent expressions or items."; - use_small_heuristics: bool, true, false, "Whether to use different formatting for items and\ - expressions if they satisfy a heuristic notion of 'small'."; - - // strings and comments - format_strings: bool, false, false, "Format string literals where necessary"; - wrap_comments: bool, false, true, "Break comments to fit on the line"; - comment_width: usize, 80, false, - "Maximum length of comments. No effect unless wrap_comments = true"; - normalize_comments: bool, false, true, "Convert /* */ comments to // comments where possible"; - - // Single line expressions and items. - empty_item_single_line: bool, true, false, - "Put empty-body functions and impls on a single line"; - struct_lit_single_line: bool, true, false, - "Put small struct literals on a single line"; - fn_single_line: bool, false, false, "Put single-expression functions on a single line"; - where_single_line: bool, false, false, "To force single line where layout"; - - // Imports - imports_indent: IndentStyle, IndentStyle::Visual, false, "Indent of imports"; - imports_layout: ListTactic, ListTactic::Mixed, false, "Item layout inside a import block"; - - // Ordering - reorder_extern_crates: bool, true, false, "Reorder extern crate statements alphabetically"; - reorder_extern_crates_in_group: bool, true, false, "Reorder extern crate statements in group"; - reorder_imports: bool, false, false, "Reorder import statements alphabetically"; - reorder_imports_in_group: bool, false, false, "Reorder import statements in group"; - reorder_imported_names: bool, true, false, - "Reorder lists of names in import statements alphabetically"; - reorder_modules: bool, false, false, "Reorder module statemtents alphabetically in group"; - - // Spaces around punctuation - binop_separator: SeparatorPlace, SeparatorPlace::Front, false, - "Where to put a binary operator when a binary expression goes multiline."; - type_punctuation_density: TypeDensity, TypeDensity::Wide, false, - "Determines if '+' or '=' are wrapped in spaces in the punctuation of types"; - space_before_colon: bool, false, false, "Leave a space before the colon"; - space_after_colon: bool, true, false, "Leave a space after the colon"; - spaces_around_ranges: bool, false, false, "Put spaces around the .. and ... range operators"; - spaces_within_parens_and_brackets: bool, false, false, - "Put spaces within non-empty parentheses or brackets"; - - // Misc. - combine_control_expr: bool, true, false, "Combine control expressions with function calls."; - struct_field_align_threshold: usize, 0, false, "Align struct fields if their diffs fits within \ - threshold."; - remove_blank_lines_at_start_or_end_of_block: bool, true, false, - "Remove blank lines at start or end of a block"; - match_arm_blocks: bool, true, false, "Wrap the body of arms in blocks when it does not fit on \ - the same line with the pattern of arms"; - force_multiline_blocks: bool, false, false, - "Force multiline closure bodies and match arms to be wrapped in a block"; - fn_args_density: Density, Density::Tall, false, "Argument density in functions"; - brace_style: BraceStyle, BraceStyle::SameLineWhere, false, "Brace style for items"; - control_brace_style: ControlBraceStyle, ControlBraceStyle::AlwaysSameLine, false, - "Brace style for control flow constructs"; - trailing_comma: SeparatorTactic, SeparatorTactic::Vertical, false, - "How to handle trailing commas for lists"; - trailing_semicolon: bool, true, false, - "Add trailing semicolon after break, continue and return"; - match_block_trailing_comma: bool, false, false, - "Put a trailing comma after a block based match arm (non-block arms are not affected)"; - blank_lines_upper_bound: usize, 1, false, - "Maximum number of blank lines which can be put between items."; - blank_lines_lower_bound: usize, 0, false, - "Minimum number of blank lines which must be put between items."; - - // Options that can change the source code beyond whitespace/blocks (somewhat linty things) - merge_derives: bool, true, true, "Merge multiple `#[derive(...)]` into a single one"; - use_try_shorthand: bool, false, false, "Replace uses of the try! macro by the ? shorthand"; - condense_wildcard_suffixes: bool, false, false, "Replace strings of _ wildcards by a single .. \ - in tuple patterns"; - force_explicit_abi: bool, true, true, "Always print the abi for extern items"; - use_field_init_shorthand: bool, false, false, "Use field initialization shorthand if possible"; - - // Control options (changes the operation of rustfmt, rather than the formatting) - write_mode: WriteMode, WriteMode::Overwrite, false, - "What Write Mode to use when none is supplied: \ - Replace, Overwrite, Display, Plain, Diff, Coverage"; - color: Color, Color::Auto, false, - "What Color option to use when none is supplied: Always, Never, Auto"; - required_version: String, env!("CARGO_PKG_VERSION").to_owned(), false, - "Require a specific version of rustfmt."; - unstable_features: bool, false, true, - "Enables unstable features. Only available on nightly channel"; - disable_all_formatting: bool, false, false, "Don't reformat anything"; - skip_children: bool, false, false, "Don't reformat out of line modules"; - hide_parse_errors: bool, false, false, "Hide errors from the parser"; - error_on_line_overflow: bool, true, false, "Error if unable to get all lines within max_width"; - error_on_unformatted: bool, false, false, - "Error if unable to get comments or string literals within max_width, \ - or they are left with trailing whitespaces"; - report_todo: ReportTactic, ReportTactic::Never, false, - "Report all, none or unnumbered occurrences of TODO in source file comments"; - report_fixme: ReportTactic, ReportTactic::Never, false, - "Report all, none or unnumbered occurrences of FIXME in source file comments"; - - // Not user-facing. - verbose: bool, false, false, "Use verbose output"; - file_lines: FileLines, FileLines::all(), false, - "Lines to format; this is not supported in rustfmt.toml, and can only be specified \ - via the --file-lines option"; - width_heuristics: WidthHeuristics, WidthHeuristics::default(), false, - "'small' heuristic values"; -} - -#[cfg(test)] -mod test { - use super::Config; - - #[test] - fn test_config_set() { - let mut config = Config::default(); - config.set().verbose(false); - assert_eq!(config.verbose(), false); - config.set().verbose(true); - assert_eq!(config.verbose(), true); - } - - #[test] - fn test_config_used_to_toml() { - let config = Config::default(); - - let merge_derives = config.merge_derives(); - let skip_children = config.skip_children(); - - let used_options = config.used_options(); - let toml = used_options.to_toml().unwrap(); - assert_eq!( - toml, - format!( - "merge_derives = {}\nskip_children = {}\n", - merge_derives, skip_children, - ) - ); - } - - #[test] - fn test_was_set() { - let config = Config::from_toml("hard_tabs = true").unwrap(); - - assert_eq!(config.was_set().hard_tabs(), true); - assert_eq!(config.was_set().verbose(), false); - } - - // FIXME(#2183) these tests cannot be run in parallel because they use env vars - // #[test] - // fn test_as_not_nightly_channel() { - // let mut config = Config::default(); - // assert_eq!(config.was_set().unstable_features(), false); - // config.set().unstable_features(true); - // assert_eq!(config.was_set().unstable_features(), false); - // } - - // #[test] - // fn test_as_nightly_channel() { - // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from("")); - // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly"); - // let mut config = Config::default(); - // config.set().unstable_features(true); - // assert_eq!(config.was_set().unstable_features(), false); - // config.set().unstable_features(true); - // assert_eq!(config.unstable_features(), true); - // ::std::env::set_var("CFG_RELEASE_CHANNEL", v); - // } - - // #[test] - // fn test_unstable_from_toml() { - // let mut config = Config::from_toml("unstable_features = true").unwrap(); - // assert_eq!(config.was_set().unstable_features(), false); - // let v = ::std::env::var("CFG_RELEASE_CHANNEL").unwrap_or(String::from("")); - // ::std::env::set_var("CFG_RELEASE_CHANNEL", "nightly"); - // config = Config::from_toml("unstable_features = true").unwrap(); - // assert_eq!(config.was_set().unstable_features(), true); - // assert_eq!(config.unstable_features(), true); - // ::std::env::set_var("CFG_RELEASE_CHANNEL", v); - // } -}