Skip to content

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

Merged
asomers merged 1 commit intomasterfrom
foreign_nonpub
May 24, 2020
Merged

Fix some visibility issues with mocking modules and foreign functions:#133
asomers merged 1 commit intomasterfrom
foreign_nonpub

Conversation

@asomers
Copy link
Copy Markdown
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.

1 participant