@@ -90,7 +90,7 @@ pub trait Conf: Sized {
9090 #[ doc( hidden) ]
9191 fn get_parser ( parsed_env : & ParsedEnv ) -> Result < Parser < ' _ > , Error > {
9292 let parser_config = Self :: get_parser_config ( ) ?;
93- let program_options = Self :: get_program_options ( ) ? ;
93+ let program_options = Self :: get_program_options ( ) ;
9494 let subcommands = Self :: get_subcommands ( parsed_env) ?;
9595 Parser :: new ( parser_config, program_options, subcommands, parsed_env)
9696 }
@@ -108,7 +108,7 @@ pub trait Conf: Sized {
108108 // Users shouldn't generally call this, because the returned data is implementation details,
109109 // and may change without a semver breaking change to the crate version.
110110 #[ doc( hidden) ]
111- fn get_program_options ( ) -> Result < & ' static [ ProgramOption ] , Error > ;
111+ fn get_program_options ( ) -> & ' static [ ProgramOption ] ;
112112 // Get the subcommands that are declared on this Conf.
113113 //
114114 // These come from `conf(subcommand)` being used on a field, and `derive(Subcommand)` being used
@@ -135,16 +135,7 @@ pub trait Conf: Sized {
135135 fn any_program_options_appeared < ' a > (
136136 conf_context : & ConfContext < ' a > ,
137137 ) -> Result < Option < ( & ' a str , ConfValueSource < & ' a str > ) > , InnerError > {
138- // This unwrap is unfortunate but this code is only called when an earlier call to
139- // Self::get_program_options has succeeded, since we have to call that to
140- // instantiate the parser, and we have to do that before getting a ConfContext.
141- // The only place in the library where a `ConfContext` is created where one doesn't already
142- // exist is in `try_parse_from`, and the ConfContext::new function is pub(crate).
143- // And we have to call get_program_options before that point, which calls it
144- // recursively on all the constituent structures.
145- // So I don't think this unwrap will panic unless get_program_options is implemented in a
146- // non-deterministic way, which it shouldn't be.
147- let program_options = Self :: get_program_options ( ) . unwrap ( ) ;
138+ let program_options = Self :: get_program_options ( ) ;
148139 for opt in program_options {
149140 if let Some ( value_source) = conf_context. option_appears ( & opt. id ) ? {
150141 return Ok ( Some ( ( & opt. id , value_source) ) ) ;
0 commit comments