File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -240,21 +240,21 @@ pub struct LinkSelfContained {
240
240
impl LinkSelfContained {
241
241
/// Incorporates an enabled or disabled component as specified on the CLI, if possible.
242
242
/// For example: `+linker`, and `-crto`.
243
- pub ( crate ) fn handle_cli_component ( & mut self , component : & str ) -> Result < ( ) , ( ) > {
243
+ pub ( crate ) fn handle_cli_component ( & mut self , component : & str ) -> Option < ( ) > {
244
244
// Note that for example `-Cself-contained=y -Cself-contained=-linker` is not an explicit
245
245
// set of all values like `y` or `n` used to be. Therefore, if this flag had previously been
246
246
// set in bulk with its historical values, then manually setting a component clears that
247
247
// `explicitly_set` state.
248
248
if let Some ( component_to_enable) = component. strip_prefix ( '+' ) {
249
249
self . explicitly_set = None ;
250
- self . components . insert ( component_to_enable . parse ( ) ?) ;
251
- Ok ( ( ) )
250
+ self . components . insert ( LinkSelfContainedComponents :: from_str ( component_to_enable ) ?) ;
251
+ Some ( ( ) )
252
252
} else if let Some ( component_to_disable) = component. strip_prefix ( '-' ) {
253
253
self . explicitly_set = None ;
254
- self . components . remove ( component_to_disable . parse ( ) ?) ;
255
- Ok ( ( ) )
254
+ self . components . remove ( LinkSelfContainedComponents :: from_str ( component_to_disable ) ?) ;
255
+ Some ( ( ) )
256
256
} else {
257
- Err ( ( ) )
257
+ None
258
258
}
259
259
}
260
260
Original file line number Diff line number Diff line change @@ -1160,7 +1160,7 @@ mod parse {
1160
1160
1161
1161
// 2. Parse a list of enabled and disabled components.
1162
1162
for comp in s. split ( ',' ) {
1163
- if slot. handle_cli_component ( comp) . is_err ( ) {
1163
+ if slot. handle_cli_component ( comp) . is_none ( ) {
1164
1164
return false ;
1165
1165
}
1166
1166
}
Original file line number Diff line number Diff line change @@ -550,18 +550,17 @@ bitflags::bitflags! {
550
550
}
551
551
}
552
552
553
- impl FromStr for LinkSelfContainedComponents {
554
- type Err = ( ) ;
555
-
556
- fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
557
- Ok ( match s {
553
+ impl LinkSelfContainedComponents {
554
+ /// Parses a single `-Clink-self-contained` well-known component, not a set of flags.
555
+ pub fn from_str ( s : & str ) -> Option < LinkSelfContainedComponents > {
556
+ Some ( match s {
558
557
"crto" => LinkSelfContainedComponents :: CRT_OBJECTS ,
559
558
"libc" => LinkSelfContainedComponents :: LIBC ,
560
559
"unwind" => LinkSelfContainedComponents :: UNWIND ,
561
560
"linker" => LinkSelfContainedComponents :: LINKER ,
562
561
"sanitizers" => LinkSelfContainedComponents :: SANITIZERS ,
563
562
"mingw" => LinkSelfContainedComponents :: MINGW ,
564
- _ => return Err ( ( ) ) ,
563
+ _ => return None ,
565
564
} )
566
565
}
567
566
}
You can’t perform that action at this time.
0 commit comments