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

Fix some visibility issues with mocking modules and foreign functions: #133

Merged
merged 1 commit into from
May 24, 2020

Conversation

asomers
Copy link
Owner

@asomers asomers commented May 24, 2020

  • When mocking foreign functions, the 'foreign ""' block is not a
    module, and should not introduce an extra layer of visibility
    modifications.

  • The visibility of the Expectation must always match the levels
    argument of Expectation::new().

  • When mocking modules, the argument and return types of mocked
    functions must be superfied by one level. Otherwise code like this
    wouldn't compile:

    struct SuperT;
    
    #[automock]
    pub mod m {
        fn foo(x: super::SuperT) -> super::SuperT;
    }

* When mocking foreign functions, the 'foreign "<ABI>"' block is not a
  module, and should not introduce an extra layer of visibility
  modifications.

* The visibility of the Expectation must always match the levels
  argument of Expectation::new().

* When foreign functions, the argument and return types of mocked
  functions must be superfied by one level.  Otherwise code like this
  wouldn't compile:
  ```rust
  struct SuperT;

  #[automock]
  extern "Rust" {
      fn foo(x: super::SuperT) -> super::SuperT;
  }
  ```
@asomers asomers merged commit 32f3407 into master May 24, 2020
@asomers asomers deleted the foreign_nonpub branch May 24, 2020 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant