I want to be able to use the file relations.rs from within both simulation_ac.rs and simgpp_ac.rs.
So, when I put in the line use super::relations::*; in simgpp_ac.rs everything works fine. When I put in the line use super::relations::*; in simulation_ac.rs, I get this error:
error[E0433]: failed to resolve: there are too many leading `super` keywords
--> src/algorithms/simulation_ac.rs:6:5
|
6 | use super::relations::*;
| ^^^^^ there are too many leading `super` keywords
The error “there are too many leading super keywords” suggests that something, somewhere, is trying to compile simulation_ac.rs as the root file of a crate (because that's the only situation I know of where no super module exists).
Can you show us your Cargo.toml? If it has any path = "src/algorithms/simulation_ac.rs" in it, this would explain that error.
There is some assymetry between the simulation_ac.rs and the simgpp_ac.rs file indeed. There is a binary linked to one, but not another.
I have the Cargo.toml file here:
[package]
name = "reduction_code"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.5"
chrono = "0.4.22" # for display .svg files timestamps
pest = "2.4.0" # For parsing Timbuk format
pest_derive = "2.4.0" # For parsing Timbuk format
[[bin]]
name = "main"
path = "src/bin/main.rs"
[[bin]]
name = "hopcroft-bench"
path = "src/algorithms/hopcroft_ac.rs"
[[bin]]
name = "simpreorder-bench"
path = "src/algorithms/simulation_ac.rs"
Yes, this is the problem. In general, you should not use one source file for two different crates (here your library and a binary). They will be compiled with different surrounding items, and it will be hard to get a successful and warning-free compilation. In this case, not only is super not valid, the item you were actually trying to access, relations, doesn't actually exist at all when compiling the binary.
Instead, write a separate file for the binary (preferably at the auto-discovery pathsrc/bin/simpreorder-bench.rs and now you don't need any path) and have it access the items from the library (use reduction_code::algorithms::simulation_ac;).
As a general rule: if you are doing something that seems to require specifying a path = "..." to a source file, in either Cargo.toml or in your source code's mods, then you may be making a mistake.