Skip to content

Commit fca8053

Browse files
authored
Merge pull request #3247 from rust-lang-nursery/dummy
Add dummy clippy crate for publishing
2 parents 788c838 + 6c1d639 commit fca8053

File tree

6 files changed

+76
-0
lines changed

6 files changed

+76
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ keywords = ["clippy", "lint", "plugin"]
1616
categories = ["development-tools", "development-tools::cargo-plugins"]
1717
build = "build.rs"
1818
edition = "2018"
19+
publish = false
1920

2021
[badges]
2122
travis-ci = { repository = "rust-lang-nursery/rust-clippy" }

clippy_dummy/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "clippy_dummy" # rename to clippy before publishing
3+
version = "0.0.301"
4+
authors = ["Manish Goregaokar <[email protected]>"]
5+
edition = "2018"
6+
readme = "crates-readme.md"
7+
description = "A bunch of helpful lints to avoid common pitfalls in Rust."
8+
build = 'build.rs'
9+
10+
repository = "https://github.com/rust-lang-nursery/rust-clippy"
11+
12+
license = "MPL-2.0"
13+
keywords = ["clippy", "lint", "plugin"]
14+
categories = ["development-tools", "development-tools::cargo-plugins"]
15+
16+
[build-dependencies]
17+
term = "0.5.1"

clippy_dummy/PUBLISH.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
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.
2+
3+
Before publishing, be sure to rename `clippy_dummy` to `clippy` in `Cargo.toml`, it has a different name to avoid workspace issues.
4+

clippy_dummy/build.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
extern crate term;
2+
3+
fn main() {
4+
if let Err(_) = foo() {
5+
eprintln!("error: Clippy is no longer available via crates.io\n");
6+
eprintln!("help: please run `rustup component add clippy-preview` instead");
7+
}
8+
std::process::exit(1);
9+
}
10+
11+
fn foo() -> Result<(), ()> {
12+
let mut t = term::stderr().ok_or(())?;
13+
14+
t.attr(term::Attr::Bold).map_err(|_| ())?;
15+
t.fg(term::color::RED).map_err(|_| ())?;
16+
write!(t, "\nerror: ").map_err(|_| ())?;
17+
18+
19+
t.reset().map_err(|_| ())?;
20+
t.fg(term::color::WHITE).map_err(|_| ())?;
21+
writeln!(t, "Clippy is no longer available via crates.io\n").map_err(|_| ())?;
22+
23+
24+
t.attr(term::Attr::Bold).map_err(|_| ())?;
25+
t.fg(term::color::GREEN).map_err(|_| ())?;
26+
write!(t, "help: ").map_err(|_| ())?;
27+
28+
29+
t.reset().map_err(|_| ())?;
30+
t.fg(term::color::WHITE).map_err(|_| ())?;
31+
write!(t, "please run `").map_err(|_| ())?;
32+
33+
t.attr(term::Attr::Bold).map_err(|_| ())?;
34+
write!(t, "rustup component add clippy-preview").map_err(|_| ())?;
35+
36+
t.reset().map_err(|_| ())?;
37+
t.fg(term::color::WHITE).map_err(|_| ())?;
38+
writeln!(t, "` instead").map_err(|_| ())?;
39+
40+
t.reset().map_err(|_| ())?;
41+
Ok(())
42+
}

clippy_dummy/crates-readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Installing clippy via crates.io is deprecated. Please use the following:
2+
3+
```terminal
4+
rustup component add clippy-preview
5+
```
6+
7+
on a Rust version 1.29 or later. You may need to run `rustup self update` if it complains about a missing clippy binary.
8+
9+
See [the homepage](https://github.com/rust-lang-nursery/rust-clippy/#clippy) for more information

clippy_dummy/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
panic!("This shouldn't even compile")
3+
}

0 commit comments

Comments
 (0)