]> git.lizzy.rs Git - rust.git/commitdiff
rustc: Don't register syntax crates twice
authorAlex Crichton <alex@alexcrichton.com>
Tue, 24 Jun 2014 23:29:15 +0000 (16:29 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 25 Jun 2014 00:24:19 +0000 (17:24 -0700)
We only need to register them once, and once they're registered twice warnings
will start being spewed or worse may happen!

Closes #14330

src/librustc/metadata/creader.rs
src/test/run-pass/issue-14330.rs [new file with mode: 0644]

index efe28614b8f4da26e586f817de751145d48f4ce2..0b9ed68215a6bff839fa140adc87890c0115f837 100644 (file)
@@ -448,7 +448,7 @@ pub fn read_plugin_metadata(&mut self, krate: &ast::ViewItem) -> PluginMetadata
             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 (file)
index 0000000..a7f2ebf
--- /dev/null
@@ -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() {}