-
Notifications
You must be signed in to change notification settings - Fork 6
Migrate to Edition 2024 #10
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
Conversation
《Change in Guidance on Committing Lockfiles》 https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html i.e ❌ Why do binaries have Cargo.lock in version control, but not libraries? https://doc.rust-lang.org/1.71.1/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries 这一条甚至已经不存在于新的 cargo book ✅ Why have Cargo.lock in version control? https://doc.rust-lang.org/nightly/cargo/faq.html#why-have-cargolock-in-version-control
add a FIXME for u128 being non-FFI-safe
out(reg) base, | ||
VAR = sym __PERCPU_CURRENT_TASK_PTR, | ||
); | ||
unsafe { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the reason to add unsafe
block here when the functions have been marked unsafe? Or you can paste the warning or error reported by the compiler.Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the suggstion from unsafe_op_in_unsafe_fn lint, as stated in PR description
mostly around adding unsafe block for calling unsafe code (refer to unsafe_op_in_unsafe_fn for more info)
A diagnostic example on playground:
warning[E0133]: call to unsafe function `core::slice::<impl [T]>::get_unchecked` is unsafe and requires unsafe block
--> src/lib.rs:2:3
|
2 | x.get_unchecked(i) // WARNING: requires unsafe block
| ^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
= note: consult the function's documentation for information on how to avoid undefined behavior
note: an unsafe function restricts its caller, but its body is safe by default
--> src/lib.rs:1:1
|
1 | pub unsafe fn get_unchecked<T>(x: &[T], i: usize) -> &T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default
For more information about this error, try `rustc --explain E0133`.
I'll quote from the linked edition guide book:
This change is intended to help protect against accidental use of unsafe operations in an unsafe function. The unsafe function keyword was performing two roles. One was to declare that calling the function requires unsafe, and that the caller is responsible to uphold additional safety requirements. The other role was to allow the use of unsafe operations inside of the function. This second role was determined to be too risky without explicit unsafe blocks.
More information and motivation may be found in RFC #2585.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks
Maybe we can avoid using
|
This PR includes:
Tested successfully on local machine with these commands:
cargo c --all-features --target x86_64-unknown-none
: good with no diagnosticscargo c --all-features --target riscv64gc-unknown-none-elf
: good with no diagnosticscargo c --target riscv32imafc-unknown-none-elf
: good with no diagnosticsTested with warnings of u128 being not FFI-safe:
Tested with errors that shows code doesn't support riscv32: