Skip to content
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

move modules from kebab-case to snake_case #14439

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/doc/src/guide/project-layout.md
Copy link
Member

@weihanglo weihanglo Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reply to #14439 (comment):

Are cargo targets a cargo concept?

Yes. See https://doc.rust-lang.org/nightly/cargo/reference/cargo-targets.html.

If so can we define the naming convention somewhere here in the cargo docs that says those targets should be kebab-case?

What's the benefit of it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is without a codified standard its hard to enforce. So people will start drifting and you will end up with multiple groups doing different things. If it becomes part of the docs then its easier to PR lints into Clippy in order to enable automatic enforcement for projects and makes the ecosystem easier and more coherent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for explaining that :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it becomes part of the docs then its easier to PR lints into Clippy in order to enable automatic enforcement for projects and makes the ecosystem easier and more coherent.

I suspect this lint should live in cargo, not clippy.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. However we still need to spell out the rule in some docs first and I think this is the place for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this is the place for it.

Also, even better than documenting this is to lint for it. If we have specific naming recommendations, we can use #12235 (unstable implementation is in place) to lint for naming like rustc does for functions, structs, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, even better than documenting this is to lint for it.

100% agree. However you end up in a chicken and egg problem. If I propose a semantic lint like this with no docs to support it, then I will end up with a really hard time getting it merged. So its just a first step here to remove an ambiguous situation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So where specifically should I try to put this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ Cargo [package][def-package]:
│   ├── lib.rs
│   ├── main.rs
│   └── bin/
│ ├── named-executable.rs
│      ├── another-executable.rs
│      └── multi-file-executable/
│ ├── named_executable.rs
│      ├── another_executable.rs
│      └── multi_file_executable/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would have end-user affects, making the default binary names use _ when the status quo is for binaries to use -.

As these are not just mod names but build target names, i would be inclined to leave all of these as -

│      ├── main.rs
│      └── some_module.rs
├── benches/
│   ├── large-input.rs
│   └── multi-file-bench/
│   ├── large_input.rs
│   └── multi_file_bench/
│   ├── main.rs
│   └── bench_module.rs
├── examples/
│   ├── simple.rs
│   └── multi-file-example/
│   └── multi_file_example/
│   ├── main.rs
│   └── ex_module.rs
└── tests/
├── some-integration-tests.rs
└── multi-file-test/
├── some_integration_tests.rs
└── multi_file_test/
├── main.rs
└── test_module.rs
```
Expand Down