-
Notifications
You must be signed in to change notification settings - Fork 5.8k
chore: update to Rust 1.76 #22376
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
chore: update to Rust 1.76 #22376
Conversation
cli/napi/util.rs
Outdated
| use deno_runtime::deno_napi::*; | ||
| use std::cell::Cell; | ||
|
|
||
| #[allow(invalid_reference_casting)] |
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.
I think this is actually invalid code.
Does this compile?
unsafe fn get_backing_store_slice(
backing_store: &mut v8::SharedRef<v8::BackingStore>,
byte_offset: usize,
byte_length: usize,
) -> &mut [u8] {
let cells: *mut [Cell<u8>] =
&mut backing_store[byte_offset..byte_offset + byte_length];
let mut bytes = cells as *mut [u8];
&mut *bytes
}
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.
Thank you for your reply.
Does this compile?
I think it was compile, maybe I miss something.
I think this is actually invalid code.
I try to remove #[allow(invalid_reference_casting)] code, I got this warning
warning: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> cli\napi\util.rs:14:3
|
13 | let mut bytes = cells as *mut [u8];
| ------------------ casting happend here
14 | &mut *bytes
| ^^^^^^^^^^^
|
= note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
= note: even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
= note: `#[warn(invalid_reference_casting)]` on by default
warning: `deno` (bin "deno") generated 1 warning
warning: `deno` (bin "deno" test) generated 1 warning (1 duplicate)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.
Could you try replacing this code with the code I put above and see if that fixes the warning?
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.
Could you try replacing this code with the code I put above and see if that fixes the warning?
I got this error
error[E0596]: cannot borrow data in dereference of `deno_core::v8::BackingStore` as mutable
--> cli\napi\util.rs:12:10
|
12 | &mut backing_store[byte_offset..byte_offset + byte_length];
| ^^^^^^^^^^^^^ cannot borrow as mutable
|
= help: trait `DerefMut` is required to modify through a dereference, but it is not implemented for `deno_core::v8::BackingStore`
For more information about this error, try `rustc --explain E0596`.
error: could not compile `deno` (bin "deno") due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `deno` (bin "deno" test) due to 1 previous errorThere 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.
I'll push a change to this PR to fix it. I think I know what to do here.
mmastrac
left a comment
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.
LGTM
Update to Rust 1.76
If this PR has any problem, please tell me.