@@ -156,6 +156,16 @@ def main(print_only=False, check=False):
156
156
collect (lints , deprecated_lints , restriction_lints ,
157
157
os .path .join (root , fn ))
158
158
159
+ # determine version
160
+ with open ('Cargo.toml' ) as fp :
161
+ for line in fp :
162
+ if line .startswith ('version =' ):
163
+ clippy_version = line .split ()[2 ].strip ('"' )
164
+ break
165
+ else :
166
+ print ('Error: version not found in Cargo.toml!' )
167
+ return
168
+
159
169
if print_only :
160
170
sys .stdout .writelines (gen_table (lints + restriction_lints ))
161
171
return
@@ -183,6 +193,19 @@ def main(print_only=False, check=False):
183
193
key = lambda l : l [1 ])],
184
194
replace_start = False , write_back = not check )
185
195
196
+ # update version of clippy_lints in Cargo.toml
197
+ changed |= replace_region (
198
+ 'Cargo.toml' , r'# begin automatic update' , '# end automatic update' ,
199
+ lambda : ['clippy_lints = { version = "%s", path = "clippy_lints" }\n ' %
200
+ clippy_version ],
201
+ replace_start = False , write_back = not check )
202
+
203
+ # update version of clippy_lints in Cargo.toml
204
+ changed |= replace_region (
205
+ 'clippy_lints/Cargo.toml' , r'# begin automatic update' , '# end automatic update' ,
206
+ lambda : ['version = "%s"\n ' % clippy_version ],
207
+ replace_start = False , write_back = not check )
208
+
186
209
# update the `pub mod` list
187
210
changed |= replace_region (
188
211
'clippy_lints/src/lib.rs' , r'begin lints modules' , r'end lints modules' ,
0 commit comments