diff options
| author | bors <bors@rust-lang.org> | 2021-07-15 02:39:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-15 02:39:38 +0000 |
| commit | b9197978a90be6f7570741eabe2da175fec75375 (patch) | |
| tree | 9e9466a496a1b5f38bf38b0201ded9ec9d586b07 /src | |
| parent | 9c107816f7b351ea5b5043cdbec52901a77526de (diff) | |
| parent | 68b959827bfba1dd942c84d6ccbcc32e7b6d98a1 (diff) | |
| download | rust-b9197978a90be6f7570741eabe2da175fec75375.tar.gz rust-b9197978a90be6f7570741eabe2da175fec75375.zip | |
Auto merge of #86876 - jyn514:56935-target-crate-num, r=petrochenkov
Reuse CrateNum for proc-macro crates even when cross-compiling
Proc-macros are always compiled for the host, so this should be the same
in every way as recompiling the crate.
I am not sure why the previous code special-cased the target, since the
compiler properly gives an error when trying to load a crate for a
different host:
```
error[E0461]: couldn't find crate `dependency` with expected target triple x86_64-unknown-linux-gnu
--> /home/joshua/rustc4/src/test/ui/cfg-dependent.rs:8:2
|
LL | dependency::is_64();
| ^^^^^^^^^^
|
= note: the following crate versions were found:
crate `dependency`, target triple i686-unknown-linux-gnu: /home/joshua/rustc4/build/x86_64-unknown-linux-gnu/test/ui/cfg-dependent/auxiliary/libdependency.so
```
I think another possible fix is to remove the check altogether. But I'm
not sure, and this fix works, so I'm not making the larger change here.
Fixes https://github.com/rust-lang/rust/issues/56935.
r? `@petrochenkov` cc `@alexcrichton`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/crate-loading/auxiliary/proc-macro.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/crate-loading/cross-compiled-proc-macro.rs | 8 |
2 files changed, 20 insertions, 0 deletions
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() {} |
