@@ -27,7 +27,7 @@ pub mod target {
27
27
/// Ensures that the `TARGET` is valid for cross compilation.
28
28
pub fn ensure_supported ( ) {
29
29
let target = Triple :: from_str ( & std:: env:: var ( TARGET_ENV_VAR_NAME ) . unwrap_or_else ( |_| {
30
- panic ! ( "Missing environment variable `{}`." , TARGET_ENV_VAR_NAME ) ;
30
+ panic ! ( "Missing environment variable `{TARGET_ENV_VAR_NAME }`." ) ;
31
31
} ) )
32
32
. expect ( "Failed to parse target triple." ) ;
33
33
match ( target. architecture , target. operating_system ) {
@@ -37,10 +37,9 @@ pub mod target {
37
37
| ( Architecture :: X86_64 , OperatingSystem :: Linux ) => { }
38
38
( arch, os) => {
39
39
panic ! (
40
- "Compilation target (architecture, OS) tuple ({}, {}) is not part of the \
40
+ "Compilation target (architecture, OS) tuple ({arch }, {os }) is not part of the \
41
41
supported tuples. Please compile with the \" generate-bindings\" feature or \
42
- add support for your platform.",
43
- arch, os
42
+ add support for your platform."
44
43
) ;
45
44
}
46
45
}
@@ -163,10 +162,7 @@ pub mod tpm2_tss {
163
162
std:: env:: var ( PATH_ENV_VAR_NAME ) . map_or_else (
164
163
|e| match e {
165
164
std:: env:: VarError :: NotUnicode ( invalid_value) => {
166
- panic ! (
167
- "Invalid `{}` env var: `{:?}`." ,
168
- PATH_ENV_VAR_NAME , invalid_value
169
- ) ;
165
+ panic ! ( "Invalid `{PATH_ENV_VAR_NAME}` env var: `{invalid_value:?}`." ) ;
170
166
}
171
167
std:: env:: VarError :: NotPresent => None ,
172
168
} ,
@@ -196,64 +192,53 @@ pub mod tpm2_tss {
196
192
let install_path = PathBuf :: from ( env_var) ;
197
193
if !install_path. is_dir ( ) {
198
194
panic ! (
199
- "The tpm2-tss installation path `{}` specifies an existing directory (`{}`)." ,
200
- PATH_ENV_VAR_NAME ,
201
- install_path. to_string_lossy( ) ,
195
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies an existing directory (`{}`)." ,
196
+ install_path. to_string_lossy( )
202
197
) ;
203
198
}
204
199
if !install_path. join ( "include" ) . is_dir ( ) {
205
200
panic ! (
206
- "The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
201
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME }` specifies a path `{}`, that does not \
207
202
contain an `include` directory",
208
- PATH_ENV_VAR_NAME ,
209
- install_path. to_string_lossy( ) ,
203
+ install_path. to_string_lossy( )
210
204
) ;
211
205
}
212
206
if !install_path. join ( "lib" ) . is_dir ( ) {
213
207
panic ! (
214
- "The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
208
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME }` specifies a path `{}`, that does not \
215
209
contain an `lib` directory",
216
- PATH_ENV_VAR_NAME ,
217
- install_path. to_string_lossy( ) ,
210
+ install_path. to_string_lossy( )
218
211
) ;
219
212
}
220
213
let version_str =
221
214
std:: fs:: read_to_string ( install_path. join ( "VERSION" ) ) . unwrap_or_else ( |e| {
222
215
panic ! (
223
- "The tpm2-tss installation path `{}` specifies a path `{}`, that does not \
224
- contain a readable VERSION file: {}.",
225
- PATH_ENV_VAR_NAME ,
226
- install_path. to_string_lossy( ) ,
227
- e,
216
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, that does not \
217
+ contain a readable VERSION file: {e}.",
218
+ install_path. to_string_lossy( )
228
219
) ;
229
220
} ) ;
230
221
let version = Version :: parse ( version_str. trim ( ) ) . unwrap_or_else ( |e| {
231
222
panic ! (
232
- "The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
233
- VERSION file that cannot be parsed: {}.",
234
- PATH_ENV_VAR_NAME ,
235
- install_path. to_string_lossy( ) ,
236
- e
223
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
224
+ VERSION file that cannot be parsed: {e}.",
225
+ install_path. to_string_lossy( )
237
226
) ;
238
227
} ) ;
239
228
240
- let min_version_req_str = format ! ( ">={}" , MINIMUM_VERSION ) ;
229
+ let min_version_req_str = format ! ( ">={MINIMUM_VERSION}" ) ;
241
230
let min_version_req = VersionReq :: parse ( & min_version_req_str) . unwrap_or_else ( |e| {
242
231
panic ! (
243
232
"[Internal Error]: Failed to parse minimum tpm2-tss library version \
244
- requirement. Error: `{}`. Please report this.",
245
- e
233
+ requirement. Error: `{e}`. Please report this."
246
234
) ;
247
235
} ) ;
248
236
if !min_version_req. matches ( & version) {
249
237
panic ! (
250
- "The tpm2-tss installation path `{}` specifies a path `{}`, contains a \
251
- VERSION file that specifies a version `{}` that does not meet the minimum \
252
- version requirement `{}`.",
253
- PATH_ENV_VAR_NAME ,
254
- install_path. to_string_lossy( ) ,
255
- version_str,
256
- MINIMUM_VERSION ,
238
+ "The tpm2-tss installation path `{PATH_ENV_VAR_NAME}` specifies a path `{}`, contains a \
239
+ VERSION file that specifies a version `{version_str}` that does not meet the minimum \
240
+ version requirement `{MINIMUM_VERSION}`.",
241
+ install_path. to_string_lossy( )
257
242
) ;
258
243
}
259
244
println ! (
@@ -296,8 +281,7 @@ pub mod tpm2_tss {
296
281
Self :: probe_optional ( lib_name, install_path, with_header_files) . map_or_else (
297
282
|| {
298
283
panic ! (
299
- "Failed to find {} library of version {MINIMUM_VERSION} or greater." ,
300
- lib_name
284
+ "Failed to find {lib_name} library of version {MINIMUM_VERSION} or greater."
301
285
)
302
286
} ,
303
287
|lib| {
@@ -356,7 +340,7 @@ pub mod tpm2_tss {
356
340
self . name
357
341
) ;
358
342
} ,
359
- |v| format ! ( "-I{}" , v ) ,
343
+ |v| format ! ( "-I{v}" ) ,
360
344
)
361
345
}
362
346
@@ -436,7 +420,7 @@ pub mod tpm2_tss {
436
420
let lib_path = path. join ( "lib" ) ;
437
421
Self :: lib_file ( lib_name, & lib_path) ?;
438
422
// If the lib file was found then the name is reported to Cargo.
439
- println ! ( "cargo:rustc-link-lib={}" , lib_name ) ;
423
+ println ! ( "cargo:rustc-link-lib={lib_name}" ) ;
440
424
441
425
let include_path = path. join ( "include/tss2" ) ;
442
426
Some ( Self {
@@ -481,8 +465,7 @@ pub mod tpm2_tss {
481
465
let mut associated_files = hit_iter. collect :: < Vec < PathBuf > > ( ) ;
482
466
associated_files. push ( hit. clone ( ) ) ;
483
467
panic ! (
484
- "More then one match found for library `{}`: {:?}" ,
485
- lib_name, associated_files
468
+ "More then one match found for library `{lib_name}`: {associated_files:?}" ,
486
469
) ;
487
470
}
488
471
}
0 commit comments