Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix check for existing crate when using --extern
When checking for an existing crate, compare against the
`crate_metadata::name` field, which is the crate name which
was requested during resolution, rather than the result of the
`crate_metadata::name()` method, which is the crate name within
the crate metadata, as these may not match when using the --extern
option to `rustc`.

This fixes spurious "multiple crate version" warnings under the
following scenario:

- The crate `foo`, is referenced multiple times
- `--extern foo=./path/to/libbar.rlib` is specified to rustc
- The internal crate name of `libbar.rlib` is not `foo`

The behavior surrounding `Context::should_match_name` and the
comments in `loader.rs` both lead me to believe that this scenario
is intended to work.

Fixes #17186
  • Loading branch information
bkoropoff committed Sep 12, 2014
1 parent f9888ac commit 957229c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Expand Up @@ -281,7 +281,7 @@ fn existing_match(e: &Env, name: &str,
hash: Option<&Svh>) -> Option<ast::CrateNum> {
let mut ret = None;
e.sess.cstore.iter_crate_data(|cnum, data| {
if data.name().as_slice() != name { return }
if data.name.as_slice() != name { return }

match hash {
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
Expand Down

0 comments on commit 957229c

Please sign in to comment.