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() {
4040 "cargo"
4141 } ;
4242
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) {
4451 Some ( "jit" ) => {
4552 env:: set_var (
4653 "RUSTFLAGS" ,
4754 env:: var ( "RUSTFLAGS" ) . unwrap_or ( String :: new ( ) ) + " -Cprefer-dynamic" ,
4855 ) ;
56+ args. remove ( 0 ) ;
4957 IntoIterator :: into_iter ( [ "rustc" . to_string ( ) ] )
50- . chain ( env :: args ( ) . skip ( 2 ) )
58+ . chain ( args)
5159 . chain ( [
5260 "--" . to_string ( ) ,
5361 "-Zunstable-options" . to_string ( ) ,
@@ -60,16 +68,17 @@ fn main() {
6068 "RUSTFLAGS" ,
6169 env:: var ( "RUSTFLAGS" ) . unwrap_or ( String :: new ( ) ) + " -Cprefer-dynamic" ,
6270 ) ;
71+ args. remove ( 0 ) ;
6372 IntoIterator :: into_iter ( [ "rustc" . to_string ( ) ] )
64- . chain ( env :: args ( ) . skip ( 2 ) )
73+ . chain ( args)
6574 . chain ( [
6675 "--" . to_string ( ) ,
6776 "-Zunstable-options" . to_string ( ) ,
6877 "-Cllvm-args=mode=jit-lazy" . to_string ( ) ,
6978 ] )
7079 . collect ( )
7180 }
72- _ => env :: args ( ) . skip ( 1 ) . collect ( ) ,
81+ _ => args,
7382 } ;
7483
7584 #[ cfg( unix) ]
You can’t perform that action at this time.
0 commit comments