-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a [lints]
table to Cargo.toml
#3389
Merged
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
b80c2ff
chore: Start manifest-lint RFC
epage 28f51c3
feat: Start manifest-lint RFC
epage 6ac518e
fix: Remove stray paren
epage aa8695b
fix: Pluralize the table
epage 680fe11
fix: Make lints table top-level
epage 054de51
fix: Call out workspace lint name reservation
epage 3796056
fix: Link to user-defined attribute RFC
epage cfbd231
feat: Add a couple more brainstorming ideas
epage c57a510
fix: Use correct --forbid syntax
epage 42010e8
fix: Apply ehuss' feedback
epage b79b792
fix: Add RFC number
epage 4f4107f
fix: Link out to rubocop
epage bf6d9fc
fix: Typos
epage d136690
fix: Include cargo-cranky as prior art
epage 75198c2
fix: Typo
epage 4a267a6
fix: Be more explicit on workspace inheritance
epage c726cf3
feat: Add external file possibility
epage 508e92f
feat: Add cargo lints as a future possibility
epage 1c7ef77
fix: Note that cargo-metadata support is needed for configurable lints
epage 4bfc545
fix: Update to lints.tool.lint
epage f8071a3
feat: Add open question about rustfmt
epage 1e43928
fix: Discuss all supported lint tools
epage 3cd6125
fix: Update for latest conversation
epage b02771a
fix: Typo
epage 5a70d45
feat: Take a stab at lint precedence
epage 08f7190
fix: Make priority signed, giving a clear center value
epage 7d81bf1
fix: Add another reason against 'rules'
epage 31c9587
fix: Some TOML formatting
epage cf9a148
fix: Clarify we are overriding lint groups
epage 1adde1b
fix: Typo
epage 78083ed
fix: Document future idea for lint-level source
epage 72cdd44
fix: Typos
epage 7073266
fix: Spelling and language
epage 86b0b64
fix: remindme priority with multiple lint sources
epage a270d28
fix: Be explicit that lints does not affect dependencies
epage 78ab70d
fix: Typo
epage cf93e59
fix: Expand on lint source future
epage e92a52b
fix: Isolate array precedence
epage ef224ec
fix: Document 'auto-priority' alternative
epage ef4a490
fix: Add missing namespacing of rust lints
epage 86932bd
fix: Call out rust/rustc category confusion
epage 5afa0cf
fix: Be more explicit in how the lints table is loaded
epage a54d985
fix: Clarified this isn't limited to rustc/clippy
epage de44058
fix: Explicitly call out why rust table exists'
epage 1557767
fix: Clarify I meant lint levels, not general lint configuration
epage e1230cd
fix: Clarify clippy.toml isn't going away yet
epage 2f5f873
fix: Add clarification that an example is only an example
epage 3543967
fix: Be explicit that lint configuration is a future possibility
epage 45766c4
fix: Update now that we have confirmation on ruff's design choice
epage fbf6f48
fix: Expand on why not `::` but separate tables
epage 935593f
fix: Expand more on why not level=lint
epage c3f932c
fix: Remove confusion over :: and tool-config
epage e73e6b9
fix: Add auto-sort as a future possibility
epage d32801b
fix: Add high-level guidance
epage 330782a
refactor: Break up Rationale / Alts into smaller sections
epage 9cbc977
fix: Rewrite :: section
epage 2f1b799
fix: Typos
epage 660bcdb
fix: Expand the schema section
epage 28f14ef
fix: Expand on precedence options
epage 51f4984
fix: Move some discussion to stablization
epage 2b10a5e
fix: Be more precise when talking about disjoint groups
epage 4cb8421
fix: Clarify dependency situation
epage a47520f
fix: Call out reducing rebuilds for filtering lints
epage 7aab0bd
Add tracking issue.
ehuss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Be explicit that lint configuration is a future possibility
- Loading branch information
commit 354396739f69e10a01916d620990dc5ae6e1c57e
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think this is probably necessary for this RFC to make sense. I feel this makes more sense in the local (potentially-but-not-necessarily checked-in) config as opposed to the crate config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though with workspace inheritance perhaps it's not that necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify why you feel it makes more sense to put this in
.cargo/config.toml
overCargo.toml
?In starting this with
Cargo.toml
, I'm looking to address the existing problems with doing this via rustflags in.cargo/config.toml
(project configuration being directory dependent). EmbarkStudios/rust-ecosystem#59 is a good example of people using both source code and.cargo/config.toml
for lints that are project-specific and would benefit from this. This was also spurred by the cargo team itself wanting to use this feature.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to allow it in both.
The reason being that there are multiple lint workflows: sometimes you lint in CI and want everyone to follow the same lint set. However, some people may wish to opt in to additional lints locally for their own code, and being able to set that is useful.
But I'm fine with starting out in Cargo.toml at least. I would prefer to try and solve it for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The part I'm missing is why users can't just use rustflags for this in the short term? In the long term, if we add configurable lints, there isn't an alternative and I can see it becoming a higher priority then. This is the main reason I put it as a future possibility, rather than including it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you are cross-compiling, there is no way to set rustflags via
.config/cargo.toml
that applies to everything (built for host or built for target), so even just for having something that works across proc-macros and normal crates within a workspace, this would be great.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Lints don't affect the compiled binaries. It seems like pure overhead to me.
While I'd want to be able to set lints globally (for every project on my computer), there is a design issue of config priority which is unclear to me. Currently afaik the only option duplicated in both
config.toml
andCargo.toml
is[profile]
, and in its case theconfig.toml
has priority. In particular, a[profile]
section in$HOME/.cargo/config.toml
would override the[profile]
in any other Cargo project.That may be reasonable for
[profile]
, but would likely be incorrect for lints. Most of the time I'd want to use the lints from the specific project I work on, with theconfig.toml
defaults (particularly defined in non-project directories) used only occasionally. So the correct priority looks like$WORKSPACE/.cargo/config.toml
>$WORKSPACE/subcrate/Cargo.toml
>$WORKSPACE/Cargo.toml
>$UPPER_DIR/.cargo/config.toml
. This looks a bit convoluted and inconsistent with the behaviour of otherconfig.toml
keys.Maybe there should be a cargo command-line flag which would control whether
Cargo.toml
orconfig.toml
lint settings should be used?Actually, if
cargo build/run/test
would have flags to set lint levels per invocation, that would be sufficient. That would also avoid the question of config priorities.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user adds additional lints and run
cargo check
, they would expect to see the result of those lints. This would only be possible by rebuilding which will require finger printing.For now, I am leaving
[lints]
for.cargo/config.toml
as a future possibility rather than removing it or making it required to move this proposal along. Keeping it as a future possibility has no cost. Adding it into the proposal has a larger cost, in design, decision making, and implementation. It would require a very strong motivation to block incremental improvement ([lints]
inCargo.toml
) on getting a full solution (e.g. including[lints]
in.cargo/config.toml
).With that context, maybe we can temper how much design work we put into the feature or how much we debate whether we should or shouldn't do it in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I wouldn't want future extensions to block this long-waited feature either.
When you say "rebuilding", do you mean rebuilding the workspace crates or all dependencies? I am most concerned about the latter, even though for large projects there could be no difference. I am not familiar with the inner details of
cargo check
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebuilding the package when its
[lints]
table changes and not its dependencies.When writing up my previous message, I realized this was ambiguous in the RFC and I have since clarified it.