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

elsa 1.11.0 fails to compile in older Rust toolchain due to usage of the inline-const feature / update MSRV? #83

Closed
Nekomaru-PKU opened this issue Feb 5, 2025 · 6 comments · Fixed by #84

Comments

@Nekomaru-PKU
Copy link
Contributor

Issue Description

Starting from version 1.11.0, this crate fails to compile with older Rust toolchain. This issue can be reproduced simply by running the following script:

mkdir elsa-test
cd elsa-test
echo "nightly-2023-05-27" > rust-toolchain
cargo init
cargo add elsa
cargo c

Note that the toolchain version can be arbitrary before "nightly-2024-03-xx". A successful compilation is expected, while the actual output is:

    Checking stable_deref_trait v1.2.0
    Checking elsa v1.11.0
error[E0658]: inline-const is experimental
   --> C:\Users\Nekomaru\.cargo\registry\src\index.crates.io-6f17d22bba15001f\elsa-1.11.0\src\sync.rs:716:10
    |
716 |         [const { AtomicPtr::new(std::ptr::null_mut()) }; NUM_BUFFERS]
    |          ^^^^^
    |
    = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
    = help: add `#![feature(inline_const)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `elsa` (lib) due to previous error

The inline_const feature was stabilized and merged into master in PR rust-lang/rust#76001 in April 24th 2024, and shipped in stable rust in 1.79.0 (See https://releases.rs/docs/1.79.0/), so recent stable and nightly toolchains accept this syntax without complaining or requiring a feature gate. For toolchains before that, this issue occurs, making the 1.11.0 version a breaking change for projects depending on this crate while using an older rust toolchain.

This issue does not occur in elsa version 1.10.0 and before.

Suggested Solution

This issue can be handled simply by adding an MSRV requirement to this crate (version = "1.79.0" to Cargo.toml). I can raise a pull request for this change. Other alternatives might be removing all usage of the inline-const feature or bumping the major version, which is not recommended in any way.

@Nekomaru-PKU
Copy link
Contributor Author

Nekomaru-PKU commented Feb 5, 2025

For some extra information, this crate is depended by spirt, which is depended by rustc_codegen_spirv in Rust-GPU. The latest release of Rust-GPU (spirv-builder v0.9.0) requires rust toolchain "nightly-2023-05-27" to work properly as it depends on the internal IR of rustc, making it almost impossible for projects using Rust-GPU to upgrade their rust toolchain.

@Manishearth
Copy link
Owner

I'm pretty sure the version requirement can be relaxed by defining an explicit intermediate const, if you'd like to make that change and then also add an older MSRV. Otherwise I don't mind MSRV 1.79, but I think we could have one that is at least a year old if we try.

@Nekomaru-PKU
Copy link
Contributor Author

Sounds good. If the previous version of this crate have no problem with older rust toolchains, I think I can just fix it by introducing an intermediate constant without a MSRV constraint. Working on this.

Manishearth added a commit that referenced this issue Feb 5, 2025
Fix #83: Remove Usage of `inline-const` Feature
@Knyffen
Copy link

Knyffen commented Mar 8, 2025

@Manishearth I don't know the crates.io update process, but is it possible for you to push version 1.11.1 to crates.io? The version that fails to compile is still being pulled in as a dependency.

@Manishearth
Copy link
Owner

Done!

@Knyffen
Copy link

Knyffen commented Mar 9, 2025

Thank you!

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 a pull request may close this issue.

3 participants