forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#63087 - crlf0710:tidy_2018, r=Mark-Simulacrum
Add very simple edition check to tidy. Fixes rust-lang#58099.
- Loading branch information
Showing
6 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! Tidy check to ensure that crate `edition` is '2018' | ||
//! | ||
use std::path::Path; | ||
|
||
fn filter_dirs(path: &Path) -> bool { | ||
// FIXME: just use super::filter_dirs after the submodules are updated. | ||
if super::filter_dirs(path) { | ||
return true; | ||
} | ||
let skip = [ | ||
"src/doc/book/second-edition", | ||
"src/doc/book/2018-edition", | ||
"src/doc/book/ci/stable-check", | ||
"src/doc/reference/stable-check", | ||
]; | ||
skip.iter().any(|p| path.ends_with(p)) | ||
} | ||
|
||
fn is_edition_2018(mut line: &str) -> bool { | ||
line = line.trim(); | ||
line == "edition = \"2018\"" || line == "edition = \'2018\'" | ||
} | ||
|
||
pub fn check(path: &Path, bad: &mut bool) { | ||
super::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 has_edition = contents.lines().any(is_edition_2018); | ||
if !has_edition { | ||
tidy_error!( | ||
bad, | ||
"{} doesn't have `edition = \"2018\"` on a separate line", | ||
file.display() | ||
); | ||
} | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters