Skip to content

Commit 5069734

Browse files
committed
---
yaml --- r: 106125 b: refs/heads/auto c: b568efc h: refs/heads/master i: 106123: 2af41a2 v: v3
1 parent bd2baa2 commit 5069734

File tree

5 files changed

+61
-20
lines changed

5 files changed

+61
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: da3625161d8f8bcb2f43d703eec8d002d0bb9c87
16+
refs/heads/auto: b568efc0cf173ac7b2d37284beda5fdf8a7686ab
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/metadata/loader.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,38 +283,46 @@ impl<'a> Context<'a> {
283283
// reading dylib metadata is quite slow.
284284
fn extract_one(&mut self, m: HashSet<Path>, flavor: &str,
285285
slot: &mut Option<MetadataBlob>) -> Option<Path> {
286-
if m.len() == 0 { return None }
287-
if m.len() > 1 {
288-
self.sess.span_err(self.span,
289-
format!("multiple {} candidates for `{}` \
290-
found", flavor, self.crate_id.name));
291-
for (i, path) in m.iter().enumerate() {
292-
self.sess.span_note(self.span,
293-
format!(r"candidate \#{}: {}", i + 1,
294-
path.display()));
295-
}
296-
return None
297-
}
286+
let mut ret = None::<Path>;
287+
let mut error = 0;
298288

299-
let lib = m.move_iter().next().unwrap();
300-
if slot.is_none() {
289+
for lib in m.move_iter() {
301290
info!("{} reading metadata from: {}", flavor, lib.display());
302-
match get_metadata_section(self.os, &lib) {
291+
let metadata = match get_metadata_section(self.os, &lib) {
303292
Ok(blob) => {
304293
if self.crate_matches(blob.as_slice()) {
305-
*slot = Some(blob);
294+
blob
306295
} else {
307296
info!("metadata mismatch");
308-
return None;
297+
continue
309298
}
310299
}
311300
Err(_) => {
312301
info!("no metadata found");
313-
return None
302+
continue
314303
}
304+
};
305+
if ret.is_some() {
306+
self.sess.span_err(self.span,
307+
format!("multiple {} candidates for `{}` \
308+
found", flavor, self.crate_id.name));
309+
self.sess.span_note(self.span,
310+
format!(r"candidate \#1: {}",
311+
ret.get_ref().display()));
312+
error = 1;
313+
ret = None;
314+
}
315+
if error > 0 {
316+
error += 1;
317+
self.sess.span_note(self.span,
318+
format!(r"candidate \#{}: {}", error,
319+
lib.display()));
320+
continue
315321
}
322+
*slot = Some(metadata);
323+
ret = Some(lib);
316324
}
317-
return Some(lib);
325+
return if error > 0 {None} else {ret}
318326
}
319327

320328
fn crate_matches(&mut self, crate_data: &[u8]) -> bool {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) foo.rs
5+
touch $(call DYLIB,foo-something-special)
6+
touch $(call DYLIB,foo-something-special2)
7+
$(RUSTC) bar.rs
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate foo;
12+
13+
fn main() { foo::foo() }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[crate_type = "dylib"];
12+
13+
pub fn foo() {}

0 commit comments

Comments
 (0)