Skip to content

Bug: State is undefined when neither tokio nor async-std features are enabled #92

@ognis1205

Description

@ognis1205

Description

When building git-cliff-core with both tokio-runtime and async-std features disabled, the crate fails to compile due to State being undefined.

Currently, git-cliff-core depends on cacache with the following configuration:

cacache = { version = "=13.0.0", features = ["mmap"], default-features = false }

In this configuration, neither tokio-runtime nor async-std is enabled.

However, State and update_state are conditionally defined as follows:

#[cfg(any(feature = "async-std", feature = "tokio"))]
enum State {
Idle(Option<Inner>),
Busy(JoinHandle<State>),
}

#[cfg(feature = "tokio")]
/// Update the state.
fn update_state(
current_state: &mut State,
next_state: std::result::Result<State, tokio::task::JoinError>,
) {
match next_state {
Ok(next) => {
*current_state = next;
}
_ => {
*current_state = State::Idle(None);
}
}
}
#[cfg(not(feature = "tokio"))]
/// Update the state.
fn update_state(current_state: &mut State, next_state: State) {
*current_state = next_state;
}

When both tokio-runtime and async-std features are disabled:

  • State is not defined due to the #[cfg(any(...))] gate
  • update_state is still defined (#[cfg(not(feature = "tokio"))])
  • This results in a compilation error because State is undefined

Expected behavior

git-cliff-core should compile successfully with its current feature settings, even when both tokio-runtime and async-std features are disabled.

Additional context

orhun/git-cliff#1328

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions