Skip to content

Commit 99aa6e2

Browse files
committed
Use native check-cfg lint in cargo beta
This uses the newly introduced conditional configuration checks that are now configurable withint Cargo (beta). This allows us to get rid of our custom python script that checks for expected features and cfgs. This does introduce a warning regarding the unknown lint in Cargo versions prior to the current beta, but since these are not rustc errors, they won't break any builds with the "-D warnings" RUSTFLAG. Moving to this lint actually exposed the "strict" feature not being present in the lightning-invoice crate, as our python script didnt correctly parse the cfg_attr where it appeared.
1 parent 78c0eaa commit 99aa6e2

File tree

13 files changed

+53
-172
lines changed

13 files changed

+53
-172
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
run: |
3333
rustup target add thumbv7m-none-eabi
3434
sudo apt-get -y install gcc-arm-none-eabi
35-
- name: Check for unknown cfg tags
36-
run: ci/check-cfg-flags.py
3735
- name: shellcheck the CI script
3836
if: "matrix.platform == 'ubuntu-latest'"
3937
run: |

Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,25 @@ panic = "abort"
4242

4343
[patch.crates-io.possiblyrandom]
4444
path = "possiblyrandom"
45+
46+
[workspace.lints.rust.unexpected_cfgs]
47+
level = "forbid"
48+
# When adding a new cfg attribute, ensure that it is added to this list.
49+
#
50+
# Note that Cargo automatically declares corresponding cfgs for every feature
51+
# defined in the member-level [features] tables as "expected".
52+
check-cfg = [
53+
"cfg(fuzzing)",
54+
"cfg(secp256k1_fuzz)",
55+
"cfg(hashes_fuzz)",
56+
"cfg(test)",
57+
"cfg(debug_assertions)",
58+
"cfg(c_bindings)",
59+
"cfg(ldk_bench)",
60+
"cfg(taproot)",
61+
"cfg(async_signing)",
62+
"cfg(require_route_graph_test)",
63+
"cfg(dual_funding)",
64+
"cfg(splicing)",
65+
"cfg(async_payments)",
66+
]

ci/check-cfg-flags.py

Lines changed: 0 additions & 170 deletions
This file was deleted.

lightning-background-processor/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "syn
3030
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
3131
lightning-invoice = { version = "0.31.0-beta", path = "../lightning-invoice" }
3232
lightning-persister = { version = "0.0.123-beta", path = "../lightning-persister" }
33+
34+
[lints]
35+
workspace = true

lightning-block-sync/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ chunked_transfer = { version = "1.4", optional = true }
2828
[dev-dependencies]
2929
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
3030
tokio = { version = "1.35", features = [ "macros", "rt" ] }
31+
32+
[lints]
33+
workspace = true

lightning-custom-message/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ rustdoc-args = ["--cfg", "docsrs"]
1616
[dependencies]
1717
bitcoin = "0.31.2"
1818
lightning = { version = "0.0.123-beta", path = "../lightning" }
19+
20+
[lints]
21+
workspace = true

lightning-invoice/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1818
default = ["std"]
1919
no-std = ["lightning/no-std"]
2020
std = ["bitcoin/std", "lightning/std", "bech32/std"]
21+
strict = []
2122

2223
[dependencies]
2324
bech32 = { version = "0.9.1", default-features = false }
@@ -31,3 +32,6 @@ lightning = { version = "0.0.123-beta", path = "../lightning", default-features
3132
hex = { package = "hex-conservative", version = "0.1.1", default-features = false }
3233
serde_json = { version = "1"}
3334
hashbrown = { version = "0.13", default-features = false }
35+
36+
[lints]
37+
workspace = true

lightning-net-tokio/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ tokio = { version = "1.35", features = [ "rt", "sync", "net", "time" ] }
2222
[dev-dependencies]
2323
tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "sync", "net", "time" ] }
2424
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
25+
26+
[lints]
27+
workspace = true

lightning-persister/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ criterion = { version = "0.4", optional = true, default-features = false }
2626
[dev-dependencies]
2727
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
2828
bitcoin = { version = "0.31.2", default-features = false }
29+
30+
[lints]
31+
workspace = true

lightning-rapid-gossip-sync/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ criterion = { version = "0.4", optional = true, default-features = false }
2323

2424
[dev-dependencies]
2525
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
26+
27+
[lints]
28+
workspace = true

lightning-transaction-sync/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ electrsd = { version = "0.27.3", default-features = false, features = ["legacy",
3939

4040
[target.'cfg(all(not(target_os = "windows"), no_download))'.dev-dependencies]
4141
electrsd = { version = "0.27.3", default-features = false, features = ["legacy"] }
42+
43+
[lints]
44+
workspace = true

lightning/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,6 @@ criterion = { version = "0.4", optional = true, default-features = false }
6565

6666
[target.'cfg(taproot)'.dependencies]
6767
musig2 = { git = "https://github.com/arik-so/rust-musig2", rev = "739533fc" }
68+
69+
[lints]
70+
workspace = true

possiblyrandom/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ getrandom = { version = "0.2", optional = true, default-features = false }
1919
# Enable getrandom if we are on a platform that (likely) supports it
2020
[target.'cfg(not(any(target_os = "unknown", target_os = "none")))'.dependencies]
2121
getrandom = { version = "0.2", default-features = false }
22+
23+
[lints]
24+
workspace = true

0 commit comments

Comments
 (0)