1
Fork 0
mirror of https://github.com/RGBCube/embd-rs synced 2025-07-27 21:47:45 +00:00

Better error messages when procmacro2_semver_exempt is not set

This commit is contained in:
RGBCube 2024-05-22 10:57:48 +03:00
parent 661d2d54c0
commit 0c9527c653
No known key found for this signature in database
2 changed files with 30 additions and 2 deletions

View file

@ -1,11 +1,20 @@
#![allow(unexpected_cfgs)]
#![cfg(procmacro2_semver_exempt)]
use std::{
borrow::Cow,
fs,
path::Path,
};
#[cfg(not(procmacro2_semver_exempt))]
compile_error!(
r#"pass `--cfg procmacro2_semver_exempt` to rustc to compile embd or add this to your `.cargo/config.toml`:
[build]
rustflags = [ "--cfg", "procmacro2_semver_exempt" ]
"#
);
#[doc(hidden)]
pub fn __string_runtime(neighbor: &str, path: &str) -> String {
let file = Path::new(neighbor)
@ -27,6 +36,7 @@ pub fn __string_runtime(neighbor: &str, path: &str) -> String {
/// }
/// ```
#[macro_export]
#[cfg(procmacro2_semver_exempt)]
macro_rules! string {
($path:literal) => {{
#[cfg(debug_assertions)]
@ -62,6 +72,7 @@ pub fn __bytes_runtime(neighbor: &str, path: &str) -> Vec<u8> {
/// }
/// ```
#[macro_export]
#[cfg(procmacro2_semver_exempt)]
macro_rules! bytes {
($path:literal) => {{
#[cfg(debug_assertions)]
@ -223,4 +234,5 @@ pub fn __dir_runtime(neighbor: &str, path: &str) -> Dir {
/// let content: embd::Dir = embd::dir!("../assets");
/// }
/// ```
#[cfg(procmacro2_semver_exempt)]
pub use embd_macros::__dir as dir;