Clap: Rust 2018 support

Created on 8 Aug 2018  路  8Comments  路  Source: clap-rs/clap

Hey all! I've been using the Rust 2018 preview in recent projects. It isn't out officially for another couple months, but soon it will supplant Rust 2015.

I've noticed at least one (minor) issue in testing using Clap in Rust 2018.

In Rust 2018, macro imports can be individually imported via use. However, importing the arg_enum macro seems to require another private macro.

use clap::arg_enum;

arg_enum!{
    #[derive(Debug)]
    pub enum ArgEnum {
        ThingA,
        ThingB
    }
}
error: cannot find macro `_clap_count_exprs!` in this scope
 --> src\enums.rs:3:1
  |
3 | / arg_enum!{
4 | |     #[derive(Debug)]
5 | |     pub enum ArgEnum {
6 | |         ThingA,
7 | |         ThingB
8 | |     }
9 | | }
  | |_^
  |
  = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

This can be worked around by additionally importing clap::_clap_count_exprs.

Rust Version

rustc 1.29.0-nightly (6a1c0637c 2018-07-23)

all needed Rust 2018 changes applied

Affected Version of clap

2.23.0

Most helpful comment

The same occurs when trying to use the app_from_crate-macro, which depends on a handful of others that aren't resolved properly at the moment (at least when using Rust 2018).

All 8 comments

The same occurs when trying to use the app_from_crate-macro, which depends on a handful of others that aren't resolved properly at the moment (at least when using Rust 2018).

Hm, I fear this is not easily fixable while still supporting Rust 1.21. One workaround I can see is using a build script that detects the Rust version and set a feature dependent on that.

@killercup: The minimum Rust version policy of this crate is to support $latest - 2 releases. Why is 1.21 in the scope of the conversation as opposed to Rust 1.29?

@ErichDonGubler oh, I just looked at the CI config, sorry! Then we should be good to go ahead with #1397. Sorry for the confusion!

@killercup: No problem! :) I wish I could just use something like a reminder bot here for Monday...

Just stumbled onto this, would appreciate a fix.

Pinging here for somebody to look at https://github.com/clap-rs/clap/pull/1397, please! I'm the author of that PR, and I'm more than happy to do whatever is necessary to get it over the line. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ruabmbua picture ruabmbua  路  17Comments

CAD97 picture CAD97  路  21Comments

XAMPPRocky picture XAMPPRocky  路  17Comments

casey picture casey  路  25Comments

kbknapp picture kbknapp  路  30Comments