Skip to content

refactor: enable clippy unsafe blocks related lints#576

Merged
CBenoit merged 3 commits intomasterfrom
refactor/clippy-unsafe-blocks-lints
Dec 22, 2025
Merged

refactor: enable clippy unsafe blocks related lints#576
CBenoit merged 3 commits intomasterfrom
refactor/clippy-unsafe-blocks-lints

Conversation

@TheBestTvarynka
Copy link
Collaborator

Checks for unsafe blocks and impls without a // SAFETY: comment explaining why the unsafe operations performed inside the block are safe.

https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks

Checks for unsafe blocks that contain more than one unsafe operation.

https://rust-lang.github.io/rust-clippy/master/index.html#multiple_unsafe_ops_per_block

@TheBestTvarynka TheBestTvarynka self-assigned this Dec 19, 2025
@TheBestTvarynka TheBestTvarynka force-pushed the refactor/clippy-unsafe-blocks-lints branch from 6094199 to bdc82c4 Compare December 19, 2025 19:19
Copy link
Member

@CBenoit CBenoit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@CBenoit CBenoit enabled auto-merge (squash) December 20, 2025 09:41
@CBenoit
Copy link
Member

CBenoit commented Dec 20, 2025

You need to verify on other platforms too, but I enabled auto-merge!

@CBenoit CBenoit merged commit 18746e0 into master Dec 22, 2025
63 checks passed
@CBenoit CBenoit deleted the refactor/clippy-unsafe-blocks-lints branch December 22, 2025 12:06
@TheBestTvarynka
Copy link
Collaborator Author

TheBestTvarynka commented Dec 22, 2025

Honestly, I do not know why this commit fixed the error reported by Miri (see the last failed CI pipeline): 6b30a7a.

I wrote a similar example in the playground, and it works with the previous approach: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3912329ddc1fc332b47c22ce68d33fdd.

Maybe it's a bug in the stacked borrows implementation (they are still experimental). But then, why did it not happen before? 🤔🤔🤔

Comment on lines +293 to +294
// SAFETY: `sspi_context_ptr` is a valid, local pointer to the `SspiHandle` allocated by the `p_ctx_handle_to_sspi_context`.
let sspi_context_ptr = unsafe { sspi_context_ptr.as_mut() };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a bit surprised by this because obtaining a pointer is generally not unsafe 🤔

@CBenoit
Copy link
Member

CBenoit commented Dec 22, 2025

Honestly, I do not know why this commit fixed the error reported by Miri (see the last failed CI pipeline): 6b30a7a.

I wrote a similar example in the playground, and it works with the previous approach: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=3912329ddc1fc332b47c22ce68d33fdd.

Maybe it's a bug in the stacked borrows implementation (they are still experimental). But then, why did it not happen before? 🤔🤔🤔

Very good question! It’s nice that you wrote a reproducer, unfortunate that it didn’t help isolate the issue 😕
Since miri is performing dynamic analysis (the program is actually running), any chance you didn’t reproduce some specific memory state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants