buildRustCrate: support proc-macro in default prelude

This commit is contained in:
Andreas Rammhold 2020-03-17 16:33:13 +01:00
parent 9e2a52f239
commit a9fdfebc6b
No known key found for this signature in database
GPG Key ID: E432E410B5E48C86
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

@ -412,6 +412,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;