1- // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+ // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22// file at the top-level directory of this distribution and at
33// http://rust-lang.org/COPYRIGHT.
44//
@@ -257,6 +257,7 @@ pub struct Context<'a> {
257257 pub root : & ' a Option < CratePaths > ,
258258 pub rejected_via_hash : Vec < CrateMismatch > ,
259259 pub rejected_via_triple : Vec < CrateMismatch > ,
260+ pub rejected_via_kind : Vec < CrateMismatch > ,
260261 pub should_match_name : bool ,
261262}
262263
@@ -311,6 +312,8 @@ impl<'a> Context<'a> {
311312 } else if self . rejected_via_triple . len ( ) > 0 {
312313 format ! ( "couldn't find crate `{}` with expected target triple {}" ,
313314 self . ident, self . triple)
315+ } else if self . rejected_via_kind . len ( ) > 0 {
316+ format ! ( "found staticlib `{}` instead of rlib or dylib" , self . ident)
314317 } else {
315318 format ! ( "can't find crate for `{}`" , self . ident)
316319 } ;
@@ -335,8 +338,8 @@ impl<'a> Context<'a> {
335338 let mismatches = self . rejected_via_hash . iter ( ) ;
336339 for ( i, & CrateMismatch { ref path, .. } ) in mismatches. enumerate ( ) {
337340 self . sess . fileline_note ( self . span ,
338- & format ! ( "crate `{}` path {} {}: {}" ,
339- self . ident, "#" , i+1 , path. display( ) ) [ ] ) ;
341+ & format ! ( "crate `{}` path # {}: {}" ,
342+ self . ident, i+1 , path. display( ) ) [ ] ) ;
340343 }
341344 match self . root {
342345 & None => { }
@@ -349,6 +352,16 @@ impl<'a> Context<'a> {
349352 }
350353 }
351354 }
355+ if self . rejected_via_kind . len ( ) > 0 {
356+ self . sess . span_help ( self . span , "please recompile this crate using \
357+ --crate-type lib") ;
358+ let mismatches = self . rejected_via_kind . iter ( ) ;
359+ for ( i, & CrateMismatch { ref path, .. } ) in mismatches. enumerate ( ) {
360+ self . sess . fileline_note ( self . span ,
361+ & format ! ( "crate `{}` path #{}: {}" ,
362+ self . ident, i+1 , path. display( ) ) [ ] ) ;
363+ }
364+ }
352365 self . sess . abort_if_errors ( ) ;
353366 }
354367
@@ -369,8 +382,10 @@ impl<'a> Context<'a> {
369382 // want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
370383 let dylib_prefix = format ! ( "{}{}" , dypair. 0 , self . crate_name) ;
371384 let rlib_prefix = format ! ( "lib{}" , self . crate_name) ;
385+ let staticlib_prefix = format ! ( "lib{}" , self . crate_name) ;
372386
373387 let mut candidates = HashMap :: new ( ) ;
388+ let mut staticlibs = vec ! ( ) ;
374389
375390 // First, find all possible candidate rlibs and dylibs purely based on
376391 // the name of the files themselves. We're trying to match against an
@@ -391,14 +406,21 @@ impl<'a> Context<'a> {
391406 Some ( file) => file,
392407 } ;
393408 let ( hash, rlib) = if file. starts_with ( & rlib_prefix[ ] ) &&
394- file. ends_with ( ".rlib" ) {
409+ file. ends_with ( ".rlib" ) {
395410 ( & file[ ( rlib_prefix. len ( ) ) .. ( file. len ( ) - ".rlib" . len ( ) ) ] ,
396411 true )
397412 } else if file. starts_with ( & dylib_prefix) &&
398413 file. ends_with ( & dypair. 1 ) {
399414 ( & file[ ( dylib_prefix. len ( ) ) .. ( file. len ( ) - dypair. 1 . len ( ) ) ] ,
400415 false )
401416 } else {
417+ if file. starts_with ( & staticlib_prefix[ ] ) &&
418+ file. ends_with ( ".a" ) {
419+ staticlibs. push ( CrateMismatch {
420+ path : path. clone ( ) ,
421+ got : "static" . to_string ( )
422+ } ) ;
423+ }
402424 return FileDoesntMatch
403425 } ;
404426 info ! ( "lib candidate: {}" , path. display( ) ) ;
@@ -415,6 +437,7 @@ impl<'a> Context<'a> {
415437
416438 FileMatches
417439 } ) ;
440+ self . rejected_via_kind . extend ( staticlibs. into_iter ( ) ) ;
418441
419442 // We have now collected all known libraries into a set of candidates
420443 // keyed of the filename hash listed. For each filename, we also have a
0 commit comments