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#136395 - ChrisDenton:rand-0-9, r=Mark-Simul…
…acrum Update to rand 0.9.0 Changes include: - `thread_rng` has been renamed to `rng` - `Standard` has been renamed to `StandardUniform` - `gen`, `gen_range`, `gen_bool` have been renamed to `random`, `random_range` and `random_bool` respectively.
- Loading branch information
Showing
9 changed files
with
63 additions
and
35 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
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
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
//! Checks the licenses of third-party dependencies. | ||
use std::collections::HashSet; | ||
use std::collections::{HashMap, HashSet}; | ||
use std::fs::{File, read_dir}; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
use build_helper::ci::CiEnv; | ||
use cargo_metadata::semver::Version; | ||
use cargo_metadata::{Metadata, Package, PackageId}; | ||
|
||
#[path = "../../../bootstrap/src/utils/proc_macro_deps.rs"] | ||
|
@@ -445,6 +446,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ | |
"windows_x86_64_gnu", | ||
"windows_x86_64_gnullvm", | ||
"windows_x86_64_msvc", | ||
"[email protected]", // via wasi | ||
"writeable", | ||
"yoke", | ||
"yoke-derive", | ||
|
@@ -802,7 +804,17 @@ fn check_permitted_dependencies( | |
|
||
// Check that the PERMITTED_DEPENDENCIES does not have unused entries. | ||
for permitted in permitted_dependencies { | ||
if !deps.iter().any(|dep_id| &pkg_from_id(metadata, dep_id).name == permitted) { | ||
fn compare(pkg: &Package, permitted: &str) -> bool { | ||
if let Some((name, version)) = permitted.split_once("@") { | ||
let Ok(version) = Version::parse(version) else { | ||
return false; | ||
}; | ||
pkg.name == name && pkg.version == version | ||
} else { | ||
pkg.name == permitted | ||
} | ||
} | ||
if !deps.iter().any(|dep_id| compare(pkg_from_id(metadata, dep_id), permitted)) { | ||
tidy_error!( | ||
bad, | ||
"could not find allowed package `{permitted}`\n\ | ||
|
@@ -813,14 +825,30 @@ fn check_permitted_dependencies( | |
} | ||
|
||
// Get in a convenient form. | ||
let permitted_dependencies: HashSet<_> = permitted_dependencies.iter().cloned().collect(); | ||
let permitted_dependencies: HashMap<_, _> = permitted_dependencies | ||
.iter() | ||
.map(|s| { | ||
if let Some((name, version)) = s.split_once('@') { | ||
(name, Version::parse(version).ok()) | ||
} else { | ||
(*s, None) | ||
} | ||
}) | ||
.collect(); | ||
|
||
for dep in deps { | ||
let dep = pkg_from_id(metadata, dep); | ||
// If this path is in-tree, we don't require it to be explicitly permitted. | ||
if dep.source.is_some() && !permitted_dependencies.contains(dep.name.as_str()) { | ||
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id); | ||
has_permitted_dep_error = true; | ||
if dep.source.is_some() { | ||
let is_eq = if let Some(version) = permitted_dependencies.get(dep.name.as_str()) { | ||
if let Some(version) = version { version == &dep.version } else { true } | ||
} else { | ||
false | ||
}; | ||
if !is_eq { | ||
tidy_error!(bad, "Dependency for {descr} not explicitly permitted: {}", dep.id); | ||
has_permitted_dep_error = true; | ||
} | ||
} | ||
} | ||
|
||
|