Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

refactor Clique and StepService  #10648

Closed
@niklasad1

Description

@niklasad1

The issue is the following here

warning[E0382]: assign to part of moved value: `engine`
   --> ethcore/src/engines/clique/mod.rs:204:4
    |
190 |         let mut engine = Clique {
    |             ---------- move occurs because `engine` has type `engines::clique::Clique`, which does not implement the `Copy` trait
...
201 |         let res = Arc::new(engine);
    |                            ------ value moved here
...
204 |             engine.step_service = Some(StepService::start(Arc::downgrade(&res) as Weak<Engine<_>>));
    |             ^^^^^^^^^^^^^^^^^^^ value partially assigned here after move
    = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
    = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future

To elaborate a bit, basically we mutate an already value moved into the Arc and this should not compile IMHO.

So, I would suggest to move the StepService into Clique instead because it is not safe/possible to mutate an Arc when it is aliased (i.e, more than 1 is pointing to it)

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions