@@ -174,13 +174,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
174
174
"RUSTFLAGS" ) ?;
175
175
let mut process = self . config . rustc ( ) ?. process ( ) ;
176
176
process. arg ( "-" )
177
- . arg ( "--crate-name" ) . arg ( "_ " )
177
+ . arg ( "--crate-name" ) . arg ( "___ " )
178
178
. arg ( "--print=file-names" )
179
179
. args ( & rustflags)
180
180
. env_remove ( "RUST_LOG" ) ;
181
181
182
182
for crate_type in crate_types {
183
- process. arg ( "--crate-type" ) . arg ( crate_type) ;
183
+ // Here and below we'll skip the metadata crate-type because it is
184
+ // not supported by older compilers. We'll do this one manually.
185
+ if crate_type != "metadata" {
186
+ process. arg ( "--crate-type" ) . arg ( crate_type) ;
187
+ }
184
188
}
185
189
if kind == Kind :: Target {
186
190
process. arg ( "--target" ) . arg ( & self . target_triple ( ) ) ;
@@ -204,31 +208,37 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
204
208
let mut map = HashMap :: new ( ) ;
205
209
for crate_type in crate_types {
206
210
let not_supported = error. lines ( ) . any ( |line| {
207
- line. contains ( "unsupported crate type" ) &&
208
- line. contains ( crate_type)
211
+ ( line. contains ( "unsupported crate type" ) ||
212
+ line. contains ( "unknown crate type" ) ) &&
213
+ line. contains ( crate_type)
209
214
} ) ;
210
215
if not_supported {
211
- if crate_type == "metadata" {
212
- bail ! ( "compiler does not support `--crate-type metadata`, \
213
- cannot run `cargo check`.") ;
214
- }
215
216
map. insert ( crate_type. to_string ( ) , None ) ;
216
- continue
217
+ continue ;
218
+ }
219
+ if crate_type == "metadata" {
220
+ continue ;
217
221
}
218
222
let line = match lines. next ( ) {
219
223
Some ( line) => line,
220
224
None => bail ! ( "malformed output when learning about \
221
225
target-specific information from rustc") ,
222
226
} ;
223
- let mut parts = line. trim ( ) . split ( '_' ) ;
227
+ let mut parts = line. trim ( ) . split ( "___" ) ;
224
228
let prefix = parts. next ( ) . unwrap ( ) ;
225
229
let suffix = match parts. next ( ) {
226
230
Some ( part) => part,
227
231
None => bail ! ( "output of --print=file-names has changed in \
228
232
the compiler, cannot parse") ,
229
233
} ;
230
- map. insert ( crate_type. to_string ( ) ,
231
- Some ( ( prefix. to_string ( ) , suffix. to_string ( ) ) ) ) ;
234
+
235
+ map. insert ( crate_type. to_string ( ) , Some ( ( prefix. to_string ( ) , suffix. to_string ( ) ) ) ) ;
236
+ }
237
+
238
+ // Manually handle the metadata case. If it is not supported by the
239
+ // compiler we'll error out elsewhere.
240
+ if crate_types. contains ( "metadata" ) {
241
+ map. insert ( "metadata" . to_string ( ) , Some ( ( "lib" . to_owned ( ) , ".rmeta" . to_owned ( ) ) ) ) ;
232
242
}
233
243
234
244
let cfg = if has_cfg {
0 commit comments