diff --git a/Cargo.toml b/Cargo.toml index 28954953d97..7bfe19809a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,25 +7,29 @@ description = "Tool to find and fix Rust formatting issues" repository = "https://github.com/rust-lang/rustfmt" readme = "README.md" license = "Apache-2.0/MIT" -build = "build.rs" +build = "rustfmt-core/rustfmt-bin/build.rs" categories = ["development-tools"] edition = "2018" [[bin]] name = "rustfmt" -path = "src/bin/main.rs" +path = "rustfmt-core/rustfmt-bin/src/bin/main.rs" +test = false [[bin]] name = "cargo-fmt" -path = "src/cargo-fmt/main.rs" +path = "rustfmt-core/rustfmt-bin/src/cargo-fmt/main.rs" +test = false [[bin]] name = "rustfmt-format-diff" -path = "src/format-diff/main.rs" +path = "rustfmt-core/rustfmt-bin/src/format-diff/main.rs" +test = false [[bin]] name = "git-rustfmt" -path = "src/git-rustfmt/main.rs" +path = "rustfmt-core/rustfmt-bin/src/git-rustfmt/main.rs" +test = false [features] default = ["cargo-fmt", "rustfmt-format-diff"] diff --git a/rustfmt-core/Cargo.toml b/rustfmt-core/Cargo.toml index 8cea2f5455d..46ed24b9f7c 100644 --- a/rustfmt-core/Cargo.toml +++ b/rustfmt-core/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = [ + "rustfmt-bin", "rustfmt-config", "rustfmt-emitter", "rustfmt-lib", diff --git a/rustfmt-core/rustfmt-bin/Cargo.toml b/rustfmt-core/rustfmt-bin/Cargo.toml new file mode 100644 index 00000000000..b57df94890a --- /dev/null +++ b/rustfmt-core/rustfmt-bin/Cargo.toml @@ -0,0 +1,47 @@ +[package] + +# The metadata of this crate is intentionally removed to avoid publishing this crate by accident. +name = "rustfmt-bin" +version = "2.0.0-rc.1" +edition = "2018" + +[[bin]] +name = "rustfmt" +path = "src/bin/main.rs" + +[[bin]] +name = "cargo-fmt" +path = "src/cargo-fmt/main.rs" + +[[bin]] +name = "rustfmt-format-diff" +path = "src/format-diff/main.rs" + +[[bin]] +name = "git-rustfmt" +path = "src/git-rustfmt/main.rs" + +[features] +default = ["cargo-fmt", "rustfmt-format-diff"] +cargo-fmt = [] +rustfmt-format-diff = [] +generic-simd = ["rustfmt_lib/generic-simd"] + +[dependencies] +ansi_term = "0.12" +anyhow = "1.0" +cargo_metadata = "0.9" +env_logger = "0.7" +getopts = "0.2" +log = "0.4" +regex = "1.0" +serde = "1.0" +serde_json = "1.0" +structopt = "0.3" +term = "0.6" +thiserror = "1.0" + +rustfmt_lib = { path = "../rustfmt-lib", version = "1.0" } + +[dev-dependencies] +lazy_static = "1.0" diff --git a/build.rs b/rustfmt-core/rustfmt-bin/build.rs similarity index 100% rename from build.rs rename to rustfmt-core/rustfmt-bin/build.rs diff --git a/src/bin/main.rs b/rustfmt-core/rustfmt-bin/src/bin/main.rs similarity index 100% rename from src/bin/main.rs rename to rustfmt-core/rustfmt-bin/src/bin/main.rs diff --git a/src/cargo-fmt/main.rs b/rustfmt-core/rustfmt-bin/src/cargo-fmt/main.rs similarity index 100% rename from src/cargo-fmt/main.rs rename to rustfmt-core/rustfmt-bin/src/cargo-fmt/main.rs diff --git a/src/format-diff/main.rs b/rustfmt-core/rustfmt-bin/src/format-diff/main.rs similarity index 100% rename from src/format-diff/main.rs rename to rustfmt-core/rustfmt-bin/src/format-diff/main.rs diff --git a/src/format-diff/test/bindgen.diff b/rustfmt-core/rustfmt-bin/src/format-diff/test/bindgen.diff similarity index 100% rename from src/format-diff/test/bindgen.diff rename to rustfmt-core/rustfmt-bin/src/format-diff/test/bindgen.diff diff --git a/src/git-rustfmt/main.rs b/rustfmt-core/rustfmt-bin/src/git-rustfmt/main.rs similarity index 100% rename from src/git-rustfmt/main.rs rename to rustfmt-core/rustfmt-bin/src/git-rustfmt/main.rs diff --git a/tests/cargo-fmt/main.rs b/rustfmt-core/rustfmt-bin/tests/cargo-fmt/main.rs similarity index 100% rename from tests/cargo-fmt/main.rs rename to rustfmt-core/rustfmt-bin/tests/cargo-fmt/main.rs diff --git a/tests/config/disable_all_formatting.toml b/rustfmt-core/rustfmt-bin/tests/config/disable_all_formatting.toml similarity index 100% rename from tests/config/disable_all_formatting.toml rename to rustfmt-core/rustfmt-bin/tests/config/disable_all_formatting.toml diff --git a/tests/nested-test-files/empty-tests-dir/Cargo.toml b/rustfmt-core/rustfmt-bin/tests/nested-test-files/empty-tests-dir/Cargo.toml similarity index 89% rename from tests/nested-test-files/empty-tests-dir/Cargo.toml rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/empty-tests-dir/Cargo.toml index 27c0eeb1ba4..5afbbbf2847 100644 --- a/tests/nested-test-files/empty-tests-dir/Cargo.toml +++ b/rustfmt-core/rustfmt-bin/tests/nested-test-files/empty-tests-dir/Cargo.toml @@ -4,3 +4,5 @@ version = "0.1.0" authors = ["rustfmt devs "] [dependencies] + +[workspace] diff --git a/tests/nested-test-files/empty-tests-dir/src/lib.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/empty-tests-dir/src/lib.rs similarity index 100% rename from tests/nested-test-files/empty-tests-dir/src/lib.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/empty-tests-dir/src/lib.rs diff --git a/tests/nested-test-files/no-tests-dir/Cargo.toml b/rustfmt-core/rustfmt-bin/tests/nested-test-files/no-tests-dir/Cargo.toml similarity index 89% rename from tests/nested-test-files/no-tests-dir/Cargo.toml rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/no-tests-dir/Cargo.toml index c48c1588c8f..264a270a561 100644 --- a/tests/nested-test-files/no-tests-dir/Cargo.toml +++ b/rustfmt-core/rustfmt-bin/tests/nested-test-files/no-tests-dir/Cargo.toml @@ -4,3 +4,5 @@ version = "0.1.0" authors = ["rustfmt devs "] [dependencies] + +[workspace] diff --git a/tests/nested-test-files/no-tests-dir/src/lib.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/no-tests-dir/src/lib.rs similarity index 100% rename from tests/nested-test-files/no-tests-dir/src/lib.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/no-tests-dir/src/lib.rs diff --git a/tests/nested-test-files/only-root-level-tests-dir/Cargo.toml b/rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/Cargo.toml similarity index 89% rename from tests/nested-test-files/only-root-level-tests-dir/Cargo.toml rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/Cargo.toml index 29ea5aa6254..3249260c26b 100644 --- a/tests/nested-test-files/only-root-level-tests-dir/Cargo.toml +++ b/rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/Cargo.toml @@ -4,3 +4,5 @@ version = "0.1.0" authors = ["rustfmt devs "] [dependencies] + +[workspace] \ No newline at end of file diff --git a/tests/nested-test-files/only-root-level-tests-dir/src/lib.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/src/lib.rs similarity index 100% rename from tests/nested-test-files/only-root-level-tests-dir/src/lib.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/src/lib.rs diff --git a/tests/nested-test-files/only-root-level-tests-dir/tests/bar.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/tests/bar.rs similarity index 100% rename from tests/nested-test-files/only-root-level-tests-dir/tests/bar.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/tests/bar.rs diff --git a/tests/nested-test-files/only-root-level-tests-dir/tests/foo.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/tests/foo.rs similarity index 100% rename from tests/nested-test-files/only-root-level-tests-dir/tests/foo.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/only-root-level-tests-dir/tests/foo.rs diff --git a/tests/nested-test-files/root-and-nested-tests/Cargo.toml b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/Cargo.toml similarity index 92% rename from tests/nested-test-files/root-and-nested-tests/Cargo.toml rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/Cargo.toml index ae58bf460d8..bd8db29924a 100644 --- a/tests/nested-test-files/root-and-nested-tests/Cargo.toml +++ b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/Cargo.toml @@ -5,3 +5,5 @@ authors = ["rustfmt devs "] edition = "2018" [dependencies] + +[workspace] \ No newline at end of file diff --git a/tests/nested-test-files/root-and-nested-tests/src/lib.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/src/lib.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/src/lib.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/src/lib.rs diff --git a/tests/nested-test-files/root-and-nested-tests/tests/bar.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/bar.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/tests/bar.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/bar.rs diff --git a/tests/nested-test-files/root-and-nested-tests/tests/foo.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/foo.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/tests/foo.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/foo.rs diff --git a/tests/nested-test-files/root-and-nested-tests/tests/nested/deeply-nested/baz.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/deeply-nested/baz.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/tests/nested/deeply-nested/baz.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/deeply-nested/baz.rs diff --git a/tests/nested-test-files/root-and-nested-tests/tests/nested/foo_bar.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/foo_bar.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/tests/nested/foo_bar.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/foo_bar.rs diff --git a/tests/nested-test-files/root-and-nested-tests/tests/nested/other.rs b/rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/other.rs similarity index 100% rename from tests/nested-test-files/root-and-nested-tests/tests/nested/other.rs rename to rustfmt-core/rustfmt-bin/tests/nested-test-files/root-and-nested-tests/tests/nested/other.rs diff --git a/tests/rustfmt/main.rs b/rustfmt-core/rustfmt-bin/tests/rustfmt/main.rs similarity index 100% rename from tests/rustfmt/main.rs rename to rustfmt-core/rustfmt-bin/tests/rustfmt/main.rs diff --git a/tests/source/issue-3981.rs b/rustfmt-core/rustfmt-bin/tests/source/issue-3981.rs similarity index 100% rename from tests/source/issue-3981.rs rename to rustfmt-core/rustfmt-bin/tests/source/issue-3981.rs diff --git a/tests/target/issue-3981.rs b/rustfmt-core/rustfmt-bin/tests/target/issue-3981.rs similarity index 100% rename from tests/target/issue-3981.rs rename to rustfmt-core/rustfmt-bin/tests/target/issue-3981.rs