-
Notifications
You must be signed in to change notification settings - Fork 288
Migrate to Rust 2024 Edition #1101
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
base: main
Are you sure you want to change the base?
Conversation
- unsafe functions now mark any unsafe operations explicitly - upgrade linkme to get fix for 2024 Edition (dtolnay/linkme#101) - tweak internal generate! macro for a mysterious backwards-incompatibility in macro_rules! expansion behavior
|
Branch | edition-2024 |
Testbed | ubuntu-latest |
🚨 2 Alerts
Benchmark | Measure Units | View | Benchmark Result (Result Δ%) | Lower Boundary (Limit %) | Upper Boundary (Limit %) |
---|---|---|---|---|---|
auto-exported-noop | Latency nanoseconds (ns) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 27.91 ns(-20.85%)Baseline: 35.26 ns | 31.74 ns (113.71%) | 70.53 ns (39.57%) |
auto-exported-noop | Throughput operations / second (ops/s) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 35,833,736.70 ops/s(+22.14%)Baseline: 29,337,831.58 ops/s | 0.00 ops/s (0.00%) | 32,271,614.74 ops/s (111.04%) |
Click to view all benchmark results
Benchmark | Latency | Benchmark Result nanoseconds (ns) (Result Δ%) | Lower Boundary nanoseconds (ns) (Limit %) | Upper Boundary nanoseconds (ns) (Limit %) | Throughput | Benchmark Result operations / second (ops/s) (Result Δ%) | Lower Boundary operations / second (ops/s) (Limit %) | Upper Boundary operations / second (ops/s) (Limit %) |
---|---|---|---|---|---|---|---|---|
JsFunction::bind | 📈 view plot 🚷 view threshold | 211.34 ns(-0.47%)Baseline: 212.33 ns | 191.10 ns (90.42%) | 424.66 ns (49.77%) | 📈 view plot 🚷 view threshold | 4,731,855.32 ops/s(+0.53%)Baseline: 4,706,741.91 ops/s | 0.00 ops/s (0.00%) | 5,177,416.10 ops/s (91.39%) |
JsFunction::call | 📈 view plot 🚷 view threshold | 221.51 ns(-0.32%)Baseline: 222.22 ns | 200.00 ns (90.29%) | 444.45 ns (49.84%) | 📈 view plot 🚷 view threshold | 4,518,159.13 ops/s(+0.64%)Baseline: 4,489,230.90 ops/s | 0.00 ops/s (0.00%) | 4,938,153.99 ops/s (91.49%) |
JsFunction::call_with | 📈 view plot 🚷 view threshold | 219.13 ns(+3.28%)Baseline: 212.16 ns | 190.94 ns (87.14%) | 424.32 ns (51.64%) | 📈 view plot 🚷 view threshold | 4,560,157.58 ops/s(-3.09%)Baseline: 4,705,442.17 ops/s | 0.00 ops/s (0.00%) | 5,175,986.39 ops/s (88.10%) |
auto-exported-noop | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 27.91 ns(-20.85%)Baseline: 35.26 ns | 31.74 ns (113.71%) | 70.53 ns (39.57%) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 35,833,736.70 ops/s(+22.14%)Baseline: 29,337,831.58 ops/s | 0.00 ops/s (0.00%) | 32,271,614.74 ops/s (111.04%) |
hello-world | 📈 view plot 🚷 view threshold | 58.12 ns(+0.58%)Baseline: 57.78 ns | 52.00 ns (89.48%) | 115.56 ns (50.29%) | 📈 view plot 🚷 view threshold | 16,910,423.12 ops/s(-1.67%)Baseline: 17,198,160.04 ops/s | 0.00 ops/s (0.00%) | 18,917,976.04 ops/s (89.39%) |
manually-exported-noop | 📈 view plot 🚷 view threshold | 28.00 ns(-2.39%)Baseline: 28.69 ns | 25.82 ns (92.20%) | 57.38 ns (48.81%) | 📈 view plot 🚷 view threshold | 35,728,080.92 ops/s(+2.60%)Baseline: 34,823,720.66 ops/s | 0.00 ops/s (0.00%) | 38,306,092.73 ops/s (93.27%) |
- addresses this incompatibility: rust-lang/rust#48950
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1101 +/- ##
==========================================
+ Coverage 83.42% 83.78% +0.35%
==========================================
Files 74 74
Lines 5546 5673 +127
Branches 5546 5673 +127
==========================================
+ Hits 4627 4753 +126
- Misses 806 817 +11
+ Partials 113 103 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR migrates the Neon crates to the Rust 2024 Edition by explicitly marking unsafe operations, updating dependencies, and adjusting macro behavior for backwards-compatibility.
- Wraps all FFI calls in explicit
unsafe { … }
blocks. - Refactors
generate!
macro intoimpl_napi_wrapper!
and handles optional return types. - Bumps crate edition to 2024 and upgrades
linkme
.
Reviewed Changes
Copilot reviewed 58 out of 58 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
crates/neon/Cargo.toml | Updated to Rust 2024 Edition and bumped linkme . |
crates/neon/src/sys/call.rs | Added explicit unsafe blocks around N-API calls. |
crates/neon/src/context/internal.rs | Changed module registration attribute. |
(other sys/*.rs files) |
Wrapped FFI invocations in unsafe blocks. |
(various src/*.rs files) |
Reordered imports and moved unsafe calls into blocks. |
Comments suppressed due to low confidence (2)
crates/neon/src/sys/call.rs:44
target
is aMaybeUninit<Local>
and does not have anis_null()
method. You need to calltarget.assume_init().is_null()
after initialization to check the pointer correctly.
!target.is_null()
crates/neon/src/context/internal.rs:79
- The attribute
#[unsafe(no_mangle)]
is invalid. Replace it with#[no_mangle]
and keep theunsafe extern "C"
on the function signature.
#[unsafe(no_mangle)]
This PR upgrades Neon's two crates (
neon
andneon-macros
) to Rust 2024 Edition.Details: