rustc: Turn off multiple versions of crate warning

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.
This commit is contained in:
Alex Crichton 2015-01-05 23:23:11 -08:00
parent 8efd9901b6
commit 9d0b3c9fc9
5 changed files with 1 additions and 61 deletions

View File

@ -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;
@ -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")
}
@ -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);

View File

@ -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

View File

@ -1,9 +0,0 @@
-include ../tools.mk
all:
$(RUSTC) foo.rs -C metadata=a -C extra-filename=-1 --crate-type=rlib
$(RUSTC) foo.rs -C metadata=b -C extra-filename=-2 --crate-type=rlib
$(RUSTC) bar.rs \
--extern foo1=$(TMPDIR)/libfoo-1.rlib \
--extern foo2=$(TMPDIR)/libfoo-2.rlib \
2>&1 | grep "using multiple versions of crate .foo."

View File

@ -1,14 +0,0 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate foo1;
extern crate foo2;
fn main() {}

View File

@ -1,11 +0,0 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn foo() {}