@@ -141,6 +141,24 @@ impl<T> EnsureInstalled<T> {
141141 }
142142}
143143
144+ impl < T : Display > EnsureInstalled < T > {
145+ fn warn_auto_install ( & self , process : & Process ) {
146+ // If we're already in a recursion, or we haven't just installed the active toolchain, then
147+ // don't print the warning.
148+ let recursions = process. var ( "RUST_RECURSION_COUNT" ) ;
149+ if recursions. is_ok_and ( |it| it != "0" ) || !matches ! ( self . status, UpdateStatus :: Installed ) {
150+ return ;
151+ }
152+
153+ warn ! (
154+ "the missing active toolchain `{}` has been auto-installed" ,
155+ self . inner,
156+ ) ;
157+ warn ! ( "this might cause rustup commands to take longer time to finish than expected" ) ;
158+ info ! ( "you may opt out with `RUSTUP_AUTO_INSTALL=0` or `rustup set auto-install disable`" ) ;
159+ }
160+ }
161+
144162impl < T > Deref for EnsureInstalled < T > {
145163 type Target = T ;
146164
@@ -544,6 +562,7 @@ impl<'a> Cfg<'a> {
544562 match self . ensure_active_toolchain ( true , false ) . await {
545563 Ok ( r) => {
546564 let ( tc, source) = r;
565+ tc. warn_auto_install ( self . process ) ;
547566 Ok ( Some ( ( tc. inner , source) ) )
548567 }
549568 Err ( e) => match e. downcast_ref :: < RustupError > ( ) {
@@ -747,8 +766,10 @@ impl<'a> Cfg<'a> {
747766 match name {
748767 Some ( ( tc, source) ) => {
749768 let install_if_missing = self . should_auto_install ( ) ?;
750- let tc = Toolchain :: from_local ( tc, install_if_missing, self ) . await ?;
751- Ok ( ( tc. inner , source) )
769+ let EnsureInstalled { inner : tc, status } =
770+ Toolchain :: from_local ( tc, install_if_missing, self ) . await ?;
771+ EnsureInstalled :: new ( tc. name ( ) , status) . warn_auto_install ( self . process ) ;
772+ Ok ( ( tc, source) )
752773 }
753774 None => {
754775 let ( tc, source) = self
0 commit comments