Skip to content

Commit f1c59c1

Browse files
committed
fix: add feature gate for format macro in invalid_data_error
1 parent df5468f commit f1c59c1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ macro_rules! invalid_data_error {
1212
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
1313
};
1414
($fmt:expr, $($arg:tt)*) => {
15-
::core2::io::Error::new(
16-
::core2::io::ErrorKind::InvalidData,
17-
::alloc::format!($fmt, $($arg)*),
18-
)
15+
{
16+
#[cfg(feature = "std")]
17+
{
18+
::core2::io::Error::new(
19+
::core2::io::ErrorKind::InvalidData,
20+
::alloc::format!($fmt, $($arg)*),
21+
)
22+
}
23+
#[cfg(not(feature = "std"))]
24+
{
25+
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
26+
}
27+
}
1928
};
2029
}
2130

0 commit comments

Comments
 (0)