-
Notifications
You must be signed in to change notification settings - Fork 18
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 lints as .cargo/config.toml
section
#68
Conversation
@repi Thanks for this! We're test-driving this change in our own projects now, but have found one major deficiency: the change in Have you found a solution to this already or not even ran into it yet? |
Ouch just tested and we ran into the same problem, switching between We actually configure Rust Analyzer to use clippy instead, so didn't notice that, and then almost never then run This is what we have for configuring RA in VS Code: |
@repi Thanks, I wasn't even aware that we could get RA to use clippy instead - if it also gives us the clippy lints in addition to check warnings directly in-line that'd be awesome! We'll see if this works out for us - haven't checked if there are conflicts with |
Looks like For Rust Analyzer in VS Code one can set a different target directory for that and avoid it (which is good in general to be able to build on command-line same time as RA runs in the background. But don't know of any way to force just clippy by itself to use a different target directory to avoid this behavior. So looks like this entire approach may not work properly in practice and one have to continue to wait for a mechanism in Cargo to set the lints properly (been waiting for 2.5 years 😢 #59). I'm closing this for now as we wont' merge this as is without a proper workaround for debug builds being force rebuilt when switching between |
@repi I'm now successfully pingponging between |
ah interesting! thought rustc would fail with unknown parameters / lints if it saw the clippy ones. Will test on our side also |
Changing to this definitely seems to work in my local tests also for our codebase, yay! Will deploy it out for wider testing in our team. [build]
rustflags = [ big thanks @MarijnS95, was very close to giving up here again :) |
Switch to global build flag instead of cargo config flag
@MarijnS95 are you getting any Rust or Clippy lints to actually trigger with it as a |
@repi It's definitely triggering for us. Adding We're on Rust 1.55, latest stable. |
Also on Rust 1.55 stable. Hmm wonder if we have something else global causing it to not take, couldn't even set as env var and have it be used. Can't find anything obvious though. Update 2: on my Windows machine the |
@MarijnS95 do you have any other target-specific rustflags in we do and it appears that if you have a section like this that sets [target.x86_64-pc-windows-msvc]
rustflags = [
"-C", "target-feature=+crt-static", # use static MSVC CRT so we do not have to distribute vc_redist
"-C", "link-args=-fuse-ld=lld-link",
"-C", "lto=no"] # disable LTO for faster incremental link times you can't have a [build]
rustflags = [ If I remove the above |
@repi we don't have any other place that specifies buildflags, so that'll explain it. |
Looks like for this to work you ought to stick it in a |
Yeah quite cryptic, but glad found workaround. Wish Cargo would have warned or failed on this when it actively ignores flags |
@repi Glad you figured it out - it's unfortunate that these are mutually exclusive instead of being joined together - how else can you make global + target specific flags without duplicating the global ones? This is especially worrisome when joining |
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
In the absence of a way to configure lints across a workspace, we use a technique described in EmbarkStudios/rust-ecosystem#68. This allows us to move the lints that should unconditionally apply to all crates to this one config, unblocking the split up of the mega crate into multiple smaller ones.
While making the code only marginally harder to read such casts can also introduce subtle bugs when used incorrectly, and are best omitted whenever unnecessary: Rust already coerces borrows into raw pointers when the types on both ends are clear, and even then there remain many casts that are identical to the source type. In addition these errors show up when using a local crate reference to `ash` in a workspace that uses "the `.cargo/config.toml` setup" from [EmbarkStudios/rust-ecosystem#68] to configure linter warnings project-wide instead of for all crates in that workspace individually. In our case aforementioned linter warnings are enabled on top of Embark's configuration, leading to a lot of these warnings in our build process. [EmbarkStudios/rust-ecosystem#68]: EmbarkStudios/rust-ecosystem#68
I'm trying out cargo cranky as an alternative to using You can specify the desired lints in a |
Adds an alternate way to enable our standard lints (#59) for all this crates in a repository through
.cargo/config.toml
section. Inspired by rust-lang/cargo#5034 (comment).We are testing this as a workaround for #22 until Cargo/Clippy supports a proper mechanism to configure lints for an entire repository/workspace, and seems to work really well so far. One of our big repositories has 80+ crates and all of them had the previous lint code definitions in every lib.rs/main.rs copy'n'pasted and this will replace all of that and make it dramatically easier to manage and less error prone.