Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tidy to allow edition = "2024" in Cargo.toml #129634

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/tools/tidy/src/edition.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tidy check to ensure that crate `edition` is '2018' or '2021'.
//! Tidy check to ensure that crate `edition` is '2021' or '2024'.

use std::path::Path;

Expand All @@ -12,18 +12,20 @@ pub fn check(path: &Path, bad: &mut bool) {
return;
}

let is_2021 = contents.lines().any(|line| line.trim() == "edition = \"2021\"");
let is_current_edition = contents
.lines()
.any(|line| line.trim() == "edition = \"2021\"" || line.trim() == "edition = \"2024\"");

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 {
if is_package && !is_current_edition {
tidy_error!(
bad,
"{} doesn't have `edition = \"2021\"` on a separate line",
"{} doesn't have `edition = \"2021\"` or `edition = \"2024\"` on a separate line",
file.display()
);
}
Expand Down
Loading