Skip to content

Commit

Permalink
Merge pull request #3870 from stepancheg/macro-refs
Browse files Browse the repository at this point in the history
Put once_cell reexport into __macro_refs
  • Loading branch information
epage committed Jun 28, 2022
2 parents 5ba41d7 + 464ef39 commit a05f4d3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions clap_derive/src/attrs.rs
Expand Up @@ -552,7 +552,7 @@ impl Attrs {
})
} else {
quote_spanned!(ident.span()=> {
static DEFAULT_VALUE: clap::once_cell::sync::Lazy<String> = clap::once_cell::sync::Lazy::new(|| {
static DEFAULT_VALUE: clap::__macro_refs::once_cell::sync::Lazy<String> = clap::__macro_refs::once_cell::sync::Lazy::new(|| {
let val: #ty = #val;
::std::string::ToString::to_string(&val)
});
Expand Down Expand Up @@ -592,7 +592,7 @@ impl Attrs {
})
} else {
quote_spanned!(ident.span()=> {
static DEFAULT_VALUE: clap::once_cell::sync::Lazy<::std::ffi::OsString> = clap::once_cell::sync::Lazy::new(|| {
static DEFAULT_VALUE: clap::__macro_refs::once_cell::sync::Lazy<::std::ffi::OsString> = clap::__macro_refs::once_cell::sync::Lazy::new(|| {
let val: #ty = #val;
::std::ffi::OsString::from(val)
});
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Expand Up @@ -82,9 +82,12 @@ pub use Parser as StructOpt;
)]
pub use ValueEnum as ArgEnum;

#[cfg(any(feature = "derive", feature = "cargo"))]
#[doc(hidden)]
pub use once_cell;
pub mod __macro_refs {
#[cfg(any(feature = "derive", feature = "cargo"))]
#[doc(hidden)]
pub use once_cell;
}

#[macro_use]
#[allow(missing_docs)]
Expand Down
6 changes: 4 additions & 2 deletions src/macros.rs
Expand Up @@ -250,8 +250,10 @@ macro_rules! crate_version {
#[macro_export]
macro_rules! crate_authors {
($sep:expr) => {{
static CACHED: clap::once_cell::sync::Lazy<String> =
clap::once_cell::sync::Lazy::new(|| env!("CARGO_PKG_AUTHORS").replace(':', $sep));
static CACHED: clap::__macro_refs::once_cell::sync::Lazy<String> =
clap::__macro_refs::once_cell::sync::Lazy::new(|| {
env!("CARGO_PKG_AUTHORS").replace(':', $sep)
});

let s: &'static str = &*CACHED;
s
Expand Down
4 changes: 2 additions & 2 deletions tests/derive_ui/next/bool_value_enum.stderr
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `bool: ValueEnum` is not satisfied
error[E0277]: the trait bound `bool: ArgEnum` is not satisfied
--> tests/derive_ui/next/bool_value_enum.rs:6:31
|
6 | #[clap(short, value_enum, default_value_t)]
| ^^^^^^^^^^^^^^^ the trait `ValueEnum` is not implemented for `bool`
| ^^^^^^^^^^^^^^^ the trait `ArgEnum` is not implemented for `bool`
|
note: required by `to_possible_value`
--> src/derive.rs
Expand Down

0 comments on commit a05f4d3

Please sign in to comment.