@@ -765,7 +765,9 @@ impl<'a> Builder<'a> {
765765 if cmd == "doc" || cmd == "rustdoc" {
766766 let my_out = match mode {
767767 // This is the intended out directory for compiler documentation.
768- Mode :: Rustc | Mode :: ToolRustc | Mode :: Codegen => self . compiler_doc_out ( target) ,
768+ Mode :: Rustc | Mode :: ToolRustc { .. } | Mode :: Codegen => {
769+ self . compiler_doc_out ( target)
770+ }
769771 _ => self . crate_doc_out ( target) ,
770772 } ;
771773 let rustdoc = self . rustdoc ( compiler) ;
@@ -797,8 +799,8 @@ impl<'a> Builder<'a> {
797799 }
798800
799801 match mode {
800- Mode :: Std | Mode :: ToolBootstrap | Mode :: ToolStd => { } ,
801- Mode :: Rustc | Mode :: Codegen | Mode :: ToolRustc => {
802+ Mode :: Std | Mode :: ToolBootstrap { .. } | Mode :: ToolStd { .. } => { } ,
803+ Mode :: Rustc | Mode :: Codegen | Mode :: ToolRustc { .. } => {
802804 // Build proc macros both for the host and the target
803805 if target != compiler. host && cmd != "check" {
804806 cargo. arg ( "-Zdual-proc-macros" ) ;
@@ -873,6 +875,28 @@ impl<'a> Builder<'a> {
873875 extra_args. push_str ( "-Zforce-unstable-if-unmarked" ) ;
874876 }
875877
878+ match mode {
879+ Mode :: ToolStd { in_tree : true } |
880+ Mode :: ToolRustc { in_tree : true } |
881+ Mode :: ToolBootstrap { in_tree : true } |
882+ Mode :: Std |
883+ Mode :: Rustc |
884+ Mode :: Codegen => {
885+ // When extending this list, add the new lints to the RUSTFLAGS of the
886+ // build_bootstrap function of src/bootstrap/bootstrap.py as well as
887+ // some code doesn't go through this `rustc` wrapper.
888+ extra_args. push_str ( " -Wrust_2018_idioms" ) ;
889+ extra_args. push_str ( " -Wunused_lifetimes" ) ;
890+ }
891+ Mode :: ToolStd { in_tree : false } |
892+ Mode :: ToolRustc { in_tree : false } |
893+ Mode :: ToolBootstrap { in_tree : false } => { }
894+ }
895+
896+ if self . config . deny_warnings {
897+ extra_args. push_str ( " -Dwarnings" ) ;
898+ }
899+
876900 if !extra_args. is_empty ( ) {
877901 cargo. env (
878902 "RUSTFLAGS" ,
@@ -891,7 +915,11 @@ impl<'a> Builder<'a> {
891915 // the stage0 build means it uses libraries build by the stage0
892916 // compiler, but for tools we just use the precompiled libraries that
893917 // we've downloaded
894- let use_snapshot = mode == Mode :: ToolBootstrap ;
918+ let use_snapshot = if let Mode :: ToolBootstrap { .. } = mode {
919+ true
920+ } else {
921+ false
922+ } ;
895923 assert ! ( !use_snapshot || stage == 0 || self . local_rebuild) ;
896924
897925 let maybe_sysroot = self . sysroot ( compiler) ;
@@ -944,8 +972,9 @@ impl<'a> Builder<'a> {
944972 let debuginfo_level = match mode {
945973 Mode :: Rustc | Mode :: Codegen => self . config . rust_debuginfo_level_rustc ,
946974 Mode :: Std => self . config . rust_debuginfo_level_std ,
947- Mode :: ToolBootstrap | Mode :: ToolStd |
948- Mode :: ToolRustc => self . config . rust_debuginfo_level_tools ,
975+ Mode :: ToolBootstrap { .. } | Mode :: ToolStd { .. } | Mode :: ToolRustc { .. } => {
976+ self . config . rust_debuginfo_level_tools
977+ }
949978 } ;
950979 cargo. env ( "RUSTC_DEBUGINFO_LEVEL" , debuginfo_level. to_string ( ) ) ;
951980
@@ -1031,10 +1060,6 @@ impl<'a> Builder<'a> {
10311060
10321061 cargo. env ( "RUSTC_VERBOSE" , self . verbosity . to_string ( ) ) ;
10331062
1034- if self . config . deny_warnings {
1035- cargo. env ( "RUSTC_DENY_WARNINGS" , "1" ) ;
1036- }
1037-
10381063 // Throughout the build Cargo can execute a number of build scripts
10391064 // compiling C/C++ code and we need to pass compilers, archivers, flags, etc
10401065 // obtained previously to those build scripts.
0 commit comments