Skip to content

Commit 7ff5bbd

Browse files
committed
auto merge of #15971 : alexcrichton/rust/hurray-for-windows, r=pcwalton
The right hand side of the comparison in these checks are values of type Option<&Path> which are normalized versions of the left-hand side, so they're not guaranteed to be byte-for-byte equivalent even though they're the same path. For this reasons, the command line arguments are promoted to paths for comparison of equality. This fixes a bug on windows where if a library was specified with --extern it would then be picked up twice because it was not considered to have been previously registered.
2 parents 44019c7 + bd838a3 commit 7ff5bbd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/librustc/metadata/creader.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,16 @@ fn existing_match(e: &Env, name: &str,
293293
// library. Even though an upstream library may have loaded something of
294294
// the same name, we have to make sure it was loaded from the exact same
295295
// location as well.
296+
//
297+
// We're also sure to compare *paths*, not actual byte slices. The
298+
// `source` stores paths which are normalized which may be different
299+
// from the strings on the command line.
296300
let source = e.sess.cstore.get_used_crate_source(cnum).unwrap();
297-
let dylib = source.dylib.as_ref().map(|p| p.as_vec());
298-
let rlib = source.rlib.as_ref().map(|p| p.as_vec());
299301
match e.sess.opts.externs.find_equiv(&name) {
300302
Some(locs) => {
301303
let found = locs.iter().any(|l| {
302-
Some(l.as_bytes()) == dylib || Some(l.as_bytes()) == rlib
304+
let l = Some(Path::new(l.as_slice()));
305+
l == source.dylib || l == source.rlib
303306
});
304307
if found {
305308
ret = Some(cnum);

0 commit comments

Comments
 (0)