Skip to content

Commit

Permalink
auto merge of #20618 : alexcrichton/rust/less-warn, r=brson
Browse files Browse the repository at this point in the history
This warning has been around in the compiler for quite some time now, but the
real place for a warning like this, if it should exist, is in Cargo, not in the
compiler itself. It's a first-class feature of Cargo that multiple versions of a
crate can be compiled into the same executable, and we shouldn't be warning
about our first-class features.
  • Loading branch information
bors committed Jan 6, 2015
2 parents 8efd990 + 9d0b3c9 commit 6539cb4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 61 deletions.
25 changes: 0 additions & 25 deletions src/librustc/metadata/creader.rs
Expand Up @@ -20,16 +20,13 @@ use metadata::cstore::{CStore, CrateSource, MetadataBlob};
use metadata::decoder;
use metadata::loader;
use metadata::loader::CratePaths;
use util::nodemap::FnvHashMap;

use std::rc::Rc;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use syntax::ast;
use syntax::abi;
use syntax::attr;
use syntax::attr::AttrMetaMethods;
use syntax::codemap::{Span, mk_sp};
use syntax::diagnostic::SpanHandler;
use syntax::parse;
use syntax::parse::token::InternedString;
use syntax::parse::token;
Expand Down Expand Up @@ -67,27 +64,6 @@ fn dump_crates(cstore: &CStore) {
})
}

fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
let mut map = FnvHashMap::new();
cstore.iter_crate_data(|cnum, data| {
match map.entry(&data.name()) {
Vacant(entry) => { entry.insert(vec![cnum]); },
Occupied(mut entry) => { entry.get_mut().push(cnum); },
}
});

for (name, dupes) in map.into_iter() {
if dupes.len() == 1 { continue }
diag.handler().warn(
format!("using multiple versions of crate `{}`", name)[]);
for dupe in dupes.into_iter() {
let data = cstore.get_crate_data(dupe);
diag.span_note(data.span, "used here");
loader::note_crate_name(diag, data.name()[]);
}
}
}

fn should_link(i: &ast::ViewItem) -> bool {
!attr::contains_name(i.attrs[], "no_link")
}
Expand Down Expand Up @@ -188,7 +164,6 @@ impl<'a> CrateReader<'a> {
if log_enabled!(log::DEBUG) {
dump_crates(&self.sess.cstore);
}
warn_if_multiple_versions(self.sess.diagnostic(), &self.sess.cstore);

for &(ref name, kind) in self.sess.opts.libs.iter() {
register_native_lib(self.sess, None, name.clone(), kind);
Expand Down
3 changes: 1 addition & 2 deletions src/test/run-make/extern-diff-internal-name/Makefile
Expand Up @@ -2,5 +2,4 @@

all:
$(RUSTC) lib.rs
$(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib 2>&1 | \
{ ! grep "using multiple versions of crate"; }
$(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib
9 changes: 0 additions & 9 deletions src/test/run-make/multiple-versions/Makefile

This file was deleted.

14 changes: 0 additions & 14 deletions src/test/run-make/multiple-versions/bar.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/test/run-make/multiple-versions/foo.rs

This file was deleted.

0 comments on commit 6539cb4

Please sign in to comment.