Skip to content

Conversation

@aliceinwire
Copy link

clippy error: if you would like to reborrow, try removing &*: self

Signed-off-by: Alice Ferrazzi [email protected]
Reviewed-by: Luca Barbato [email protected]

clippy error: if you would like to reborrow, try removing `&*`: `self`

Signed-off-by: Alice Ferrazzi <[email protected]>
Reviewed-by: Luca Barbato <[email protected]>
// the work without it having the chance to run, so we need to explicitly destroy this
// reference (which would have happened in `work_func` if it did run).
unsafe { Ref::from_raw(&*self) };
unsafe { Ref::from_raw(self) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but I think this is actually wrong. Work is not the thing put in a Ref, but the type containing Work. As such self should be value containing Work. Could you please take a look @wedsonaf?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, we need to do the same pointer arithmetic we do in work_func below to get to the right ptr.

Nice catch, @bjorn3

Now we don't have the type here anymore, so we either need to make Work generic or just store the offset is some field.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to change the function signature to fn cancel<A: WorkAdapter>(obj: Ref<A::Target>) I think.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that would be unsafe. Users could use the wrong adapter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, sorry, I see now that it's passing the outer object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants