@@ -52,13 +52,13 @@ fn try_help(config: &Config) -> CargoResult<bool> {
52
52
None => return Ok ( false ) ,
53
53
} ;
54
54
if resolve_executable ( Path :: new ( "man" ) ) . is_ok ( ) {
55
- let man = match extract_man ( & subcommand, "1" ) ? {
55
+ let man = match extract_man ( & subcommand, "1" ) {
56
56
Some ( man) => man,
57
57
None => return Ok ( false ) ,
58
58
} ;
59
59
write_and_spawn ( & man, "man" ) ?;
60
60
} else {
61
- let txt = match extract_man ( & subcommand, "txt" ) ? {
61
+ let txt = match extract_man ( & subcommand, "txt" ) {
62
62
Some ( txt) => txt,
63
63
None => return Ok ( false ) ,
64
64
} ;
@@ -96,10 +96,12 @@ fn check_alias(config: &Config, subcommand: &str) -> Option<String> {
96
96
/// Extracts the given man page from the compressed archive.
97
97
///
98
98
/// Returns None if the command wasn't found.
99
- fn extract_man ( subcommand : & str , extension : & str ) -> CargoResult < Option < Vec < u8 > > > {
99
+ fn extract_man ( subcommand : & str , extension : & str ) -> Option < Vec < u8 > > {
100
100
let extract_name = OsString :: from ( format ! ( "cargo-{}.{}" , subcommand, extension) ) ;
101
101
let gz = GzDecoder :: new ( COMPRESSED_MAN ) ;
102
102
let mut ar = tar:: Archive :: new ( gz) ;
103
+ // Unwraps should be safe here, since this is a static archive generated
104
+ // by our build script. It should never be an invalid format!
103
105
for entry in ar. entries ( ) . unwrap ( ) {
104
106
let mut entry = entry. unwrap ( ) ;
105
107
let path = entry. path ( ) . unwrap ( ) ;
@@ -108,9 +110,9 @@ fn extract_man(subcommand: &str, extension: &str) -> CargoResult<Option<Vec<u8>>
108
110
}
109
111
let mut result = Vec :: new ( ) ;
110
112
entry. read_to_end ( & mut result) . unwrap ( ) ;
111
- return Ok ( Some ( result) ) ;
113
+ return Some ( result) ;
112
114
}
113
- Ok ( None )
115
+ None
114
116
}
115
117
116
118
/// Write the contents of a man page to disk and spawn the given command to
0 commit comments