about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_metadata/src/creader.rs6
-rw-r--r--src/test/ui/crate-loading/auxiliary/proc-macro.rs12
-rw-r--r--src/test/ui/crate-loading/cross-compiled-proc-macro.rs8
3 files changed, 25 insertions, 1 deletions
diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs
index 70d29f9d7ca..70b3efa1d16 100644
--- a/compiler/rustc_metadata/src/creader.rs
+++ b/compiler/rustc_metadata/src/creader.rs
@@ -599,7 +599,11 @@ impl<'a> CrateLoader<'a> {
         // don't want to match a host crate against an equivalent target one
         // already loaded.
         let root = library.metadata.get_root();
-        Ok(Some(if locator.triple == self.sess.opts.target_triple {
+        // FIXME: why is this condition necessary? It was adding in #33625 but I
+        // don't know why and the original author doesn't remember ...
+        let can_reuse_cratenum =
+            locator.triple == self.sess.opts.target_triple || locator.is_proc_macro == Some(true);
+        Ok(Some(if can_reuse_cratenum {
             let mut result = LoadResult::Loaded(library);
             self.cstore.iter_crate_data(|cnum, data| {
                 if data.name() == root.name() && root.hash() == data.hash() {
diff --git a/src/test/ui/crate-loading/auxiliary/proc-macro.rs b/src/test/ui/crate-loading/auxiliary/proc-macro.rs
new file mode 100644
index 00000000000..52631de5757
--- /dev/null
+++ b/src/test/ui/crate-loading/auxiliary/proc-macro.rs
@@ -0,0 +1,12 @@
+// force-host
+// no-prefer-dynamic
+#![crate_name = "reproduction"]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+
+#[proc_macro]
+pub fn mac(input: TokenStream) -> TokenStream {
+    input
+}
diff --git a/src/test/ui/crate-loading/cross-compiled-proc-macro.rs b/src/test/ui/crate-loading/cross-compiled-proc-macro.rs
new file mode 100644
index 00000000000..c1f4331438e
--- /dev/null
+++ b/src/test/ui/crate-loading/cross-compiled-proc-macro.rs
@@ -0,0 +1,8 @@
+// edition:2018
+// compile-flags:--extern reproduction
+// aux-build:proc-macro.rs
+// check-pass
+
+reproduction::mac!();
+
+fn main() {}