-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
mformat: sort files()
arguments naturally
#15005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Independent from this, you need to keep the first Rust file the same or, even better, move it first. |
Hmm? This PR doesn't touch anything Rust-related. |
Yes, it is an independent bug. The problem is that the first file is special for Rust, and typically in the top directory, so if you put subdirectories first you change the semantics (unlike C). |
If the project needs a specific file order, it can still do something like sources = files('main.rs')
sources += files(
'subdir/a.rs',
'subdir/b.rs',
) or executable(
'main',
'main.rs',
files(
'subdir/a.rs',
'subdir/b.rs',
)
) and the formatter won't interfere with that. There are any number of programs that might receive lists of files and have opinions about the file order, and I don't think the formatter should start carrying special cases for those. |
If the formatter can change the semantics of the |
It already could, though. There's no guarantee that the desired "first Rust file" sorts first under the current sort order, and In other words, this PR doesn't change anything fundamental about how the formatter works. It just fixes the sort order to bring the formatter in line with the Meson style guide and the existing behavior of the rewriter (added in #5010 for 0.50). |
I assume you mean the hardcoded values "main.rs" / "lib.rs" and no other? Or... ? |
main.rs and lib.rs are just Cargo defaults (and they don't apply to tests/ and examples/, which treat all files in the directory as main files). ninjabackend.py passes the first .rs file to rustc. |
So then if the first file isn't first, then I suppose it is doable to simply exclude the first element from sorting, i.e.
but ... how does
? |
It's not a regression so this PR is fine. But it could be a future improvement. By "move it first" I mean move the first Rust source even before e.g. |
The other thing is that the sources for a target may be built from any number of |
Fixes #14997.