@@ -103,11 +103,7 @@ pub(crate) enum RustupError {
103
103
"help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain."
104
104
) ]
105
105
ToolchainNotSelected ,
106
- #[ error( "toolchain '{}' does not contain component {}{}{}" , . desc, . component, if let Some ( suggestion) = . suggestion {
107
- format!( "; did you mean '{suggestion}'?" )
108
- } else {
109
- "" . to_string( )
110
- } , if . component. contains( "rust-std" ) {
106
+ #[ error( "toolchain '{}' does not contain component {}{}{}" , . desc, . component, suggest_message( . suggestion) , if . component. contains( "rust-std" ) {
111
107
format!( "\n note: not all platforms have the standard library pre-compiled: https://doc.rust-lang.org/nightly/rustc/platform-support.html{}" ,
112
108
if desc. channel == "nightly" { "\n help: consider using `cargo build -Z build-std` instead" } else { "" }
113
109
)
@@ -120,22 +116,14 @@ pub(crate) enum RustupError {
120
116
#[ error( "toolchain '{}' does not support target '{}'{}\n \
121
117
note: you can see a list of supported targets with `rustc --print=target-list`\n \
122
118
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html", . desc, . target,
123
- if let Some ( suggestion) = . suggestion {
124
- format!( "; did you mean '{suggestion}'?" )
125
- } else {
126
- "" . to_string( )
127
- } ) ]
119
+ suggest_message( . suggestion) ) ]
128
120
UnknownTarget {
129
121
desc : ToolchainDesc ,
130
122
target : TargetTriple ,
131
123
suggestion : Option < String > ,
132
124
} ,
133
125
#[ error( "toolchain '{}' does not have target '{}' installed{}\n " , . desc, . target,
134
- if let Some ( suggestion) = . suggestion {
135
- format!( "; did you mean '{suggestion}'?" )
136
- } else {
137
- "" . to_string( )
138
- } ) ]
126
+ suggest_message( . suggestion) ) ]
139
127
TargetNotInstalled {
140
128
desc : ToolchainDesc ,
141
129
target : TargetTriple ,
@@ -151,6 +139,14 @@ pub(crate) enum RustupError {
151
139
IOError ( #[ from] std:: io:: Error ) ,
152
140
}
153
141
142
+ fn suggest_message ( suggestion : & Option < String > ) -> String {
143
+ if let Some ( suggestion) = suggestion {
144
+ format ! ( "; did you mean '{}'?" , suggestion)
145
+ } else {
146
+ String :: new ( )
147
+ }
148
+ }
149
+
154
150
fn remove_component_msg ( cs : & Component , manifest : & Manifest , toolchain : & str ) -> String {
155
151
if cs. short_name_in_manifest ( ) == "rust-std" {
156
152
// We special-case rust-std as it's the stdlib so really you want to do
0 commit comments