Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix json! invocations when std prelude is not in scope #1166

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

// Not public API. Used from macro-generated code.
#[doc(hidden)]
pub mod __private {
pub use alloc::vec;
}

#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[doc(inline)]
Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ macro_rules! json_internal {

// Done with trailing comma.
(@array [$($elems:expr,)*]) => {
vec![$($elems,)*]
$crate::__private::vec![$($elems,)*]
};

// Done without trailing comma.
(@array [$($elems:expr),*]) => {
vec![$($elems),*]
$crate::__private::vec![$($elems),*]
};

// Next element is `null`.
Expand Down Expand Up @@ -254,7 +254,7 @@ macro_rules! json_internal {
};

([]) => {
$crate::Value::Array(vec![])
$crate::Value::Array($crate::__private::vec![])
};

([ $($tt:tt)+ ]) => {
Expand Down