Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/69191.rs: fixed with no errors #303

Merged
merged 1 commit into from
Mar 7, 2020
Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Mar 7, 2020

Issue: rust-lang/rust#69191

pub enum Void {}

pub trait Machine: Sized {
    type Seed: Sized;
    fn create(seed: Self::Seed) -> Response<Self, ()>;
}

pub struct Response<M, N>(std::marker::PhantomData<(M, N)>);
pub struct MyHandler<M>(std::marker::PhantomData<M>);
pub struct Loop<M>(std::marker::PhantomData<M>);

impl<M: Machine> Loop<M> {
    pub fn new() -> Self {
        unimplemented!()
    }

    pub fn add_machine_with<F>(&self, _fun: F)
    where
        F: FnOnce() -> Response<M, Void>,
    {
        unimplemented!()
    }

    pub fn run(self) {
        let handler = MyHandler::<M>::new();
        handler.timeout();
    }
}

impl<M: Machine> MyHandler<M> {
    pub fn new() -> Self {
        unimplemented!()
    }
    fn timeout(self) {
        let creator = None;
        let new = Some(creator.unwrap());
        M::create(new.unwrap());
    }
}

impl<M: Sized, N: Sized> Response<M, N> {
    pub fn map<T, U, S, R>(self, _: S, _: R) -> Response<T, U>
    where
        S: FnOnce(M) -> T,
    {
        unimplemented!()
    }
    pub fn wrap<T, S>(self, _: S) -> Response<T, N>
    where
        S: FnOnce(M) -> T,
    {
        unimplemented!()
    }
}

enum Tcp {}

enum Composed {
    Tcp(Tcp),
}
enum CSeed {
    Tcp(Void),
}

impl Machine for Composed {
    type Seed = CSeed;
    fn create(seed: CSeed) -> Response<Self, ()> {
        match seed {
            CSeed::Tcp(_x) => unimplemented!(),
        }
    }
}

impl Tcp {
    fn new() -> Response<Tcp, Void> {
        unimplemented!()
    }
}

impl Machine for Tcp {
    type Seed = Void;
    fn create(_seed: Void) -> Response<Self, ()> {
        unimplemented!()
    }
}

fn main() {
    let loop_creator = Loop::new();
    loop_creator.add_machine_with(|| Tcp::new().wrap(Composed::Tcp));
    loop_creator.run();
}
=== stdout ===
=== stderr ===
warning: variant is never constructed: `Tcp`
  --> /home/runner/work/glacier/glacier/ices/69191.rs:62:5
   |
62 |     Tcp(Void),
   |     ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

==============

=== stdout ===
=== stderr ===
warning: variant is never constructed: `Tcp`
  --> /home/runner/work/glacier/glacier/ices/69191.rs:62:5
   |
62 |     Tcp(Void),
   |     ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

==============
@Alexendoo Alexendoo merged commit 48b0c1d into master Mar 7, 2020
@Alexendoo Alexendoo deleted the autofix/ices/69191.rs branch March 7, 2020 12:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants