File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,22 @@ fn main() {
40
40
"cargo"
41
41
} ;
42
42
43
- let args: Vec < _ > = match env:: args ( ) . nth ( 1 ) . as_deref ( ) {
43
+ let mut args = env:: args ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
44
+ if args. get ( 0 ) . map ( |arg| & * * arg) == Some ( "clif" ) {
45
+ // Avoid infinite recursion when invoking `cargo-clif` as cargo subcommand using
46
+ // `cargo clif`.
47
+ args. remove ( 0 ) ;
48
+ }
49
+
50
+ let args: Vec < _ > = match args. get ( 0 ) . map ( |arg| & * * arg) {
44
51
Some ( "jit" ) => {
45
52
env:: set_var (
46
53
"RUSTFLAGS" ,
47
54
env:: var ( "RUSTFLAGS" ) . unwrap_or ( String :: new ( ) ) + " -Cprefer-dynamic" ,
48
55
) ;
56
+ args. remove ( 0 ) ;
49
57
IntoIterator :: into_iter ( [ "rustc" . to_string ( ) ] )
50
- . chain ( env :: args ( ) . skip ( 2 ) )
58
+ . chain ( args)
51
59
. chain ( [
52
60
"--" . to_string ( ) ,
53
61
"-Zunstable-options" . to_string ( ) ,
@@ -60,16 +68,17 @@ fn main() {
60
68
"RUSTFLAGS" ,
61
69
env:: var ( "RUSTFLAGS" ) . unwrap_or ( String :: new ( ) ) + " -Cprefer-dynamic" ,
62
70
) ;
71
+ args. remove ( 0 ) ;
63
72
IntoIterator :: into_iter ( [ "rustc" . to_string ( ) ] )
64
- . chain ( env :: args ( ) . skip ( 2 ) )
73
+ . chain ( args)
65
74
. chain ( [
66
75
"--" . to_string ( ) ,
67
76
"-Zunstable-options" . to_string ( ) ,
68
77
"-Cllvm-args=mode=jit-lazy" . to_string ( ) ,
69
78
] )
70
79
. collect ( )
71
80
}
72
- _ => env :: args ( ) . skip ( 1 ) . collect ( ) ,
81
+ _ => args,
73
82
} ;
74
83
75
84
#[ cfg( unix) ]
You can’t perform that action at this time.
0 commit comments