Skip to content

Commit 59397d6

Browse files
committed
make clippy version number correspond to rustc version number.
clippy 0.1.50 corresponds to rustc 1.50.x This bumps the clippy version number from 0.0.212 to 0.1.50 Fixes rust-lang#6499
1 parent 0d8a27a commit 59397d6

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.212"
3+
version = "0.1.50"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -29,7 +29,7 @@ path = "src/driver.rs"
2929

3030
[dependencies]
3131
# begin automatic update
32-
clippy_lints = { version = "0.0.212", path = "clippy_lints" }
32+
clippy_lints = { version = "0.1.50", path = "clippy_lints" }
3333
# end automatic update
3434
semver = "0.11"
3535
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.212"
4+
version = "0.1.50"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

tests/versioncheck.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![allow(clippy::single_match_else)]
2+
use rustc_tools_util::VersionInfo;
3+
14
#[test]
25
fn check_that_clippy_lints_has_the_same_version_as_clippy() {
36
let clippy_meta = cargo_metadata::MetadataCommand::new()
@@ -17,3 +20,56 @@ fn check_that_clippy_lints_has_the_same_version_as_clippy() {
1720
}
1821
}
1922
}
23+
24+
#[test]
25+
fn check_that_clippy_has_the_same_major_version_as_rustc() {
26+
let clippy_version = rustc_tools_util::get_version_info!();
27+
let clippy_major = clippy_version.major;
28+
let clippy_minor = clippy_version.minor;
29+
let clippy_patch = clippy_version.patch;
30+
31+
// get the rustc version from cargo
32+
// this way the rust-toolchain file version is honored
33+
let rustc_version = String::from_utf8(
34+
std::process::Command::new("cargo")
35+
.arg("--version")
36+
.output()
37+
.expect("failed to run 'cargo --version'")
38+
.stdout,
39+
)
40+
.unwrap();
41+
// extract "1 50 0" from "cargo 1.50.0-nightly (a3c2627fb 2020-12-14)"
42+
let vsplit: Vec<&str> = rustc_version
43+
.split(' ')
44+
.nth(1)
45+
.unwrap()
46+
.split('-')
47+
.next()
48+
.unwrap()
49+
.split('.')
50+
.collect();
51+
match vsplit.as_slice() {
52+
[rustc_major, rustc_minor, _rustc_patch] => {
53+
// clippy 0.1.50 should correspond to rustc 1.50.0
54+
dbg!(&rustc_version);
55+
dbg!(&clippy_version);
56+
assert_eq!(clippy_major, 0); // this will probably stay the same for a long time
57+
assert_eq!(
58+
clippy_minor.to_string(),
59+
*rustc_major,
60+
"clippy minor version does not equal rustc major version"
61+
);
62+
assert_eq!(
63+
clippy_patch.to_string(),
64+
*rustc_minor,
65+
"clippy patch version does not equal rustc minor version"
66+
);
67+
// do not check rustc_patch because when a stable-patch-release is made (like 1.50.2),
68+
// we don't want our tests failing suddenly
69+
},
70+
_ => {
71+
dbg!(vsplit);
72+
panic!("Failed to parse rustc version");
73+
},
74+
};
75+
}

0 commit comments

Comments
 (0)