]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Turn off multiple versions of crate warning
authorAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 07:23:11 +0000 (23:23 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 6 Jan 2015 16:22:59 +0000 (08:22 -0800)
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.

src/librustc/metadata/creader.rs
src/test/run-make/extern-diff-internal-name/Makefile
src/test/run-make/multiple-versions/Makefile [deleted file]
src/test/run-make/multiple-versions/bar.rs [deleted file]
src/test/run-make/multiple-versions/foo.rs [deleted file]

index 171bfd74a816b4604c281b7ac1933a002d453447..b44520e28527b8e5c9e6772b54101fed0bed6a56 100644 (file)
 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 @@ pub fn read_crates(&mut self, krate: &ast::Crate) {
         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);
index 3787b879c1ff67158924fe7a9bc0b773bcc9dcfe..b84e930757b251c8495f2dc01973f04468b25404 100644 (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
diff --git a/src/test/run-make/multiple-versions/Makefile b/src/test/run-make/multiple-versions/Makefile
deleted file mode 100644 (file)
index e60c16a..0000000
+++ /dev/null
@@ -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."
diff --git a/src/test/run-make/multiple-versions/bar.rs b/src/test/run-make/multiple-versions/bar.rs
deleted file mode 100644 (file)
index 262193a..0000000
+++ /dev/null
@@ -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() {}
diff --git a/src/test/run-make/multiple-versions/foo.rs b/src/test/run-make/multiple-versions/foo.rs
deleted file mode 100644 (file)
index 2661b1f..0000000
+++ /dev/null
@@ -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() {}