File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -52,13 +52,16 @@ fn execute() -> i32 {
52
52
opts. optflag ( "" , "all" , "format all packages (only usable in workspaces)" ) ;
53
53
54
54
// If there is any invalid argument passed to `cargo fmt`, return without formatting.
55
- if let Some ( arg) = env:: args ( )
56
- . skip ( 2 )
57
- . take_while ( |a| a != "--" )
58
- . find ( |a| !a. starts_with ( '-' ) )
59
- {
60
- print_usage_to_stderr ( & opts, & format ! ( "Invalid argument: `{}`." , arg) ) ;
61
- return failure;
55
+ let mut is_package_arg = false ;
56
+ for arg in env:: args ( ) . skip ( 2 ) . take_while ( |a| a != "--" ) {
57
+ if arg. starts_with ( "-" ) {
58
+ is_package_arg = arg. starts_with ( "--package" ) ;
59
+ } else if !is_package_arg {
60
+ print_usage_to_stderr ( & opts, & format ! ( "Invalid argument: `{}`." , arg) ) ;
61
+ return failure;
62
+ } else {
63
+ is_package_arg = false ;
64
+ }
62
65
}
63
66
64
67
let matches = match opts. parse ( env:: args ( ) . skip ( 1 ) . take_while ( |a| a != "--" ) ) {
You can’t perform that action at this time.
0 commit comments