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

Add a [lints] table to Cargo.toml #3389

Merged
merged 64 commits into from
May 9, 2023
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 Feb 14, 2023
28f51c3
feat: Start manifest-lint RFC
epage Feb 14, 2023
6ac518e
fix: Remove stray paren
epage Feb 14, 2023
aa8695b
fix: Pluralize the table
epage Feb 14, 2023
680fe11
fix: Make lints table top-level
epage Feb 14, 2023
054de51
fix: Call out workspace lint name reservation
epage Feb 14, 2023
3796056
fix: Link to user-defined attribute RFC
epage Feb 14, 2023
cfbd231
feat: Add a couple more brainstorming ideas
epage Feb 15, 2023
c57a510
fix: Use correct --forbid syntax
epage Feb 15, 2023
42010e8
fix: Apply ehuss' feedback
epage Feb 15, 2023
b79b792
fix: Add RFC number
epage Feb 15, 2023
4f4107f
fix: Link out to rubocop
epage Feb 15, 2023
bf6d9fc
fix: Typos
epage Feb 15, 2023
d136690
fix: Include cargo-cranky as prior art
epage Feb 15, 2023
75198c2
fix: Typo
epage Feb 15, 2023
4a267a6
fix: Be more explicit on workspace inheritance
epage Feb 15, 2023
c726cf3
feat: Add external file possibility
epage Feb 15, 2023
508e92f
feat: Add cargo lints as a future possibility
epage Feb 15, 2023
1c7ef77
fix: Note that cargo-metadata support is needed for configurable lints
epage Feb 15, 2023
4bfc545
fix: Update to lints.tool.lint
epage Feb 15, 2023
f8071a3
feat: Add open question about rustfmt
epage Feb 15, 2023
1e43928
fix: Discuss all supported lint tools
epage Feb 17, 2023
3cd6125
fix: Update for latest conversation
epage Feb 21, 2023
b02771a
fix: Typo
epage Feb 21, 2023
5a70d45
feat: Take a stab at lint precedence
epage Feb 21, 2023
08f7190
fix: Make priority signed, giving a clear center value
epage Feb 22, 2023
7d81bf1
fix: Add another reason against 'rules'
epage Feb 22, 2023
31c9587
fix: Some TOML formatting
epage Feb 22, 2023
cf9a148
fix: Clarify we are overriding lint groups
epage Feb 23, 2023
1adde1b
fix: Typo
epage Feb 23, 2023
78083ed
fix: Document future idea for lint-level source
epage Feb 23, 2023
72cdd44
fix: Typos
epage Feb 23, 2023
7073266
fix: Spelling and language
epage Feb 27, 2023
86b0b64
fix: remindme priority with multiple lint sources
epage Feb 27, 2023
a270d28
fix: Be explicit that lints does not affect dependencies
epage Feb 27, 2023
78ab70d
fix: Typo
epage Feb 27, 2023
cf93e59
fix: Expand on lint source future
epage Feb 28, 2023
e92a52b
fix: Isolate array precedence
epage Mar 7, 2023
ef224ec
fix: Document 'auto-priority' alternative
epage Mar 7, 2023
ef4a490
fix: Add missing namespacing of rust lints
epage Mar 18, 2023
86932bd
fix: Call out rust/rustc category confusion
epage Mar 24, 2023
5afa0cf
fix: Be more explicit in how the lints table is loaded
epage Mar 24, 2023
a54d985
fix: Clarified this isn't limited to rustc/clippy
epage Mar 24, 2023
de44058
fix: Explicitly call out why rust table exists'
epage Mar 24, 2023
1557767
fix: Clarify I meant lint levels, not general lint configuration
epage Mar 24, 2023
e1230cd
fix: Clarify clippy.toml isn't going away yet
epage Mar 24, 2023
2f5f873
fix: Add clarification that an example is only an example
epage Mar 24, 2023
3543967
fix: Be explicit that lint configuration is a future possibility
epage Mar 24, 2023
45766c4
fix: Update now that we have confirmation on ruff's design choice
epage Mar 29, 2023
fbf6f48
fix: Expand on why not `::` but separate tables
epage Mar 30, 2023
935593f
fix: Expand more on why not level=lint
epage Mar 30, 2023
c3f932c
fix: Remove confusion over :: and tool-config
epage Mar 31, 2023
e73e6b9
fix: Add auto-sort as a future possibility
epage Apr 10, 2023
d32801b
fix: Add high-level guidance
epage Apr 10, 2023
330782a
refactor: Break up Rationale / Alts into smaller sections
epage Apr 10, 2023
9cbc977
fix: Rewrite :: section
epage Apr 10, 2023
2f1b799
fix: Typos
epage Apr 10, 2023
660bcdb
fix: Expand the schema section
epage Apr 10, 2023
28f14ef
fix: Expand on precedence options
epage Apr 10, 2023
51f4984
fix: Move some discussion to stablization
epage Apr 18, 2023
2b10a5e
fix: Be more precise when talking about disjoint groups
epage Apr 19, 2023
4cb8421
fix: Clarify dependency situation
epage Apr 27, 2023
a47520f
fix: Call out reducing rebuilds for filtering lints
epage Apr 27, 2023
7aab0bd
Add tracking issue.
ehuss May 9, 2023
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
Prev Previous commit
Next Next commit
fix: Be explicit that lint configuration is a future possibility
  • Loading branch information
epage committed Mar 24, 2023
commit 354396739f69e10a01916d620990dc5ae6e1c57e
5 changes: 3 additions & 2 deletions text/3389-manifest-lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,9 @@ plans for clippy itself.
Currently, it is a hard error to mix `workspace = true` and lints. We could
open this up in the future for the package to override lints from the
workspace. This would not be a breaking change as we'd be changing an error
case into a working case. We'd need to ensure we had a path forward for the
semantics for configurable lints.
case into a working case. We should consider the possibility of adding
configurable lints in the future and what that would look like with
overridin of lints.

## Extending the syntax to `.cargo/config.toml`
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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 over Cargo.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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

Copy link
Contributor

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.

Choose a reason for hiding this comment

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

We will still be fingerprinting [lints] and causing rebuilds

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 and Cargo.toml is [profile], and in its case the config.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 the config.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 other config.toml keys.

Maybe there should be a cargo command-line flag which would control whether Cargo.toml or config.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.

Copy link
Contributor Author

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.

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.

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.

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] in Cargo.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.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you say "rebuilding", do you mean rebuilding the workspace crates or all dependencies?

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.


Expand Down