热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Fatalinternalerrorwhenargrequirementdoesn'texist

RustVersion


Rust Version


1
rustc 1.40.0 (73528e339 2019-12-16)

Affected Version of clap

Both

1
2.33.0

and

1
3.0.0-beta.1

(from git)

Expected Behavior Summary

Clap should complain (to the writer of the app - not the end user of the interface) that one of the arguments requires an

1
Arg

that does not exist - i.e. has not been added to the

1
App

.

Actual Behavior Summary

Fatal internal error.

Steps to Reproduce the issue

See sample code below.

Sample Code or Link to Sample Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
rust

fn main() {

    // The issue also persists when loading from yaml (where I originally found it)

    // the only difference is that if we don't give a name for the App, it doesn't

    // panic.

    let app = clap::App::new("clap-issue-1644")

        .arg(clap::Arg::with_name("foo")

                // It doesn't matter whether we use a short or long value here;

                // clap still crashes

                .long("foo")

                .requires("missing-arg"));



    app.get_matches();

}


Debug output

Debug Output (v2.33.0)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
DEBUG:clap:Parser::propagate_settings: self=clap-issue-1644, g_settings=AppFlags(

    (empty),

)

DEBUG:clap:Parser::get_matches_with;

DEBUG:clap:Parser::create_help_and_version;

DEBUG:clap:Parser::create_help_and_version: Building --help

DEBUG:clap:Parser::create_help_and_version: Building --version

DEBUG:clap:Parser::get_matches_with: Begin parsing '"--foo"' ([45, 45, 102, 111, 111])

DEBUG:clap:Parser::is_new_arg:"--foo":NotFound

DEBUG:clap:Parser::is_new_arg: arg_allows_tac=false

DEBUG:clap:Parser::is_new_arg: -- found

DEBUG:clap:Parser::is_new_arg: starts_new_arg=true

DEBUG:clap:Parser::possible_subcommand: arg="--foo"

DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=None

DEBUG:clap:ArgMatcher::process_arg_overrides:None;

DEBUG:clap:Parser::parse_long_arg;

DEBUG:clap:Parser::parse_long_arg: Does it contain '='...No

DEBUG:clap:Parser::parse_long_arg: Found valid flag '--foo'

DEBUG:clap:Parser::check_for_help_and_version_str;

DEBUG:clap:Parser::check_for_help_and_version_str: Checking if --foo is help or version...Neither

DEBUG:clap:Parser::parse_flag;

DEBUG:clap:ArgMatcher::inc_occurrence_of: arg=foo

DEBUG:clap:ArgMatcher::inc_occurrence_of: first instance

DEBUG:clap:Parser::groups_for_arg: name=foo

DEBUG:clap:Parser::groups_for_arg: No groups defined

DEBUG:clap:Parser:get_matches_with: After parse_long_arg Flag

DEBUG:clap:ArgMatcher::process_arg_overrides:Some("foo");

DEBUG:clap:Parser::remove_overrides:[];

DEBUG:clap:Validator::validate;

DEBUG:clap:Parser::add_defaults;

DEBUG:clap:Validator::validate_blacklist;

DEBUG:clap:Validator::validate_blacklist:iter:foo;

DEBUG:clap:Parser::groups_for_arg: name=foo

DEBUG:clap:Parser::groups_for_arg: No groups defined

DEBUG:clap:Validator::validate_required: required=[];

DEBUG:clap:Validator::validate_matched_args;

DEBUG:clap:Validator::validate_matched_args:iter:foo: vals=[]

DEBUG:clap:Validator::validate_arg_requires:foo;

DEBUG:clap:Validator::missing_required_error: extra=Some("mising-arg")

DEBUG:clap:Parser::color;

DEBUG:clap:Parser::color: Color setting...Auto

DEBUG:clap:is_a_tty: stderr=true

DEBUG:clap:Validator::missing_required_error: reqs=[

    "mising-arg",

]

DEBUG:clap:usage::get_required_usage_from: reqs=["mising-arg"], extra=Some("mising-arg")

DEBUG:clap:usage::get_required_usage_from: after init desc_reqs=["mising-arg"]

DEBUG:clap:usage::get_required_usage_from: no more children

DEBUG:clap:usage::get_required_usage_from: final desc_reqs=["mising-arg"]

DEBUG:clap:usage::get_required_usage_from: args_in_groups=[]

DEBUG:clap:usage::get_required_usage_from:iter:mising-arg:

thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/clap-rs/clap/issues', src/libcore/option.rs:1185:5

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Debug Output (v3.0.0-beta.1)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
DEBUG:clap:App::_do_parse;

DEBUG:clap:App::_build;

DEBUG:clap:App::_derive_display_order:clap-issue-1644

DEBUG:clap:App::_create_help_and_version;

DEBUG:clap:App::_create_help_and_version: Building --help

DEBUG:clap:App::_create_help_and_version: Building --version

DEBUG:clap:App::_arg_debug_asserts:foo

DEBUG:clap:App::_arg_debug_asserts:help

DEBUG:clap:App::_arg_debug_asserts:version

DEBUG:clap:App::_app_debug_asserts;

DEBUG:clap:Parser::get_matches_with;

DEBUG:clap:Parser::_build;

DEBUG:clap:Parser::_verify_positionals;

DEBUG:clap:Parser::get_matches_with: Begin parsing '"--foo"' ([45, 45, 102, 111, 111])

DEBUG:clap:Parser::is_new_arg:"--foo":NotFound

DEBUG:clap:Parser::is_new_arg: arg_allows_tac=false

DEBUG:clap:Parser::is_new_arg: -- found

DEBUG:clap:Parser::is_new_arg: starts_new_arg=true

DEBUG:clap:Parser::possible_subcommand: arg="--foo"

DEBUG:clap:Parser::get_matches_with: possible_sc=false, sc=None

DEBUG:clap:Parser::parse_long_arg;

DEBUG:clap:Parser::parse_long_arg: Does it contain '='...No

DEBUG:clap:Parser::parse_long_arg: Found valid opt or flag '--foo'

DEBUG:clap:Parser::check_for_help_and_version_str;

DEBUG:clap:Parser::check_for_help_and_version_str: Checking if --foo is help or version...Neither

DEBUG:clap:Parser::parse_flag;

DEBUG:clap:ArgMatcher::inc_occurrence_of: arg=4741034841092048056

DEBUG:clap:ArgMatcher::inc_occurrence_of: first instance

DEBUG:clap:Parser::groups_for_arg: name=4741034841092048056

DEBUG:clap:Parser:get_matches_with: After parse_long_arg Flag

DEBUG:clap:Parser::remove_overrides;

DEBUG:clap:Parser::remove_overrides:iter:4741034841092048056;

DEBUG:clap:Validator::validate;

DEBUG:clap:Parser::add_defaults;

DEBUG:clap:Validator::validate_conflicts;

DEBUG:clap:Validator::validate_conflicts_with_everything;

DEBUG:clap:Validator::validate_conflicts_with_everything:iter:4741034841092048056;

DEBUG:clap:Validator::gather_conflicts;

DEBUG:clap:Validator::gather_conflicts:iter:4741034841092048056;

DEBUG:clap:Parser::groups_for_arg: name=4741034841092048056

DEBUG:clap:Validator::validate_required: required=ChildGraph([]);

DEBUG:clap:Validator::gather_requirements;

DEBUG:clap:Validator::gather_requirements:iter:4741034841092048056;

DEBUG:clap:Validator::validate_required:iter:aog=18152889946298061510;

DEBUG:clap:Validator::validate_required_unless;

DEBUG:clap:Validator::validate_matched_args;

DEBUG:clap:Validator::validate_matched_args:iter:4741034841092048056: vals=[]

DEBUG:clap:Validator::validate_arg_num_vals;

DEBUG:clap:Validator::validate_arg_values: arg="foo"

DEBUG:clap:Validator::validate_arg_requires:foo;

DEBUG:clap:Validator::missing_required_error; incl=Some(18152889946298061510)

DEBUG:clap:App::color;

DEBUG:clap:App::color: Color setting...Auto

DEBUG:clap:is_a_tty: stderr=true

DEBUG:clap:Validator::missing_required_error: reqs=ChildGraph([Child { id: 18152889946298061510, children: None }])

DEBUG:clap:Usage::get_required_usage_from: incls=[18152889946298061510], matcher=true, incl_last=true

DEBUG:clap:Usage::get_required_usage_from:iter:18152889946298061510:

thread 'main' panicked at 'Fatal internal error. Please consider filing a bug report at https://github.com/kbknapp/clap-rs/issues', src/libcore/option.rs:1185:5

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

该提问来源于开源项目:clap-rs/clap

Right





   



推荐阅读
author-avatar
zf19920222
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有