Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot mock methods with inputs that refer to unimock's lifetime #12

Closed
audunhalland opened this issue Nov 27, 2022 · 2 comments
Closed
Labels
api-breaking Fixing this would break the API and requires a breaking release bug Something isn't working

Comments

@audunhalland
Copy link
Owner

audunhalland commented Nov 27, 2022

E.g. https://doc.rust-lang.org/std/io/trait.Read.html#method.read_vectored

@audunhalland audunhalland changed the title Cannot mock methods which refer to 'self in argument list Cannot mock methods with nested "inferred" lifetimes in input Nov 27, 2022
@audunhalland
Copy link
Owner Author

audunhalland commented Nov 27, 2022

In e.g.

    fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) {

The lifetime inside the IoSliceMut must outlive the lifetime of bufs. They have to be two different lifetimes.

In order to encode this, MockFn could have type Inputs<'i0, 'i1: 'i0>;. But as soon as it has this, it becomes quite hard to express a HRTB that type checks.

The HRTB must introduce two lifetimes with an outlives-relation between them. This is not supported. See Extended HRTB RFC proposal

@audunhalland audunhalland changed the title Cannot mock methods with nested "inferred" lifetimes in input Cannot mock methods with inputs that refer to unimock's lifetime Mar 24, 2023
@audunhalland
Copy link
Owner Author

Experimental branch: https://github.com/audunhalland/unimock/tree/unimock-input-lifetime

But ran into the "HRTB must outlive" issue:
rust-lang/rust#100013

@audunhalland audunhalland added bug Something isn't working api-breaking Fixing this would break the API and requires a breaking release labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-breaking Fixing this would break the API and requires a breaking release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant