Skip to content

Conversation

@nnethercote
Copy link
Collaborator

Rust CUDA uses a mix of 2018, 2021 and 2024 editions. It's worth updating to 2024 across the board to promote the idea that the project has been rebooted and is in active development again.

The most significant change is that Rust 2024 requires unsafe operations in unsafe functions to be marked explicitly as unsafe. In particular, this affects kernels.

(These will be updated to 2024 in a separate commit.)

The only change required is in a macro, where spaces are needed before
`#` to avoid a "prefixed identifiers and literals are reserved
since Rust 2021" error.
Three kinds of changes are required.
- Unsafe operations within unsafe functions now need to be explicitly
  marked with `unsafe`.
- `#[no_mangle]` now must be `#[unsafe(no_mangle)]`.
- `gen` is now a keyword.
- `cargo fmt` formats some things slightly different in edition 2024.
- `env::set_var` is now unsafe.
- Clippy wants nested `if`s to be chained where possible.
Three kinds of changes are required.
- Unsafe operations within unsafe functions now need to be explicitly
  marked with `unsafe`.
  - This requires setting `.wrap_unsafe_ops` for unsafe functions
    generated by bindgen.
- `extern "C"` blocks now need to be marked as unsafe.
- `cargo fmt` formats some things slightly different in edition 2024.
Again, all the unsafe operations within unsafe functions now need
explicit `unsafe` marking.
Copy link
Contributor

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

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

Lots of changes, hard to review. Tests passing so 🚀

@LegNeato LegNeato merged commit 65f66ec into Rust-GPU:main Dec 10, 2025
8 checks passed
nnethercote added a commit to nnethercote/Rust-CUDA that referenced this pull request Dec 11, 2025
The merging of two unintentionally interdependent PRs left `path-tracer`
in a broken state.
- Rust-GPU#335 updated it from edition 2018 to 2024, while it was disabled
  (commented out).
- Rust-GPU#332 re-enabled it.

This left it marked as using edition 2024 but without the appropriate
changes for edition 2024. This commit makes those changes.
@nnethercote nnethercote mentioned this pull request Dec 11, 2025
LegNeato pushed a commit that referenced this pull request Dec 11, 2025
The merging of two unintentionally interdependent PRs left `path-tracer`
in a broken state.
- #335 updated it from edition 2018 to 2024, while it was disabled
  (commented out).
- #332 re-enabled it.

This left it marked as using edition 2024 but without the appropriate
changes for edition 2024. This commit makes those changes.
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