error[E0433] for folder + files in folder

Hello,

I moved a bunch of files around in my project earlier, and now it's broken.

I fixed up my imports (almost) with the exception of these two:

Here is my folder structure:
image

I don't get it, both of these folders are on the same level in the src folder, shouldn't rust be able to see them? I do have a mod.rs file in both for the components in each folder as well.

I know I'm missing something simple, but I don't see it.

Can someone help?

Thanks!

First, I'm going to assume you're using edition 2018. You can look for edition = "2018" in Cargo.toml to be sure. The module pathing was updated across editions and you may need to change some things or try rustfix if you're updating code from one edition to the another. Most but probably not all of what follows applies to both currently existing editions.

Next, I see a src/mod.rs. As far as I know, nothing looks for that file automatically. You almost certainly meant src/lib.rs. The first thing I would try is renaming that file.

After that, note that aside from src/lib.rs and src/main.rs, cargo and rust don't look for files that just happen to be in src. Instead you have to declare modules in the files it's already looking in. So it's possible that you're missing some statements like mod nnet_auto_optimization; in (what will presumably soon be renamed to) lib.rs. Once you have a lib.rs, if you're still getting those errors, this is the next thing I would check.

Furthermore, you don't need src/submodule/mod.rs anymore, you can use src/submodule.rs instead. But you can still use src/submodule/mod.rs if you prefer, so this shouldn't be a source of any of your problems.

Taken altogether, I would expect something like

  • lib.rs -- declares mod nnet_auto_optimization and mod testing_config
  • nnet_auto_optimization.rs -- declares mod optimize_nnet and mod optimizer_parameters
    • nnet_auto_optimization/optimize_nnet.rs
    • nnet_auto_optimization/optimizer_parameters.rs
  • testing_config.rs -- declares mod test_config
    • testing_config/test_config.rs

One thing I notice immediately is that you have a mod.rs file directly in src. Normally you wouldn't have that because the main.rs has that role in the top-level folder.

True,

I did delete that after I took that screenshot. I should have retaken the screenshot after I deleted it.