Skip to content

context: Avoid clippy errors #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cryptoki/src/context/general_purpose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub enum Function {

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

Expand Down
23 changes: 11 additions & 12 deletions cryptoki/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ fn session_find_objects() -> testresult::TestResult {
let key_template = vec![
Attribute::Token(true),
Attribute::Encrypt(true),
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
Attribute::ValueLen(32.into()),
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
];
Expand Down Expand Up @@ -826,7 +826,7 @@ fn session_objecthandle_iterator() -> testresult::TestResult {
Attribute::Token(true),
Attribute::Encrypt(true),
Attribute::ValueLen(32.into()),
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
];

Expand Down Expand Up @@ -1000,27 +1000,27 @@ fn login_feast() {
let session = pkcs11.open_rw_session(slot).unwrap();
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
match session.logout() {
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
match session.logout() {
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
match session.logout() {
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
Err(e) => panic!("Bad error response: {}", e),
Err(e) => panic!("Bad error response: {e}"),
}
}));
}
Expand Down Expand Up @@ -1317,7 +1317,7 @@ fn is_initialized_test() {

match pkcs11.initialize(CInitializeArgs::OsThreads) {
Err(Error::AlreadyInitialized) => (),
Err(e) => panic!("Got unexpected error when initializing: {}", e),
Err(e) => panic!("Got unexpected error when initializing: {e}"),
Ok(()) => panic!("Initializing twice should not have been allowed"),
}
}
Expand Down Expand Up @@ -1429,7 +1429,7 @@ fn ro_rw_session_test() -> TestResult {
if let Error::Pkcs11(RvError::SessionReadOnly, _f) = e {
// as expected
} else {
panic!("Got wrong error code (expecting SessionReadOnly): {}", e);
panic!("Got wrong error code (expecting SessionReadOnly): {e}");
}
ro_session.logout()?;
}
Expand Down Expand Up @@ -2075,8 +2075,7 @@ fn wait_for_slot_event() {
Function::WaitForSlotEvent
))
),
"res = {:?}",
res
"res = {res:?}"
);
}

Expand Down
Loading