热门标签 | 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





   



推荐阅读
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • Commit1ced2a7433ea8937a1b260ea65d708f32ca7c95eintroduceda+Clonetraitboundtom ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • Ihaveaworkfolderdirectory.我有一个工作文件夹目录。holderDir.glob(*)>holder[ProjectOne, ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 标题: ... [详细]
  • 闭包一直是Java社区中争论不断的话题,很多语言都支持闭包这个语言特性,闭包定义了一个依赖于外部环境的自由变量的函数,这个函数能够访问外部环境的变量。本文以JavaScript的一个闭包为例,介绍了闭包的定义和特性。 ... [详细]
  • 本文介绍了在处理不规则数据时如何使用Python自动提取文本中的时间日期,包括使用dateutil.parser模块统一日期字符串格式和使用datefinder模块提取日期。同时,还介绍了一段使用正则表达式的代码,可以支持中文日期和一些特殊的时间识别,例如'2012年12月12日'、'3小时前'、'在2012/12/13哈哈'等。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • 本文详细介绍了git常用命令及其操作方法,包括查看、添加、提交、删除、找回等操作,以及如何重置修改文件、抛弃工作区修改、将工作文件提交到本地暂存区、从版本库中删除文件等。同时还介绍了如何从暂存区恢复到工作文件、恢复最近一次提交过的状态,以及如何合并多个操作等。 ... [详细]
  • 本文整理了315道Python基础题目及答案,帮助读者检验学习成果。文章介绍了学习Python的途径、Python与其他编程语言的对比、解释型和编译型编程语言的简述、Python解释器的种类和特点、位和字节的关系、以及至少5个PEP8规范。对于想要检验自己学习成果的读者,这些题目将是一个不错的选择。请注意,答案在视频中,本文不提供答案。 ... [详细]
  • 本文详细介绍了使用C#实现Word模版打印的方案。包括添加COM引用、新建Word操作类、开启Word进程、加载模版文件等步骤。通过该方案可以实现C#对Word文档的打印功能。 ... [详细]
  • 带添加按钮的GridView,item的删除事件
    先上图片效果;gridView无数据时显示添加按钮,有数据时,第一格显示添加按钮,后面显示数据:布局文件:addr_manage.xml<?xmlve ... [详细]
  • 本文介绍了如何在Jquery中通过元素的样式值获取元素,并将其赋值给一个变量。提供了5种解决方案供参考。 ... [详细]
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社区 版权所有