mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Handle virtual workspaces in the tidy edition check
This commit is contained in:
parent
a886938671
commit
7742be0095
@ -4,11 +4,6 @@ use std::path::Path;
|
|||||||
|
|
||||||
use crate::walk::{filter_dirs, walk};
|
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) {
|
pub fn check(path: &Path, bad: &mut bool) {
|
||||||
walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| {
|
walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| {
|
||||||
let file = entry.path();
|
let file = entry.path();
|
||||||
@ -17,8 +12,15 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_2021 = contents.lines().any(is_edition_2021);
|
let is_2021 = contents.lines().any(|line| line.trim() == "edition = \"2021\"");
|
||||||
if !is_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!(
|
tidy_error!(
|
||||||
bad,
|
bad,
|
||||||
"{} doesn't have `edition = \"2021\"` on a separate line",
|
"{} doesn't have `edition = \"2021\"` on a separate line",
|
||||||
|
Loading…
Reference in New Issue
Block a user