@@ -16,7 +16,7 @@ use std::{ffi::OsString, path::PathBuf, process::Command};
1616
1717use once_cell:: sync:: Lazy ;
1818
19- use crate :: ExitStatus ;
19+ use crate :: { cli :: Flags , ExitStatus } ;
2020
2121/// This is the driver version and toolchain, that is used by the setup command
2222/// to install the driver.
@@ -41,7 +41,7 @@ pub fn print_driver_version() {
4141}
4242
4343/// This tries to install the rustc driver specified in [`DEFAULT_DRIVER_INFO`].
44- pub fn install_driver ( verbose : bool , dev_build : bool ) -> Result < ( ) , ExitStatus > {
44+ pub fn install_driver ( flags : & Flags ) -> Result < ( ) , ExitStatus > {
4545 // The toolchain, driver version and api version should ideally be configurable.
4646 // However, that will require more prototyping and has a low priority rn.
4747 // See #60
@@ -50,10 +50,10 @@ pub fn install_driver(verbose: bool, dev_build: bool) -> Result<(), ExitStatus>
5050 let toolchain = & DEFAULT_DRIVER_INFO . toolchain ;
5151 check_toolchain ( toolchain) ?;
5252
53- build_driver ( toolchain, & DEFAULT_DRIVER_INFO . version , verbose , dev_build ) ?;
53+ build_driver ( toolchain, & DEFAULT_DRIVER_INFO . version , flags ) ?;
5454
5555 // We don't want to advice the user, to install the driver again.
56- check_driver ( verbose, false )
56+ check_driver ( flags . verbose , false )
5757}
5858
5959/// This function checks if the specified toolchain is installed. This requires
@@ -73,8 +73,8 @@ fn check_toolchain(toolchain: &str) -> Result<(), ExitStatus> {
7373
7474/// This tries to compile the driver. If successful the driver binary will
7575/// be places next to the executable of `cargo-linter`.
76- fn build_driver ( toolchain : & str , version : & str , verbose : bool , dev_build : bool ) -> Result < ( ) , ExitStatus > {
77- if dev_build {
76+ fn build_driver ( toolchain : & str , version : & str , flags : & Flags ) -> Result < ( ) , ExitStatus > {
77+ if flags . dev_build {
7878 println ! ( "Compiling rustc driver" ) ;
7979 } else {
8080 println ! ( "Compiling rustc driver v{version} with {toolchain}" ) ;
@@ -83,15 +83,21 @@ fn build_driver(toolchain: &str, version: &str, verbose: bool, dev_build: bool)
8383 // Build driver
8484 let mut cmd = Command :: new ( "cargo" ) ;
8585
86- if !dev_build {
86+ if !flags . dev_build {
8787 cmd. arg ( & format ! ( "+{toolchain}" ) ) ;
8888 }
8989
90- if verbose {
90+ if flags . verbose {
9191 cmd. arg ( "--verbose" ) ;
9292 }
9393
94- if dev_build {
94+ let mut rustc_flags = if flags. forward_rust_flags {
95+ std:: env:: var ( "RUSTFLAGS" ) . unwrap_or_default ( )
96+ } else {
97+ String :: new ( )
98+ } ;
99+
100+ if flags. dev_build {
95101 cmd. args ( [ "build" , "--bin" , "marker_driver_rustc" ] ) ;
96102 } else {
97103 // FIXME: This currently installs the binary in Cargo's default location.
@@ -105,8 +111,11 @@ fn build_driver(toolchain: &str, version: &str, verbose: bool, dev_build: bool)
105111 //
106112 // See #60
107113 cmd. args ( [ "install" , "marker_rustc_driver" , "--version" , version] ) ;
114+ rustc_flags += " --cap-lints=allow" ;
108115 }
116+ cmd. env ( "RUSTFLAGS" , rustc_flags) ;
109117
118+ // `RUSTFLAGS` is never set for driver compilation, we might want to
110119 let status = cmd
111120 . spawn ( )
112121 . expect ( "unable to start cargo install for the driver" )
0 commit comments