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

Fix error "assigning to &T is undefined behavior" and clippy warnings #232

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

azerupi
Copy link
Contributor

@azerupi azerupi commented Jan 2, 2024

Since Rust 1.73.0 there seems to be a new deny-by-default lint to catch invalid casting from references to mutable pointers.

As far as I understand the compiler is making assumptions that references are read only and passing those assumptions on to LLVM. The only way to tell the compiler to not make those assumptions is to use UnsafeCell.

So this PR is essentially wrapping those casts with UnsafeCell and getting the mutable pointer through it.

In addition to that I fixed some warnings from compiler lints and clippy lints.

@azerupi azerupi requested a review from a team as a code owner January 2, 2024 16:10
Since Rust 1.73.0, the compiler errors about assigning to a reference
when casting it to a mutable pointer.

See: https://doc.rust-lang.org/beta/rustc/lints/listing/deny-by-default.html#invalid-reference-casting
Copy link
Contributor

@jamwaffles jamwaffles left a comment

Choose a reason for hiding this comment

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

Looks good to me, although I'd like at least one more pair of eyes on this before merge if possible.

@jamwaffles
Copy link
Contributor

Gonna call this one good. Thanks for the fix, and sorry for the delay!

@jamwaffles jamwaffles merged commit 7041775 into stm32-rs:master Jan 16, 2024
11 checks passed
@azerupi
Copy link
Contributor Author

azerupi commented Jan 16, 2024

No worries, thank you very much!

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