Comments (4)
from rust.
It seems to me that since the file is included in both build.rs and the built program, even if rustc-check-cfg suppressed the warnings about the surplus exe config in the program I might still wind up facing warnings about exe in the build.rs, since the println has not run at the time the build.rs is built. However I don't think this is the problem above, because in that case I would have expected the number of warnings to halve on adding the suppression line, not stay the same.
Your analysis here is correct, I think you just missed this tiny note which is that cargo suppresses identical warnings 🙂
Before uncommenting the cargo:rustc-cfg-check
line:
...
warning: `spritetest` (build script) generated 4 warnings
warning: `spritetest` (bin "spritetest") generated 4 warnings (4 duplicates)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 11.66s
After:
...
warning: `spritetest` (build script) generated 4 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.47s
@Urgau what's the right way to deal with check-cfg
warnings originating in build.rs
?
from rust.
Adding the check-cfg args directly in the lint config should do it12.
Cargo.toml
:
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(exe)'] }
Footnotes
from rust.
Adding the check-cfg args directly in the lint config should do it12.
Cargo.toml
:[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(exe)'] }Footnotes
Thank you, I should have updated to NEWEST nightly before filing. I see that with 2024-05-20 nightly rustc the [lint] IS recommended in a hint, so this hint would have solved my problem if I had upgraded this morning before filing.
The lint works as expected and my problem is resolved (lint removes warnings where println does not).
I have a recommendation. If you are merging build.rs and executable warnings, then in principle you know that my "exe" cfg warnings are coming (in part) from build.rs. Currently, you display two recommendations*, the build.rs print and the [lint]. In the case of a cfg warning originating from a build.rs, the build.rs print! will not help and you know that ahead of time. Therefore for these warnings, I suggest you omit the build.rs print recommendation and show only the [lint] recommendation.
If that is impractical, then you may close this issue.
* with rustc 1.80.0-nightly (b92758a9a 2024-05-20)
I get:
warning: unexpected `cfg` condition name: `exe`
--> src/rkyv_types.rs:6:7
|
6 | #[cfg(exe)]
| ^^^
|
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows`
= help: consider using a Cargo feature instead
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(exe)'] }
= help: or consider adding `println!("cargo::rustc-check-cfg=cfg(exe)");` to the top of the `build.rs`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default
from rust.
Related Issues (20)
- Error performing operation: fully_perform HOT 1
- Debuginfo tests don't control for ambient tools HOT 8
- const expression produces infinite compilation HOT 1
- std cannot be compiled on win7 targets HOT 4
- Regression in nightly-2024-05-27 HOT 6
- False negative lint for `unused_imports`
- ICE / `Unexpected initial operand type` HOT 3
- Relating different kinds: `'?1 Bar` HOT 1
- When looking for alternative places for method not found, look at parent expresions for it
- "Binding is possibly uninitalized" reports some additional spans incorrectly in addition to the correct one HOT 1
- Overriding LTO option in global config.toml release profile causes bootstrap failure HOT 4
- Deallocating large BTreeMap takes very long time HOT 6
- ICE: `None` in `compiler/rustc_middle/src/ty/sty.rs` HOT 4
- ICE: Failed to normalize `std::ops::ControlFlow<Alias(Projection, …), Alias(Projection, …)>` HOT 1
- Tracking Issue for offset_of_slice
- Bootstrap unit tests always require cmake
- CI: tidy errors are hidden by verbose Python dependency resolution logging
- bootstrap: `x.py test` specified test order not honored
- dead_code lint wrongly warns about public repr(C) structs with private fields but no constructors HOT 25
- PR CI (x86_64-gnu-llvm-17) does not run codegen tests HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.