Browse Source

Add workaround for tokio-rs/tokio#5502

master
Adrian Heine 1 year ago
parent
commit
f27e981259
  1. 27
      src/setup/core.rs
  2. 2
      src/setup/mod.rs
  3. 16
      src/setup/setup.rs

27
src/setup/core.rs

@ -20,6 +20,17 @@ pub trait AddGeneric<X: ToArtifact> {
}
macro_rules! add_generic {
// Workaround for https://github.com/tokio-rs/tokio/issues/5502
() => (
#[async_trait(?Send)]
impl<SR, L, B, Rs, As> AddGeneric<()> for Setup<SR, L, B, Rs, As>
{
async fn add_generic(&self, (): ()) -> Result<(StoringLogger, (), bool), (StoringLogger, Box<dyn Error>)>
{
Ok((StoringLogger::default(), (), false))
}
}
);
( $($name:ident)* ) => (
#[async_trait(?Send)]
#[allow(non_snake_case)]
@ -202,3 +213,19 @@ impl<SR: SymbolRunner, L, B> SymbolRunner for RegularSetupCore<SR, L, B> {
result
}
}
#[cfg(test)]
mod test {
use super::super::setup::Setup;
use super::AddGeneric;
use crate::async_utils::run;
use crate::DrySymbolRunner;
#[test]
fn empty() {
let setup: Setup<_, (), (), (), ()> = Setup::new(DrySymbolRunner);
run(async {
assert!(setup.add_generic(()).await.is_ok());
})
}
}

2
src/setup/mod.rs

@ -1,6 +1,6 @@
mod core;
mod util;
mod symbol_runner;
mod util;
pub use symbol_runner::{
DelayingSymbolRunner, DrySymbolRunner, InitializingSymbolRunner, ReportingSymbolRunner,
SymbolRunner,

16
src/setup/setup.rs

@ -27,6 +27,14 @@ struct SetupInner<CORE, Rs, As> {
#[derive(Debug)]
pub struct Setup<SR, L, B, Rs, As>(Rc<SetupInner<RegularSetupCore<SR, L, B>, Rs, As>>);
impl<SR, L, B, Rs, As> Setup<SR, L, B, Rs, As> {
pub fn new(symbol_runner: SR) -> Self {
Self(Rc::new(SetupInner {
core: RegularSetupCore::new(symbol_runner),
resources: RefCell::default(),
}))
}
}
impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static>
Setup<SR, L, B, Rs, As>
{
@ -111,13 +119,7 @@ impl<SR, LOG> SetupFacade<SR, LOG> {
impl<L, B, As, SR, LOG, Rs: Hash + Eq> SetupFacade<SR, LOG, L, B, Rs, As> {
pub fn new_with(symbol_runner: SR, logger: LOG) -> Self {
Self(
logger,
Setup(Rc::new(SetupInner {
core: RegularSetupCore::new(symbol_runner),
resources: RefCell::default(),
})),
)
Self(logger, Setup::new(symbol_runner))
}
}

Loading…
Cancel
Save