Skip to content

Commit 957229c

Browse files
committed
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
1 parent f9888ac commit 957229c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc/metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn existing_match(e: &Env, name: &str,
281281
hash: Option<&Svh>) -> Option<ast::CrateNum> {
282282
let mut ret = None;
283283
e.sess.cstore.iter_crate_data(|cnum, data| {
284-
if data.name().as_slice() != name { return }
284+
if data.name.as_slice() != name { return }
285285

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

0 commit comments

Comments
 (0)