diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 145db0ce0f3..eef3a4390c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.46.0, stable, beta] + rust: [1.54.0, stable, beta] os: [windows-latest, macos-latest, ubuntu-latest] target: - i686-pc-windows-msvc @@ -103,7 +103,8 @@ jobs: if: matrix.features == 'all' with: command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex" + # Test `doc` to run doctests on the README + args: --target ${{ matrix.target }} --features "wrap_help yaml regex doc" - name: Check debug uses: actions-rs/cargo@v1 if: matrix.features == 'all' @@ -169,7 +170,7 @@ jobs: - name: Install rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.46.0 + toolchain: 1.54.0 target: ${{ matrix.target }} override: true - name: Checkout diff --git a/README.md b/README.md index 37fbe8b2bfd..100bef9e6a1 100644 --- a/README.md +++ b/README.md @@ -555,7 +555,7 @@ The following is a list of the minimum required version of Rust to compile `clap | clap | MSRV | | :----: | :----: | -| >=3.0 | 1.46.0 | +| >=3.0 | 1.54.0 | | >=2.21 | 1.24.0 | | >=2.2 | 1.12.0 | | >=2.1 | 1.6.0 | @@ -585,4 +585,4 @@ There are several excellent crates which can be used with `clap`, I recommend ch * [`assert_cmd`](https://github.com/assert-rs/assert_cmd) - This crate allows you test your CLIs in a very intuitive and functional way! [docs]: https://docs.rs/clap -[examples]: examples +[examples]: https://github.com/clap-rs/clap/tree/master/examples diff --git a/clap_derive/Cargo.toml b/clap_derive/Cargo.toml index 65fa16e4f00..a29a7af8f85 100644 --- a/clap_derive/Cargo.toml +++ b/clap_derive/Cargo.toml @@ -31,9 +31,9 @@ proc-macro = true bench = false [dependencies] -syn = { version = "1.0.69", features = ["full"] } +syn = { version = "1.0.74", features = ["full"] } quote = "1.0.9" -proc-macro2 = "1.0.26" +proc-macro2 = "1.0.28" heck = "0.3.0" proc-macro-error = "1" diff --git a/clap_derive/src/dummies.rs b/clap_derive/src/dummies.rs index 72e8ab4bed2..433fff3f16e 100644 --- a/clap_derive/src/dummies.rs +++ b/clap_derive/src/dummies.rs @@ -52,6 +52,9 @@ pub fn subcommand(name: &Ident) { fn augment_subcommands_for_update(_app: clap::App<'_>) -> clap::App<'_> { unimplemented!() } + fn has_subcommand(name: &str) -> bool { + unimplemented!() + } } }); } @@ -77,6 +80,9 @@ pub fn arg_enum(name: &Ident) { fn from_str(_input: &str, _case_insensitive: bool) -> Result { unimplemented!() } + fn as_arg(&self) -> Option<&'static str> { + unimplemented!() + } } }) } diff --git a/clap_derive/tests/ui.rs b/clap_derive/tests/ui.rs index 34be737263e..d96746e53df 100644 --- a/clap_derive/tests/ui.rs +++ b/clap_derive/tests/ui.rs @@ -5,7 +5,7 @@ // , at your // option. This file may not be copied, modified, or distributed -#[rustversion::attr(any(not(stable), before(1.45), since(1.46)), ignore)] +#[rustversion::attr(any(not(stable), before(1.54), since(1.55)), ignore)] #[test] fn ui() { let t = trybuild::TestCases::new(); diff --git a/clap_derive/tests/ui/arg_enum_on_struct.stderr b/clap_derive/tests/ui/arg_enum_on_struct.stderr index b64ac779e0e..d83386a4118 100644 --- a/clap_derive/tests/ui/arg_enum_on_struct.stderr +++ b/clap_derive/tests/ui/arg_enum_on_struct.stderr @@ -4,4 +4,4 @@ error: `#[derive(ArgEnum)]` only supports enums 3 | #[derive(ArgEnum, Debug)] | ^^^^^^^ | - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `ArgEnum` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/clap_derive/tests/ui/enum_variant_not_args.stderr b/clap_derive/tests/ui/enum_variant_not_args.stderr index f1a9b207a44..5a874413b08 100644 --- a/clap_derive/tests/ui/enum_variant_not_args.stderr +++ b/clap_derive/tests/ui/enum_variant_not_args.stderr @@ -5,3 +5,11 @@ error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied | ^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` | = note: required by `augment_args` + +error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied + --> $DIR/enum_variant_not_args.rs:3:9 + | +3 | Sub(SubCmd), + | ^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` + | + = note: required by `augment_args_for_update` diff --git a/clap_derive/tests/ui/non_existent_attr.stderr b/clap_derive/tests/ui/non_existent_attr.stderr index 0887310693e..e6d308f7786 100644 --- a/clap_derive/tests/ui/non_existent_attr.stderr +++ b/clap_derive/tests/ui/non_existent_attr.stderr @@ -1,5 +1,5 @@ -error[E0599]: no method named `non_existing_attribute` found for struct `clap::Arg<'_>` in the current scope +error[E0599]: no method named `non_existing_attribute` found for struct `Arg` in the current scope --> $DIR/non_existent_attr.rs:14:19 | 14 | #[clap(short, non_existing_attribute = 1)] - | ^^^^^^^^^^^^^^^^^^^^^^ method not found in `clap::Arg<'_>` + | ^^^^^^^^^^^^^^^^^^^^^^ method not found in `Arg<'_>` diff --git a/clap_derive/tests/ui/skip_without_default.stderr b/clap_derive/tests/ui/skip_without_default.stderr index 85545e56086..747f3d27658 100644 --- a/clap_derive/tests/ui/skip_without_default.stderr +++ b/clap_derive/tests/ui/skip_without_default.stderr @@ -1,9 +1,7 @@ -error[E0277]: the trait bound `Kind: std::default::Default` is not satisfied +error[E0277]: the trait bound `Kind: Default` is not satisfied --> $DIR/skip_without_default.rs:22:12 | 22 | #[clap(skip)] - | ^^^^ the trait `std::default::Default` is not implemented for `Kind` + | ^^^^ the trait `Default` is not implemented for `Kind` | = note: required by `std::default::Default::default` - -For more information about this error, try `rustc --explain E0277`. diff --git a/clap_derive/tests/ui/subcommand_on_struct.stderr b/clap_derive/tests/ui/subcommand_on_struct.stderr index 14b03d895db..afef79fd1b1 100644 --- a/clap_derive/tests/ui/subcommand_on_struct.stderr +++ b/clap_derive/tests/ui/subcommand_on_struct.stderr @@ -4,4 +4,4 @@ error: `#[derive(Subcommand)]` only supports enums 3 | #[derive(Subcommand, Debug)] | ^^^^^^^^^^ | - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Subcommand` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/clap_derive/tests/ui/tuple_struct.stderr b/clap_derive/tests/ui/tuple_struct.stderr index 6adcce183ec..a4f1b7572ff 100644 --- a/clap_derive/tests/ui/tuple_struct.stderr +++ b/clap_derive/tests/ui/tuple_struct.stderr @@ -4,7 +4,7 @@ error: `#[derive(Clap)]` only supports non-tuple structs and enums 11 | #[derive(Clap, Debug)] | ^^^^ | - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `Clap` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `parse` found for struct `Opt` in the current scope --> $DIR/tuple_struct.rs:16:20 @@ -17,4 +17,4 @@ error[E0599]: no function or associated item named `parse` found for struct `Opt | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `parse`, perhaps you need to implement it: - candidate #1: `clap::Clap` + candidate #1: `Clap` diff --git a/src/build/app/mod.rs b/src/build/app/mod.rs index 525a36d5e22..72da3242e92 100644 --- a/src/build/app/mod.rs +++ b/src/build/app/mod.rs @@ -2703,6 +2703,7 @@ impl<'help> App<'help> { where 'help: 'a, { + #![allow(clippy::needless_collect)] let a: Vec<_> = self .get_subcommands() .flat_map(|sc| { diff --git a/src/lib.rs b/src/lib.rs index 03c3e517a83..29f8d95bbf4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,10 +3,9 @@ // (see LICENSE or ) All files in the project carrying such // notice may not be copied, modified, or distributed except according to those terms. -#![cfg_attr(feature = "doc", feature(external_doc))] #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] #![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.2")] -#![cfg_attr(feature = "doc", doc(include = "../README.md"))] +#![cfg_attr(feature = "doc", doc = include_str!("../README.md"))] //! #![crate_type = "lib"] #![deny(