Skip to content

Commit

Permalink
Use native check-cfg lint in cargo beta
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dunxen committed Jul 12, 2024
1 parent 78c0eaa commit 99aa6e2
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 172 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
run: |
rustup target add thumbv7m-none-eabi
sudo apt-get -y install gcc-arm-none-eabi
- name: Check for unknown cfg tags
run: ci/check-cfg-flags.py
- name: shellcheck the CI script
if: "matrix.platform == 'ubuntu-latest'"
run: |
Expand Down
22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,25 @@ panic = "abort"

[patch.crates-io.possiblyrandom]
path = "possiblyrandom"

[workspace.lints.rust.unexpected_cfgs]
level = "forbid"
# When adding a new cfg attribute, ensure that it is added to this list.
#
# Note that Cargo automatically declares corresponding cfgs for every feature
# defined in the member-level [features] tables as "expected".
check-cfg = [
"cfg(fuzzing)",
"cfg(secp256k1_fuzz)",
"cfg(hashes_fuzz)",
"cfg(test)",
"cfg(debug_assertions)",
"cfg(c_bindings)",
"cfg(ldk_bench)",
"cfg(taproot)",
"cfg(async_signing)",
"cfg(require_route_graph_test)",
"cfg(dual_funding)",
"cfg(splicing)",
"cfg(async_payments)",
]
170 changes: 0 additions & 170 deletions ci/check-cfg-flags.py

This file was deleted.

3 changes: 3 additions & 0 deletions lightning-background-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "syn
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
lightning-invoice = { version = "0.31.0-beta", path = "../lightning-invoice" }
lightning-persister = { version = "0.0.123-beta", path = "../lightning-persister" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-block-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ chunked_transfer = { version = "1.4", optional = true }
[dev-dependencies]
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
tokio = { version = "1.35", features = [ "macros", "rt" ] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-custom-message/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
bitcoin = "0.31.2"
lightning = { version = "0.0.123-beta", path = "../lightning" }

[lints]
workspace = true
4 changes: 4 additions & 0 deletions lightning-invoice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
default = ["std"]
no-std = ["lightning/no-std"]
std = ["bitcoin/std", "lightning/std", "bech32/std"]
strict = []

[dependencies]
bech32 = { version = "0.9.1", default-features = false }
Expand All @@ -31,3 +32,6 @@ lightning = { version = "0.0.123-beta", path = "../lightning", default-features
hex = { package = "hex-conservative", version = "0.1.1", default-features = false }
serde_json = { version = "1"}
hashbrown = { version = "0.13", default-features = false }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-net-tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ tokio = { version = "1.35", features = [ "rt", "sync", "net", "time" ] }
[dev-dependencies]
tokio = { version = "1.35", features = [ "macros", "rt", "rt-multi-thread", "sync", "net", "time" ] }
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-persister/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ criterion = { version = "0.4", optional = true, default-features = false }
[dev-dependencies]
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
bitcoin = { version = "0.31.2", default-features = false }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-rapid-gossip-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ criterion = { version = "0.4", optional = true, default-features = false }

[dev-dependencies]
lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning-transaction-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ electrsd = { version = "0.27.3", default-features = false, features = ["legacy",

[target.'cfg(all(not(target_os = "windows"), no_download))'.dev-dependencies]
electrsd = { version = "0.27.3", default-features = false, features = ["legacy"] }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions lightning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ criterion = { version = "0.4", optional = true, default-features = false }

[target.'cfg(taproot)'.dependencies]
musig2 = { git = "https://github.com/arik-so/rust-musig2", rev = "739533fc" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions possiblyrandom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ getrandom = { version = "0.2", optional = true, default-features = false }
# Enable getrandom if we are on a platform that (likely) supports it
[target.'cfg(not(any(target_os = "unknown", target_os = "none")))'.dependencies]
getrandom = { version = "0.2", default-features = false }

[lints]
workspace = true

0 comments on commit 99aa6e2

Please sign in to comment.