Merge pull request #85172 from andir/buildRustCrate-proc-macro

buildRustCrate: support proc-macro in default prelude
This commit is contained in:
Andreas Rammhold 2020-04-13 23:35:19 +02:00 committed by GitHub
commit 84b91899c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -16,6 +16,9 @@
++ [crateFeatures]
++ extraRustcOpts
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "--target ${rust.toRustTarget stdenv.hostPlatform} -C linker=${stdenv.hostPlatform.config}-gcc"
# since rustc 1.42 the "proc_macro" crate is part of the default crate prelude
# https://github.com/rust-lang/cargo/commit/4d64eb99a4#diff-7f98585dbf9d30aa100c8318e2c77e79R1021-R1022
++ lib.optional (lib.elem "proc-macro" crateType) "--extern proc_macro"
;
rustcMeta = "-C metadata=${metadata} -C extra-filename=-${metadata}";

View file

@ -457,6 +457,18 @@ let
"test ignore_main ... ok"
];
};
procMacroInPrelude = {
procMacro = true;
edition = "2018";
src = symlinkJoin {
name = "proc-macro-in-prelude";
paths = [
(mkFile "src/lib.rs" ''
use proc_macro::TokenTree;
'')
];
};
};
};
brotliCrates = (callPackage ./brotli-crates.nix {});
tests = lib.mapAttrs (key: value: mkTest (value // lib.optionalAttrs (!value?crateName) { crateName = key; })) cases;