@@ -15,7 +15,9 @@ use super::self_update;
1515use super :: term2;
1616use super :: term2:: Terminal ;
1717use super :: topical_doc;
18- use crate :: dist:: dist:: { PartialTargetTriple , PartialToolchainDesc , Profile , TargetTriple } ;
18+ use crate :: dist:: dist:: {
19+ PartialTargetTriple , PartialToolchainDesc , Profile , TargetTriple , ToolchainDesc ,
20+ } ;
1921use crate :: dist:: manifest:: Component ;
2022use crate :: process;
2123use crate :: toolchain:: { CustomToolchain , DistributableToolchain } ;
@@ -904,6 +906,32 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode> {
904906 if let Some ( names) = m. values_of ( "toolchain" ) {
905907 for name in names {
906908 update_bare_triple_check ( cfg, name) ?;
909+
910+ let toolchain_has_triple = match PartialToolchainDesc :: from_str ( name) {
911+ Ok ( x) => x. has_triple ( ) ,
912+ _ => false ,
913+ } ;
914+
915+ if toolchain_has_triple {
916+ let host_arch = TargetTriple :: from_host_or_build ( ) ;
917+ match ToolchainDesc :: from_str ( name) {
918+ Ok ( toolchain_desc) => {
919+ let target_triple = toolchain_desc. target ;
920+ if host_arch. ne ( & target_triple) {
921+ warn ! (
922+ "toolchain '{}' may not be able to run on this system." ,
923+ name
924+ ) ;
925+ warn ! (
926+ "If you meant to build software to target that platform, perhaps try `rustup target add {}` instead?" ,
927+ target_triple. to_string( )
928+ ) ;
929+ }
930+ }
931+ _ => ( ) ,
932+ }
933+ }
934+
907935 let toolchain = cfg. get_toolchain ( name, false ) ?;
908936
909937 let status = if !toolchain. is_custom ( ) {
0 commit comments