]> git.proxmox.com Git - rustc.git/blob - src/doc/book/ci/stable-check/src/main.rs
New upstream version 1.34.2+dfsg1
[rustc.git] / src / doc / book / ci / stable-check / src / main.rs
1 use std::error::Error;
2 use std::env;
3 use std::fs;
4 use std::fs::File;
5 use std::io::prelude::*;
6 use std::path::Path;
7
8 fn main() {
9 let arg = env::args().nth(1).unwrap_or_else(|| {
10 println!("Please pass a src directory as the first argument");
11 std::process::exit(1);
12 });
13
14 match check_directory(&Path::new(&arg)) {
15 Ok(()) => println!("passed!"),
16 Err(e) => {
17 println!("Error: {}", e);
18 std::process::exit(1);
19 }
20 }
21
22 }
23
24 fn check_directory(dir: &Path) -> Result<(), Box<Error>> {
25 for entry in fs::read_dir(dir)? {
26 let entry = entry?;
27 let path = entry.path();
28
29 if path.is_dir() {
30 continue;
31 }
32
33 let mut file = File::open(&path)?;
34 let mut contents = String::new();
35 file.read_to_string(&mut contents)?;
36
37 if contents.contains("#![feature") {
38 return Err(From::from(format!("Feature flag found in {:?}", path)));
39 }
40 }
41
42 Ok(())
43 }