From a930e778c2325c32bf94a580499b000455081e90 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 1 Oct 2018 22:03:07 +0200 Subject: [PATCH 1/2] Add dummy clippy crate for publishing --- clippy_dummy/Cargo.toml | 17 ++++++++++++++ clippy_dummy/PUBLISH.md | 4 ++++ clippy_dummy/build.rs | 42 +++++++++++++++++++++++++++++++++++ clippy_dummy/crates-readme.md | 9 ++++++++ clippy_dummy/src/main.rs | 3 +++ 5 files changed, 75 insertions(+) create mode 100644 clippy_dummy/Cargo.toml create mode 100644 clippy_dummy/PUBLISH.md create mode 100644 clippy_dummy/build.rs create mode 100644 clippy_dummy/crates-readme.md create mode 100644 clippy_dummy/src/main.rs diff --git a/clippy_dummy/Cargo.toml b/clippy_dummy/Cargo.toml new file mode 100644 index 000000000000..b9e3aa3bcdc5 --- /dev/null +++ b/clippy_dummy/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "clippy_dummy" # rename to clippy before publishing +version = "0.0.301" +authors = ["Manish Goregaokar "] +edition = "2018" +readme = "crates-readme.md" +description = "A bunch of helpful lints to avoid common pitfalls in Rust." +build = 'build.rs' + +repository = "https://github.com/rust-lang-nursery/rust-clippy" + +license = "MPL-2.0" +keywords = ["clippy", "lint", "plugin"] +categories = ["development-tools", "development-tools::cargo-plugins"] + +[build-dependencies] +term = "0.5.1" diff --git a/clippy_dummy/PUBLISH.md b/clippy_dummy/PUBLISH.md new file mode 100644 index 000000000000..535f11bd2ee4 --- /dev/null +++ b/clippy_dummy/PUBLISH.md @@ -0,0 +1,4 @@ +This is a dummy crate to publish to crates.io. It primarily exists to ensure that folks trying to install clippy from crates.io get redirected to the `rustup` technique. + +Before publishing, be sure to rename `clippy_dummy` to `clippy` in `Cargo.toml`, it has a different name to avoid workspace issues. + \ No newline at end of file diff --git a/clippy_dummy/build.rs b/clippy_dummy/build.rs new file mode 100644 index 000000000000..97902feff868 --- /dev/null +++ b/clippy_dummy/build.rs @@ -0,0 +1,42 @@ +extern crate term; + +fn main() { + if let Err(_) = foo() { + eprintln!("error: Clippy is no longer available via crates.io\n"); + eprintln!("help: please run `rustup component add clippy-preview` instead"); + } + std::process::exit(1); +} + +fn foo() -> Result<(), ()> { + let mut t = term::stderr().ok_or(())?; + + t.attr(term::Attr::Bold).map_err(|_| ())?; + t.fg(term::color::RED).map_err(|_| ())?; + write!(t, "\nerror: ").map_err(|_| ())?; + + + t.reset().map_err(|_| ())?; + t.fg(term::color::WHITE).map_err(|_| ())?; + writeln!(t, "Clippy is no longer available via crates.io\n").map_err(|_| ())?; + + + t.attr(term::Attr::Bold).map_err(|_| ())?; + t.fg(term::color::GREEN).map_err(|_| ())?; + write!(t, "help: ").map_err(|_| ())?; + + + t.reset().map_err(|_| ())?; + t.fg(term::color::WHITE).map_err(|_| ())?; + write!(t, "please run `").map_err(|_| ())?; + + t.attr(term::Attr::Bold).map_err(|_| ())?; + write!(t, "rustup component add clippy-preview").map_err(|_| ())?; + + t.reset().map_err(|_| ())?; + t.fg(term::color::WHITE).map_err(|_| ())?; + writeln!(t, "` instead").map_err(|_| ())?; + + t.reset().map_err(|_| ())?; + Ok(()) +} \ No newline at end of file diff --git a/clippy_dummy/crates-readme.md b/clippy_dummy/crates-readme.md new file mode 100644 index 000000000000..0035073549c0 --- /dev/null +++ b/clippy_dummy/crates-readme.md @@ -0,0 +1,9 @@ +Installing clippy via crates.io is deprecated. Please use the following: + +```terminal +rustup component add clippy-preview +``` + +on a Rust version 1.29 or later. You may need to run `rustup self update` if it complains about a missing clippy binary. + +See [the homepage](https://github.com/rust-lang-nursery/rust-clippy/#clippy) for more information \ No newline at end of file diff --git a/clippy_dummy/src/main.rs b/clippy_dummy/src/main.rs new file mode 100644 index 000000000000..a118834f1fd4 --- /dev/null +++ b/clippy_dummy/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + panic!("This shouldn't even compile") +} From 6c1d6391ecf3d7f2ee6761dda1cd5595744550dc Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 2 Oct 2018 09:58:02 +0200 Subject: [PATCH 2/2] publish = false --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 80ff21764a52..d765e09deef3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ keywords = ["clippy", "lint", "plugin"] categories = ["development-tools", "development-tools::cargo-plugins"] build = "build.rs" edition = "2018" +publish = false [badges] travis-ci = { repository = "rust-lang-nursery/rust-clippy" }