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

clap_complete v4 panics in debug mode when generating #4272

Closed
2 tasks done
alexheretic opened this issue Sep 28, 2022 · 2 comments · Fixed by #4277
Closed
2 tasks done

clap_complete v4 panics in debug mode when generating #4272

alexheretic opened this issue Sep 28, 2022 · 2 comments · Fixed by #4277
Labels
C-bug Category: Updating dependencies

Comments

@alexheretic
Copy link

alexheretic commented Sep 28, 2022

Please complete the following tasks

Rust Version

rustc 1.64.0 (a55dd71d5 2022-09-19)

Clap Version

4.0.0

Minimal reproducible code

completion-derive example: https://github.com/clap-rs/clap/blob/master/clap_complete/examples/completion-derive.rs

Steps to reproduce the bug with the above code

cargo run --example completion-derive -- --generate=bash

Actual Behaviour

$ RUST_BACKTRACE=1 cargo run --example completion-derive -- --generate=bash
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `/home/alex/.cargo/target/debug/examples/completion-derive --generate=bash`
thread 'main' panicked at 'Command value_hints_derive: Short option names must be unique for each argument, but '-h' is in use by both 'host' and 'help' (call `cmd.disable_help_flag(true)` to remove the auto-generated `--help`)', src/builder/debug_asserts.rs:121:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: clap::builder::debug_asserts::assert_app
             at /home/alex/project/clap/src/builder/debug_asserts.rs:121:17
   3: clap::builder::command::Command::_build_self
             at /home/alex/project/clap/src/builder/command.rs:3898:13
   4: clap::builder::command::Command::_do_parse
             at /home/alex/project/clap/src/builder/command.rs:3768:9
   5: clap::builder::command::Command::try_get_matches_from_mut
             at /home/alex/project/clap/src/builder/command.rs:708:9
   6: clap::builder::command::Command::get_matches_from
             at /home/alex/project/clap/src/builder/command.rs:578:9
   7: clap::builder::command::Command::get_matches
             at /home/alex/project/clap/src/builder/command.rs:490:9
   8: clap::derive::Parser::parse
             at /home/alex/project/clap/src/derive.rs:82:27
   9: completion_derive::main
             at ./examples/completion-derive.rs:62:15
  10: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5

Expected Behaviour

It should not panic.

No panics in release mode and the output seems to be correct too.

Additional Context

No response

Debug Output

[      clap::builder::command]  Command::_do_parse
[      clap::builder::command]  Command::_build: name="value_hints_derive"
[      clap::builder::command]  Command::_propagate:value_hints_derive
[      clap::builder::command]  Command::_check_help_and_version:value_hints_derive expand_help_tree=false
[      clap::builder::command]  Command::long_help_exists
[      clap::builder::command]  Command::_check_help_and_version: Building default --help
[      clap::builder::command]  Command::_propagate_global_args:value_hints_derive
[clap::builder::debug_asserts]  Command::_debug_asserts
[clap::builder::debug_asserts]  Arg::_debug_asserts:generator
[clap::builder::debug_asserts]  Arg::_debug_asserts:unknown
[clap::builder::debug_asserts]  Arg::_debug_asserts:other
[clap::builder::debug_asserts]  Arg::_debug_asserts:path
[clap::builder::debug_asserts]  Arg::_debug_asserts:file
[clap::builder::debug_asserts]  Arg::_debug_asserts:dir
[clap::builder::debug_asserts]  Arg::_debug_asserts:exe
[clap::builder::debug_asserts]  Arg::_debug_asserts:cmd_name
[clap::builder::debug_asserts]  Arg::_debug_asserts:cmd
[clap::builder::debug_asserts]  Arg::_debug_asserts:command_with_args
[clap::builder::debug_asserts]  Arg::_debug_asserts:user
[clap::builder::debug_asserts]  Arg::_debug_asserts:host
thread 'main' panicked at 'Command value_hints_derive: Short option names must be unique for each argument, but '-h' is in use by both 'host' and 'help' (call `cmd.disable_help_flag(true)` to remove the auto-generated `--help`)', src/builder/debug_asserts.rs:121:17
@alexheretic alexheretic added the C-bug Category: Updating dependencies label Sep 28, 2022
epage added a commit to epage/clap that referenced this issue Sep 28, 2022
@alexheretic
Copy link
Author

Changing the example doesn't fix the, i thought similar, regression affecting alexheretic/ab-av1#52 though.

Shall i raise another issue?

@epage
Copy link
Member

epage commented Sep 28, 2022

The panic is expected behavior; I just missed updating the example due to limited testing of it.

While its covered in the changelog, I go into more background on my announcement

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

Successfully merging a pull request may close this issue.

2 participants