Skip to content
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

Add unsafe keyword to unsafe block in rust code #18264

Closed

Conversation

tempoz
Copy link
Contributor

@tempoz tempoz commented Sep 11, 2024

No description provided.

@tempoz tempoz requested a review from a team as a code owner September 11, 2024 17:14
@tempoz tempoz requested review from sbenzaquen and removed request for a team September 11, 2024 17:14
@esrauchg
Copy link

This is a little bit of an unfortunate situation; starting in 1.81 this usage of an extern static is not considered unsafe (thanks to the fix rust-lang/rust#125834).

This means that adding this unsafe{} will give an "warning: unnecessary unsafe block" if on 1.81 or higher, but is necessary to compile under 1.80 or lower.

I think basically we need to add the unsafe{} block but also a #[allow(unused_unsafe)] on the block, with a comment about how this is unsafe only for 1.80 and below and so can be dropped once our MSRV is bumped to be 1.81+.

Can you add that to your PR? Thanks!

@esrauchg esrauchg requested review from esrauchg and removed request for sbenzaquen September 16, 2024 20:16
@tempoz
Copy link
Contributor Author

tempoz commented Sep 18, 2024

Done!
Hopefully I added the allow_unused_unsafe correctly; I'm not really very familiar with Rust.

Copy link

@esrauchg esrauchg left a comment

Choose a reason for hiding this comment

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

Thanks!

@esrauchg esrauchg added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Sep 18, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants