1- use std:: time:: Duration ;
2- use std:: collections:: HashMap ;
3- use std:: process:: Command ;
4- use std:: io:: Write ;
51use crates_io_api:: { CratesQuery , Sort } ;
62use itertools:: Itertools ;
3+ use std:: collections:: HashMap ;
4+ use std:: io:: Write ;
5+ use std:: process:: Command ;
6+ use std:: time:: Duration ;
77
88/// To get the rustdoc of the current, we first create a placeholder project somewhere
99/// with the current as a dependency, and run `cargo rustdoc` on it.
1010fn create_rustdoc_manifest_for_crate_version (
1111 name : & str ,
1212 version : & str ,
13- features : & HashMap < String , Vec < String > >
13+ features : & HashMap < String , Vec < String > > ,
1414) -> cargo_toml:: Manifest < ( ) > {
1515 use cargo_toml:: * ;
1616
@@ -30,11 +30,8 @@ fn create_rustdoc_manifest_for_crate_version(
3030 } ,
3131 dependencies : {
3232 let project_with_features = DependencyDetail {
33- version : Some ( format ! ( "={}" , version. to_string( ) ) ) ,
34- features : features
35- . keys ( )
36- . cloned ( )
37- . collect ( ) ,
33+ version : Some ( format ! ( "={version}" ) ) ,
34+ features : features. keys ( ) . cloned ( ) . collect ( ) ,
3835 ..DependencyDetail :: default ( )
3936 } ;
4037 let mut deps = DepsSet :: new ( ) ;
@@ -54,15 +51,15 @@ fn save_manifest(manifest: cargo_toml::Manifest<()>, path: &str) -> anyhow::Resu
5451}
5552
5653fn run_checks_on_manifest ( baseline_version : & str ) -> anyhow:: Result < ( ) > {
57- let output = Command :: new ( "cargo" )
54+ let output = Command :: new ( "cargo" )
5855 . current_dir ( "crate_current" )
5956 . args ( [
6057 "run" ,
6158 "--manifest-path=../../../Cargo.toml" ,
6259 "--" ,
6360 "semver-checks" ,
6461 "check-release" ,
65- & format ! ( "--baseline-version={baseline_version}" )
62+ & format ! ( "--baseline-version={baseline_version}" ) ,
6663 ] )
6764 . output ( ) ?;
6865 std:: io:: stdout ( ) . write_all ( & output. stdout ) ?;
@@ -87,10 +84,21 @@ fn main() -> anyhow::Result<()> {
8784
8885 for crate_info in crate_page. crates . into_iter ( ) {
8986 let versions = client. get_crate ( & crate_info. name ) ?. versions ;
90- let versions: Vec < crates_io_api:: Version > = versions. into_iter ( ) . filter ( |v| !v. yanked ) . collect ( ) ;
87+ let versions: Vec < crates_io_api:: Version > =
88+ versions. into_iter ( ) . filter ( |v| !v. yanked ) . collect ( ) ;
9189 for ( version_current, version_baseline) in versions. iter ( ) . tuple_windows ( ) {
92- println ! ( "{} {} {}" , crate_info. name, version_current. num, version_baseline. num) ;
93- save_manifest ( create_rustdoc_manifest_for_crate_version ( & crate_info. name , & version_current. num , & version_current. features ) , "crate_current/Cargo.toml" ) ?;
90+ println ! (
91+ "{} {} {}" ,
92+ crate_info. name, version_current. num, version_baseline. num
93+ ) ;
94+ save_manifest (
95+ create_rustdoc_manifest_for_crate_version (
96+ & crate_info. name ,
97+ & version_current. num ,
98+ & version_current. features ,
99+ ) ,
100+ "crate_current/Cargo.toml" ,
101+ ) ?;
94102 run_checks_on_manifest ( & version_baseline. num ) ?;
95103 }
96104 }
0 commit comments