Skip to content

Commit 752d405

Browse files
committed
context: Avoid clippy errors
error: variables can be used directly in the `format!` string --> cryptoki/src/context/general_purpose.rs:161:9 | 161 | write!(f, "Function::{:?}", self) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args = note: `-D clippy::uninlined-format-args` implied by `-D clippy::all` = help: to override `-D clippy::all` add `#[allow(clippy::uninlined_format_args)]` Many similar also lived in tests Signed-off-by: Jakub Jelen <jjelen@redhat.com>
1 parent bf85b6f commit 752d405

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

cryptoki/src/context/general_purpose.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub enum Function {
145145

146146
impl Display for Function {
147147
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
148-
write!(f, "Function::{:?}", self)
148+
write!(f, "Function::{self:?}")
149149
}
150150
}
151151

cryptoki/tests/basic.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ fn session_find_objects() -> testresult::TestResult {
774774
let key_template = vec![
775775
Attribute::Token(true),
776776
Attribute::Encrypt(true),
777-
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
777+
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
778778
Attribute::ValueLen(32.into()),
779779
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
780780
];
@@ -826,7 +826,7 @@ fn session_objecthandle_iterator() -> testresult::TestResult {
826826
Attribute::Token(true),
827827
Attribute::Encrypt(true),
828828
Attribute::ValueLen(32.into()),
829-
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
829+
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
830830
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
831831
];
832832

@@ -1000,27 +1000,27 @@ fn login_feast() {
10001000
let session = pkcs11.open_rw_session(slot).unwrap();
10011001
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10021002
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1003-
Err(e) => panic!("Bad error response: {}", e),
1003+
Err(e) => panic!("Bad error response: {e}"),
10041004
}
10051005
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10061006
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1007-
Err(e) => panic!("Bad error response: {}", e),
1007+
Err(e) => panic!("Bad error response: {e}"),
10081008
}
10091009
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10101010
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1011-
Err(e) => panic!("Bad error response: {}", e),
1011+
Err(e) => panic!("Bad error response: {e}"),
10121012
}
10131013
match session.logout() {
10141014
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1015-
Err(e) => panic!("Bad error response: {}", e),
1015+
Err(e) => panic!("Bad error response: {e}"),
10161016
}
10171017
match session.logout() {
10181018
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1019-
Err(e) => panic!("Bad error response: {}", e),
1019+
Err(e) => panic!("Bad error response: {e}"),
10201020
}
10211021
match session.logout() {
10221022
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1023-
Err(e) => panic!("Bad error response: {}", e),
1023+
Err(e) => panic!("Bad error response: {e}"),
10241024
}
10251025
}));
10261026
}
@@ -1317,7 +1317,7 @@ fn is_initialized_test() {
13171317

13181318
match pkcs11.initialize(CInitializeArgs::OsThreads) {
13191319
Err(Error::AlreadyInitialized) => (),
1320-
Err(e) => panic!("Got unexpected error when initializing: {}", e),
1320+
Err(e) => panic!("Got unexpected error when initializing: {e}"),
13211321
Ok(()) => panic!("Initializing twice should not have been allowed"),
13221322
}
13231323
}
@@ -1429,7 +1429,7 @@ fn ro_rw_session_test() -> TestResult {
14291429
if let Error::Pkcs11(RvError::SessionReadOnly, _f) = e {
14301430
// as expected
14311431
} else {
1432-
panic!("Got wrong error code (expecting SessionReadOnly): {}", e);
1432+
panic!("Got wrong error code (expecting SessionReadOnly): {e}");
14331433
}
14341434
ro_session.logout()?;
14351435
}
@@ -2075,8 +2075,7 @@ fn wait_for_slot_event() {
20752075
Function::WaitForSlotEvent
20762076
))
20772077
),
2078-
"res = {:?}",
2079-
res
2078+
"res = {res:?}"
20802079
);
20812080
}
20822081

0 commit comments

Comments
 (0)