Handle virtual workspaces in the tidy edition check
This commit is contained in:
parent
a886938671
commit
7742be0095
@ -4,11 +4,6 @@
|
||||
|
||||
use crate::walk::{filter_dirs, walk};
|
||||
|
||||
fn is_edition_2021(mut line: &str) -> bool {
|
||||
line = line.trim();
|
||||
line == "edition = \"2021\""
|
||||
}
|
||||
|
||||
pub fn check(path: &Path, bad: &mut bool) {
|
||||
walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| {
|
||||
let file = entry.path();
|
||||
@ -17,8 +12,15 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||
return;
|
||||
}
|
||||
|
||||
let is_2021 = contents.lines().any(is_edition_2021);
|
||||
if !is_2021 {
|
||||
let is_2021 = contents.lines().any(|line| line.trim() == "edition = \"2021\"");
|
||||
|
||||
let is_workspace = contents.lines().any(|line| line.trim() == "[workspace]");
|
||||
let is_package = contents.lines().any(|line| line.trim() == "[package]");
|
||||
assert!(is_workspace || is_package);
|
||||
|
||||
// Check that all packages use the 2021 edition. Virtual workspaces don't allow setting an
|
||||
// edition, so these shouldn't be checked.
|
||||
if is_package && !is_2021 {
|
||||
tidy_error!(
|
||||
bad,
|
||||
"{} doesn't have `edition = \"2021\"` on a separate line",
|
||||
|
Loading…
Reference in New Issue
Block a user