blob: 8a7c4460dc7eaed4dc7a24723d14c17f159e42d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
//! Tidy check to ensure that crate `edition` is '2018' or '2021'.
use crate::walk::{filter_dirs, walk};
use std::path::Path;
fn is_edition_2021(mut line: &str) -> bool {
line = line.trim();
line == "edition = \"2021\""
}
pub fn check(path: &Path, bad: &mut bool) {
walk(
path,
&mut |path| filter_dirs(path) || path.ends_with("src/test"),
&mut |entry, contents| {
let file = entry.path();
let filename = file.file_name().unwrap();
if filename != "Cargo.toml" {
return;
}
let is_2021 = contents.lines().any(is_edition_2021);
if !is_2021 {
tidy_error!(
bad,
"{} doesn't have `edition = \"2021\"` on a separate line",
file.display()
);
}
},
);
}
|