1use std::fs;
4use std::path::Path;
5
6const ALLOWED_SOURCES: &[&str] = &[
8 r#""registry+https://github.com/rust-lang/crates.io-index""#,
9 r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
11];
12
13pub fn check(root: &Path, bad: &mut bool) {
16 for &(workspace, _, _, submodules) in crate::deps::WORKSPACES {
17 if crate::deps::has_missing_submodule(root, submodules) {
18 continue;
19 }
20
21 let path = root.join(workspace).join("Cargo.lock");
24
25 if !path.exists() {
26 tidy_error!(bad, "the `{workspace}` workspace doesn't have a Cargo.lock");
27 continue;
28 }
29
30 let cargo_lock = t!(fs::read_to_string(&path));
32
33 for line in cargo_lock.lines() {
35 if !line.starts_with("source = ") {
37 continue;
38 }
39
40 let source = line.split_once('=').unwrap().1.trim();
42
43 if !ALLOWED_SOURCES.contains(&&*source) {
45 tidy_error!(bad, "invalid source: {}", source);
46 }
47 }
48 }
49}