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

fails to compile clap 2.33.3 -- 'if' is not allowed in a 'const fn' #2734

Closed
2 tasks done
jtmoon79 opened this issue Aug 22, 2021 · 2 comments
Closed
2 tasks done

fails to compile clap 2.33.3 -- 'if' is not allowed in a 'const fn' #2734

jtmoon79 opened this issue Aug 22, 2021 · 2 comments
Labels
C-bug Category: Updating dependencies

Comments

@jtmoon79
Copy link

jtmoon79 commented Aug 22, 2021

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

1.42.1

Specifically rustc version 1.41.1 and cargo version 1.42.1.

Clap Version

2.33.3

Minimal reproducible code

src/main.rs

// src/main.rs
fn main() {}

Cargo.toml

[package]
name = "cargo1"
version = "0.0.1"

[dependencies]
clap = "2.33.3"

Steps to reproduce the bug with the above code

cargo build

Actual Behaviour

$ cargo build
   Compiling clap v2.33.3
error[E0658]: `if` is not allowed in a `const fn`
  --> /home/user1/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.3/src/app/settings.rs:7:1
   |
7  | / bitflags! {
8  | |     struct Flags: u64 {
9  | |         const SC_NEGATE_REQS       = 1;
10 | |         const SC_REQUIRED          = 1 << 1;
...  |
51 | |     }
52 | | }
   | |_^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/49146
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0658]: `if` is not allowed in a `const fn`
  --> /home/user1/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.3/src/args/settings.rs:6:1
   |
6  | / bitflags! {
7  | |     struct Flags: u32 {
8  | |         const REQUIRED         = 1;
9  | |         const MULTIPLE         = 1 << 1;
...  |
28 | |     }
29 | | }
   | |_^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/49146
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `clap`.

Expected Behaviour

$ cargo build

   Compiling cargo1 v0.0.1 (/tmp/project1)
    Finished dev [unoptimized + debuginfo] target(s) in 2.34s

Additional Context

Run on Debian 9 Linux.

Debug Output

No difference in cargo build output.

@jtmoon79 jtmoon79 added the C-bug Category: Updating dependencies label Aug 22, 2021
@jtmoon79 jtmoon79 changed the title fails to compile clap 2.33.3 -- if is not allowed in a const fn fails to compile clap 2.33.3 -- 'if' is not allowed in a 'const fn' Aug 22, 2021
@jtmoon79 jtmoon79 changed the title fails to compile clap 2.33.3 -- 'if' is not allowed in a 'const fn' fails to build clap 2.33.3 -- 'if' is not allowed in a 'const fn' Aug 22, 2021
@jtmoon79 jtmoon79 changed the title fails to build clap 2.33.3 -- 'if' is not allowed in a 'const fn' fails to compile clap 2.33.3 -- 'if' is not allowed in a 'const fn' Aug 22, 2021
@jtmoon79
Copy link
Author

jtmoon79 commented Aug 22, 2021

The same minimal reproduction setup passes when using cargo version 1.51.0 and rustc version 1.51.0 on Ubuntu 20.04.

The versions reported 1.42.1 and 1.41.1 are the supported versions in Debian 9 which is supported by Debian until July 2022.

@epage
Copy link
Member

epage commented Aug 23, 2021

This is a duplicate of #2691. Users are subject to how the dependency resolver selects all crates and how that impacts MSRV. By default, it will pick the latest for everything, so with a new bitflags changing its MSRV, people are now picking that up. The flag -Z minimal-versions is an option to get around this but the challenge is not everyone tests with it, so people will have too-low of dependencies. The other option is to patch dependencies.

What clap shouldn't do is constrain the dependency for everyone for the sake of MSRV. That would be inaccurate and can lead to other problems like what happened to nom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies
Projects
None yet
Development

No branches or pull requests

3 participants