1 //! Tidy check to ensure that crate `edition` is '2018' or '2021'.
5 fn is_edition_2018(mut line: &str) -> bool {
7 line == "edition = \"2018\""
10 fn is_edition_2021(mut line: &str) -> bool {
12 line == "edition = \"2021\""
15 pub fn check(path: &Path, bad: &mut bool) {
18 &mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
19 &mut |entry, contents| {
20 let file = entry.path();
21 let filename = file.file_name().unwrap();
22 if filename != "Cargo.toml" {
26 // Library crates are not yet ready to migrate to 2021.
27 if path.components().any(|c| c.as_os_str() == "library") {
28 let has = contents.lines().any(is_edition_2018);
32 "{} doesn't have `edition = \"2018\"` on a separate line",
37 let is_2021 = contents.lines().any(is_edition_2021);
41 "{} doesn't have `edition = \"2021\"` on a separate line",