-
Notifications
You must be signed in to change notification settings - Fork 2k
Lint for source files being in subpackage/ rather than subpackage/src/, when workspace includes subpackage/Cargo.toml #16789
Copy link
Copy link
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
I finally discovered today, after extensive trial and error, and after consulting JetBrains Junie before finally noticing the answer in a Google Gemini response, that the reason RustRover was failing to load my benchmark package's dependencies from benches/Cargo.toml was that it was expecting their source code to be in benches/src/benchmarks.rs rather than benches/benchmarks.rs, which is where I had it.
Advantage
- Make it much easier to use all kinds of tools in multi-Cargo.toml workspaces.
- Eliminate guesswork about seemingly-likely solutions that don't work (e.g. moving the benchmarks' dependencies from
[dependencies]to[dev-dependencies].
Drawbacks
May need some exclusion rules to deal with Cargo.toml's that are specifically adapted to being siblings of the *.rs files in the directory tree rather than uncles via ./src.
Example
$ ls -r
Cargo.toml
benches
benches/
Cargo.toml
benchmarks.rsIn Cargo.toml:
[workspace]
members = [
".", # The main crate in the current directory
"benches", # The new benchmark-only crate
]In benches/Cargo.toml:
[[bench]]
name = "benchmarks"
path = "benchmarks.rs"Could be written as:
$ ls -r
Cargo.toml
benches
benches/
Cargo.toml
src
benches/src/
benchmarks.rsIn benches/Cargo.toml:
[[bench]]
name = "benchmarks"
path = "src/benchmarks.rs"
Comparison with existing lints
AFAICT no lints currently evaluate the directory structure of a workspace.
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints
Type
Fields
Give feedbackNo fields configured for issues without a type.