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

Trouble resolving super:: in mock methods's signatures #8

Closed
asomers opened this issue Jul 28, 2019 · 0 comments
Closed

Trouble resolving super:: in mock methods's signatures #8

asomers opened this issue Jul 28, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@asomers
Copy link
Owner

asomers commented Jul 28, 2019

It's perfect valid for super:: to be part of a type in a method's signature. But Mockall has trouble resolving it, probably because of some of the internally created modules. For example, using automock:

use mockall::*;

#[allow(unused)]
mod outer {
    struct SuperT();

    mod inner {
        use super::super::automock;

        pub(crate) struct PubCrateT();
        struct PrivT();

        pub struct Foo();
        #[automock]
        impl Foo {
            pub(crate) fn foo(&self) -> PubCrateT { unimplemented!() }
            fn bar(&self) -> PrivT { unimplemented!() }
            pub(in crate::outer) fn baz(&self) -> super::SuperT {
                unimplemented!()
            }
            pub(in super) fn bang(&self) -> super::SuperT { unimplemented!() }
        }
    }
}

or using mock!

use mockall::*;

#[allow(unused)]
mod outer {
    struct SuperT();

    mod inner {
        use super::super::mock;

        pub(crate) struct PubCrateT();
        struct PrivT();

        mock! {
            Foo {
                fn foo(&self) -> PubCrateT;
                fn bar(&self) -> PrivT;
                fn baz(&self) -> super::SuperT;
                fn bang(&self) -> super::SuperT;
            }
        }
    }
}

These yield compile errors like the following:

error[E0412]: cannot find type `SuperT` in module `super`
  --> mockall/tests/mock_nonpub.rs:21:41
   |
21 |                 fn baz(&self) -> super::SuperT;
   |                                         ^^^^^^ not found in `super`

error[E0412]: cannot find type `SuperT` in module `super`
  --> mockall/tests/mock_nonpub.rs:22:42
   |
22 |                 fn bang(&self) -> super::SuperT;
   |                                          ^^^^^^ not found in `super`

error: aborting due to 2 previous errors
@asomers asomers added the bug Something isn't working label Jul 28, 2019
@asomers asomers closed this as completed in 697d341 Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant