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"
4
4
edition = " 2021"
5
5
6
6
[dependencies ]
7
- bytecount = " 0.6"
8
7
clap = " 2.33"
9
8
indoc = " 1.0"
10
9
itertools = " 0.10.1"
11
10
opener = " 0.5"
12
11
shell-escape = " 0.1"
13
12
walkdir = " 2.3"
14
- cargo_metadata = " 0.14"
15
-
16
13
17
14
[features ]
18
15
deny-warnings = []
Original file line number Diff line number Diff line change
1
+ #![ feature( let_else) ]
1
2
#![ feature( once_cell) ]
2
3
#![ feature( rustc_private) ]
3
4
#![ 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 {
133
133
}
134
134
135
135
fn 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
+ ) )
142
150
}
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` ")
145
153
}
146
154
147
155
fn get_test_file_contents ( lint_name : & str , header_commands : Option < & str > ) -> String {
You can’t perform that action at this time.
0 commit comments