Skip to content

Commit 5432a67

Browse files
committed
Allow Rust 2021 crates in tidy
Once all crates have been switched to Rust 2021, I think this code should be changed to be similar to the old version but with 2021 instead of 2018. For now, allow both editions during the transition.
1 parent d6cd2c6 commit 5432a67

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/tools/tidy/src/edition.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
//! Tidy check to ensure that crate `edition` is '2018'
1+
//! Tidy check to ensure that crate `edition` is '2018' or '2021'.
22
33
use std::path::Path;
44

5-
fn is_edition_2018(mut line: &str) -> bool {
5+
fn is_edition_2018_or_2021(mut line: &str) -> bool {
66
line = line.trim();
7-
line == "edition = \"2018\"" || line == "edition = \'2018\'"
7+
line == "edition = \"2018\""
8+
|| line == "edition = \'2018\'"
9+
|| line == "edition = \"2021\""
10+
|| line == "edition = \'2021\'"
811
}
912

1013
pub fn check(path: &Path, bad: &mut bool) {
@@ -17,11 +20,11 @@ pub fn check(path: &Path, bad: &mut bool) {
1720
if filename != "Cargo.toml" {
1821
return;
1922
}
20-
let has_edition = contents.lines().any(is_edition_2018);
23+
let has_edition = contents.lines().any(is_edition_2018_or_2021);
2124
if !has_edition {
2225
tidy_error!(
2326
bad,
24-
"{} doesn't have `edition = \"2018\"` on a separate line",
27+
"{} doesn't have `edition = \"2018\"` or `edition = \"2021\"` on a separate line",
2528
file.display()
2629
);
2730
}

0 commit comments

Comments
 (0)