File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,12 @@ version = "0.0.1"
44edition = " 2021"
55
66[dependencies ]
7- bytecount = " 0.6"
87clap = " 2.33"
98indoc = " 1.0"
109itertools = " 0.10.1"
1110opener = " 0.5"
1211shell-escape = " 0.1"
1312walkdir = " 2.3"
14- cargo_metadata = " 0.14"
15-
1613
1714[features ]
1815deny-warnings = []
Original file line number Diff line number Diff line change 1+ #![ feature( let_else) ]
12#![ feature( once_cell) ]
23#![ feature( rustc_private) ]
34#![ cfg_attr( feature = "deny-warnings" , deny( warnings) ) ]
Original file line number Diff line number Diff line change @@ -133,15 +133,23 @@ fn to_camel_case(name: &str) -> String {
133133}
134134
135135fn get_stabilisation_version ( ) -> String {
136- let mut command = cargo_metadata:: MetadataCommand :: new ( ) ;
137- command. no_deps ( ) ;
138- if let Ok ( metadata) = command. exec ( ) {
139- if let Some ( pkg) = metadata. packages . iter ( ) . find ( |pkg| pkg. name == "clippy" ) {
140- return format ! ( "{}.{}.0" , pkg. version. minor, pkg. version. patch) ;
141- }
136+ fn parse_manifest ( contents : & str ) -> Option < String > {
137+ let version = contents
138+ . lines ( )
139+ . filter_map ( |l| l. split_once ( '=' ) )
140+ . find_map ( |( k, v) | ( k. trim ( ) == "version" ) . then ( || v. trim ( ) ) ) ?;
141+ let Some ( ( "0" , version) ) = version. get ( 1 ..version. len ( ) - 1 ) ?. split_once ( '.' ) else {
142+ return None ;
143+ } ;
144+ let ( minor, patch) = version. split_once ( '.' ) ?;
145+ Some ( format ! (
146+ "{}.{}.0" ,
147+ minor. parse:: <u32 >( ) . ok( ) ?,
148+ patch. parse:: <u32 >( ) . ok( ) ?
149+ ) )
142150 }
143-
144- String :: from ( "<TODO set version(see doc/adding_lints.md)> ")
151+ let contents = fs :: read_to_string ( "Cargo.toml" ) . expect ( "Unable to read `Cargo.toml`" ) ;
152+ parse_manifest ( & contents ) . expect ( "Unable to find package version in `Cargo.toml` ")
145153}
146154
147155fn get_test_file_contents ( lint_name : & str , header_commands : Option < & str > ) -> String {
You can’t perform that action at this time.
0 commit comments