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

build errors: trait bounds other than Sized on const fn parameters are unstable #336

Open
IronThread opened this issue Apr 7, 2022 · 7 comments

Comments

@IronThread
Copy link

IronThread commented Apr 7, 2022

I tried to compile lock_api and I got these errors:

   Compiling lock_api v0.4.7
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
   --> C:\Users\Santino\.cargo\registry\src\github.com-1285ae84e5963aae\lock_api-0.4.7\src\mutex.rs:150:6
    |
150 | impl<R: RawMutex, T> Mutex<R, T> {
    |      ^
...
154 |     pub const fn new(val: T) -> Mutex<R, T> {
    |     --------------------------------------- function declared as const here
    |
    = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information
    = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable

error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
   --> C:\Users\Santino\.cargo\registry\src\github.com-1285ae84e5963aae\lock_api-0.4.7\src\remutex.rs:231:6
    |
231 | impl<R: RawMutex, G: GetThreadId, T> ReentrantMutex<R, G, T> {
    |      ^
...
235 |     pub const fn new(val: T) -> ReentrantMutex<R, G, T> {
    |     --------------------------------------------------- function declared as const here
    |
    = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information
    = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable

error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
   --> C:\Users\Santino\.cargo\registry\src\github.com-1285ae84e5963aae\lock_api-0.4.7\src\remutex.rs:231:19
    |
231 | impl<R: RawMutex, G: GetThreadId, T> ReentrantMutex<R, G, T> {
    |                   ^
...
235 |     pub const fn new(val: T) -> ReentrantMutex<R, G, T> {
    |     --------------------------------------------------- function declared as const here
    |
    = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information
    = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable

error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
   --> C:\Users\Santino\.cargo\registry\src\github.com-1285ae84e5963aae\lock_api-0.4.7\src\rwlock.rs:367:6
    |
367 | impl<R: RawRwLock, T> RwLock<R, T> {
    |      ^
...
371 |     pub const fn new(val: T) -> RwLock<R, T> {
    |     ---------------------------------------- function declared as const here
    |
    = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information
    = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `lock_api` due to 4 previous errors

rustc --version --verbose:

rustc 1.61.0-nightly (68369a041 2022-02-22)
binary: rustc
commit-hash: 68369a041cea809a87e5bd80701da90e0e0a4799
commit-date: 2022-02-22
host: i686-pc-windows-msvc
release: 1.61.0-nightly
LLVM version: 14.0.0
@Amanieu
Copy link
Owner

Amanieu commented Apr 7, 2022

Update to the latest nightly.

@aminya
Copy link

aminya commented Apr 26, 2022

This is a breaking change. You should not release a patch version for such changes.

This version requires a very recent version of the nightly that doesn't build many other packages. Some core Rust packages such as racer, rls, rustfmt fail to build with the latest nightly, while this package requires it!
https://github.com/racer-rust/racer/blob/a457c235b545c5251570cda8fec1edeab05ab1d4/src/racer/ast.rs#L25

@bjorn3
Copy link
Contributor

bjorn3 commented Apr 26, 2022

Racer doesn't depend on parking_lot at all.

@aminya
Copy link

aminya commented Apr 26, 2022

Yes, but rls depends on both Lock_api and racer. Lock_api requires the latest nightly and the others do not build with the latest.

https://github.com/rust-lang/rls/blob/d8478d82f59e17c2846e9935025e557c1693dd5a/Cargo.lock#L1183
https://github.com/rust-lang/rls/blob/d8478d82f59e17c2846e9935025e557c1693dd5a/Cargo.lock#L1530

@Amanieu
Copy link
Owner

Amanieu commented Apr 26, 2022

I don't think it is reasonable for parking_lot to support older nightly versions. The whole point of nightly is that it is unstable and you are responsible for keeping up with changes. If you really need it then you can use a nightly with a version number of 1.60, which will fail the check in build.rs.

@synek317
Copy link

synek317 commented May 5, 2022

I'm not sure if I understand this correctly.

I thought that parking_lot and lock_api would work on any nightly version greater than msvr unless I explicitly enable nightly feature. Once it is enabled, I can agree that I'm then responsible for updating to the appropriate nightly (though, still, it would be nicer to support some older nightlies).

But I ran into this issue having just

lock_api = "0.4.7"

in my cargo lock and running cargo build using rust 1.61.0-nightly (45e2c2881 2022-02-20) (which I cannot upgrade, unfortunately).

Do you think it could be fixed somehow?

@Amanieu
Copy link
Owner

Amanieu commented May 7, 2022

I supposed the build.rs check could be changed to disable the flag for 1.61 on the nightly channel, and only enable it for 1.61 stable/beta. I'd be happy to accept a PR for that.

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

No branches or pull requests

5 participants