about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-06-24 16:29:15 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-06-24 17:24:19 -0700
commitfb296b80118a2c594986c09f2b6ec97829ba3d2d (patch)
treef63e763e932dec1ef5135b00301eeaf9c550dbca
parent86dda1b6f3db582005a3138e6cc10eb924ad7da3 (diff)
downloadrust-fb296b80118a2c594986c09f2b6ec97829ba3d2d.tar.gz
rust-fb296b80118a2c594986c09f2b6ec97829ba3d2d.zip
rustc: Don't register syntax crates twice
We only need to register them once, and once they're registered twice warnings
will start being spewed or worse may happen!

Closes #14330
-rw-r--r--src/librustc/metadata/creader.rs2
-rw-r--r--src/test/run-pass/issue-14330.rs15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index efe28614b8f..0b9ed68215a 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -448,7 +448,7 @@ impl<'a> PluginMetadataReader<'a> {
             macros: macros.move_iter().map(|x| x.to_string()).collect(),
             registrar_symbol: registrar,
         };
-        if should_link {
+        if should_link && existing_match(&self.env, &info.crate_id, None).is_none() {
             // register crate now to avoid double-reading metadata
             register_crate(&mut self.env, &None, info.ident.as_slice(),
                            &info.crate_id, krate.span, library);
diff --git a/src/test/run-pass/issue-14330.rs b/src/test/run-pass/issue-14330.rs
new file mode 100644
index 00000000000..a7f2ebf9e11
--- /dev/null
+++ b/src/test/run-pass/issue-14330.rs
@@ -0,0 +1,15 @@
+// Copyright 2012-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.
+
+#![feature(phase)]
+
+#[phase(plugin, link)] extern crate std;
+
+fn main() {}