Messages in this thread |  | | From | Miguel Ojeda <> | | Date | Wed, 18 Mar 2026 15:21:33 +0100 | | Subject | Re: [PATCH v13 1/1] rust: interop: Add list module for C linked list interface |
| |
On Wed, Mar 18, 2026 at 11:54 AM Alexandre Courbot <acourbot@nvidia.com> wrote: > > Ah, so there is a rationale for using a `mod.rs` file after all. What > are the project-wide guidelines re: `foo.rs` vs `foo/mod.rs`?
Quoting myself from a few years ago:
I don't have a strong opinion either way -- this was originally done to improve fuzzy searching, see commit 829c2df153d7 ("rust: move `net` and `sync` modules to uniquely-named files") upstream:
This is so that each file in the module has a unique name instead of the generic `mod.rs` name. It makes it easier to open files when using fuzzy finders like `fzf` once names are unique.
Another reason was that it is what upstream Rust recommends:
"Prior to rustc 1.30, using `mod.rs` files was the way to load a module with nested children. It is encouraged to use the new naming convention as it is more consistent, and avoids having many files named mod.rs within a project."
https://doc.rust-lang.org/reference/items/modules.html#r-items.mod.outlined.search-mod https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html#no-more-modrs
Now, several other people have argued for the other way over the years.
For instance, one reason is that tab completion can be smoother with `mod.rs`, e.g. every time you complete something like `rust/kernel/sync`, you have to decide whether you want `sync.rs` or `sync/`, and then if you wanted the folder, you have to tab-complete again.
So I guess it depends if you use more the shell TAB (like Linus really values on the C folders) or the fuzzy finder (like Wedson argued for in the commit referenced above).
I personally don't want to bias it one way or the other [*], but please let's avoid having both mixed if possible (unless there is a reason not to). I can put the result in the new guidelines rules list file.
I hope that gives some context!
[*] I would have preferred a middle ground like modules being inside but repeating the folder name, e.g. `.../pci/pci.rs`, but I doubt that will ever be supported upstream since one probably wants to support the other ways at the same time.
Cheers, Miguel
|  |