-
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: Spelling and language
- Loading branch information
commit 70732661ab14212bf163de1b5f1795fac976c4f8
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 don't think a
priority
attributes really solves the issue here. This puts a lot of burden on the user. Users will have to know how lint levels are resolved in rustc and why this is even necessary.Figuring this part out is the biggest blocker of this RFC IMO.
I think a solution here would be to handle lints in the order:
Taking the example below:
-Aclippy::all -Wclippy::doc_markdown
-D future-incompatible -A semicolon_in_expressions_from_macros
This would look like (using my preferred syntax):
Which would then become
I'm not 100% sure if this ordering will work out though. Maybe there are still edge cases with overlapping groups 🤔
Now,
cargo
doesn't know the difference between a group and a lint. However,rustc
does know the difference and can order them according to this specification. But this would probably mean, that new CLI flags inrustc
have to be introduced to pass lints that were defined in theCargo.toml
. The question is, if we want this.I generally think, that lint level configuration should be as easy as possible without any surprises. Lint levels shouldn't be a complicated construct you have to learn about to do it right. Things like the
priority
field over complicates this IMO.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.
Yeah I suggested this in #3389 (comment) as well
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 the "in the order they are specified" model is useful for when lint levels are being specified in multiple places. But I think it might be fine to do it just for CLI flags.
Strawman proposal:
rustc
gains asort-lint-cli-flags
arg that Cargo passes in, which perhaps becomes the default mode in the next edition.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.
Does the
warnings
meta-group complicate this at all? (AFAICT with some quick testing of-Dwarnings
behavior it ignores flag order).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.
It's not actually a lint group; it turns all warnings into errors, including non-lint warnings
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.
Is using order for priority an option¹? As in, it's just an object with name to level mapping, but the order inside the TOML determines what overrides.
That is how many CLIs work: if you pass
--no-foo --foo
,foo
is on, for--foo, --no-foo
it's off.¹ easy to maintain in deserialization w/
IndexMap
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.
Highly unlikely, but not impossible. Also other tools (rustc) already do this or will do this.
Agreed
I'm a bit confused: If we can detect conflicts in priority groups and warn about them, shouldn't it then be also possible to resolve those conflicts? Is resolving this always possible automagically? I think having
priority
in the MVP will give us time to figure those things outAgreed
I hate everything about this 😅 : This is just not useable. It's all the bad parts from the
lint = "level"
and thelevel = [lint]
syntaxes combined IMO.is maybe an option, but if we punt this to the user, I think
priority
is the better approach.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.
By making the reference to
IndexMap
, I assume you are meaning the order within a table? The cargo team ruled that out because (1) order for keys is not defined in the TOML spec and we don't want to rely on an extension of the TOML spec and (2) this doesn't communicate semantics to the user/tool and they could easily do things incorrectly, e.g. sorting the table.Option 4 tries to instead explore ordering within TOML syntax and semantics.
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.
We could except for when groups intersect. Framed differently, its the auto-sort solution but punts to the user instead of using a heuristic, with an MVP that always punts to the user.
Something I forgot to include in discussing is going past the MVP is the cargo/linter contract and acknowledging the parallel work for registering custom lints. I've not followed that too closely. Depending on how likely that is to be completed and what options are possibilities, each of these proposals could have a limiting factor on the other.
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've updated the RFC to reflect Option 2 (
priority
with warnings/auto-sort in the future).