Failing to find a module [SOLVED]

I am just trying to create my first module.
File system structure:

src :

contents of
pub mod client;

contets of
fn connect () {}

and contents of

extern crate communicator;

fn main() {

and when I am trying to build project with "cargo build" I get this error:

error[E0433]: failed to resolve. Could not find client in communicator
--> src/
4 | communicator::client::connect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find client in communicator

error: aborting due to previous error

error: Could not compile communicator.

Caused by:
process didn't exit successfully: rustc --crate-name communicator src/ --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=8bad32256e86bfcc -C extra-filename=-8bad32256e86bfcc --out-dir /home/alireza/Src/communicator/target/debug/deps -L dependency=/home/alireza/Src/communicator/target/debug/deps --extern communicator=/home/alireza/Src/communicator/target/debug/deps/libcommunicator-dfc3c2e1752e1b41.rlib (exit code: 101)

What am I doing wrong?

Are you building with Cargo or are you using rustc directly?

1 Like

I am compiling with cargo build command

This needs to be pub fn.

1 Like

still no luck.still the same error.

What content of your Cargo.toml file?

name = "communicator"
version = "0.1.0"
authors = ["Alireza"]



I can not able to reproduce your problem,
can you post archive with your code somewhere?

Right now I am too afraid of it being a silly problem!
but here :


To fix compilation you just need remove #[cfg(test)] from here:


pub mod client;

because of with #[cfg(test)] at the top of pub mod client, you client
module compiles only if build tests via cargo test