This can help with verifying that the crate is correctly handling conditional compilation for different target platforms or features. It ensures that the cfg settings are consistent between what is intended and what is used, helping to catch potential bugs or errors early in the development process.This can help with verifying that the crate is correctly handling conditional compilation for different target platforms or features. It ensures that the cfg settings are consistent between what is intended and what is used, helping to catch potential bugs or errors early in the development process.

The Automatic Checking of cfgs: How It Works

2025/11/03 01:15

The Cargo and Compiler team are delighted to announce that starting with Rust 1.80 (or nightly-2024-05-05) every reachable #[cfg] will be automatically checked that they match the expected config names and values.

\ This can help with verifying that the crate is correctly handling conditional compilation for different target platforms or features. It ensures that the cfg settings are consistent between what is intended and what is used, helping to catch potential bugs or errors early in the development process.

\ This addresses a common pitfall for new and advanced users.

\ This is another step to our commitment to provide user-focused tooling and we are eager and excited to finally see it fixed, after more than two years since the original RFC 30131.

A look at the feature

Every time a Cargo feature is declared that feature is transformed into a config that is passed to rustc (the Rust compiler) so it can verify with it along with well known cfgs if any of the #[cfg], #![cfg_attr] and cfg! have unexpected configs and report a warning with the unexpected_cfgs lint.

Cargo.toml:

[package] name = "foo" [features] lasers = [] zapping = []

\ src/lib.rs:

#[cfg(feature = "lasers")] // This condition is expected // as "lasers" is an expected value // of the `feature` cfg fn shoot_lasers() {} #[cfg(feature = "monkeys")] // This condition is UNEXPECTED // as "monkeys" is NOT an expected // value of the `feature` cfg fn write_shakespeare() {} #[cfg(windosw)] // This condition is UNEXPECTED // it's supposed to be `windows` fn win() {}

\ cargo check:

Expecting custom cfgs

UPDATE: This section was added with the release of nightly-2024-05-19.

\ Some crates might use custom cfgs, like loom, fuzzing or tokio_unstable that they expected from the environment (RUSTFLAGS or other means) and which are always statically known at compile time. For those cases, Cargo provides via the [lints] table a way to statically declare those cfgs as expected.

\ Defining those custom cfgs as expected is done through the special check-cfg config under [lints.rust.unexpected_cfgs]:

Cargo.toml

[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(loom)', 'cfg(fuzzing)'] }

Custom cfgs in build scripts

On the other hand some crates use custom cfgs that are enabled by some logic in the crate build.rs. For those crates Cargo provides a new instruction: cargo::rustc-check-cfg2 (or cargo:rustc-check-cfg for older Cargo version).

\ The syntax to use is described in the rustc book section checking configuration, but in a nutshell the basic syntax of --check-cfg is:

cfg(name, values("value1", "value2", ..., "valueN"))

\ Note that every custom cfgs must always be expected, regardless if the cfg is active or not!

build.rs example

build.rs:

fn main() { println!("cargo::rustc-check-cfg=cfg(has_foo)"); // ^^^^^^^^^^^^^^^^^^^^^^ new with Cargo 1.80 if has_foo() { println!("cargo::rustc-cfg=has_foo"); } }

Equivalence table

\ More details can be found in the rustc book.

Frequently asked questions

Can it be disabled?

For Cargo users, the feature is always on and cannot be disabled, but like any other lints it can be controlled: #![warn(unexpected_cfgs)].

Does the lint affect dependencies?

No, like most lints, unexpected_cfgs will only be reported for local packages thanks to cap-lints.

How does it interact with the RUSTFLAGS env?

You should be able to use the RUSTFLAGS environment variable like it was before. Currently --cfg arguments are not checked, only usage in code are.

\ This means that doing RUSTFLAGS="--cfg tokio_unstable" cargo check will not report any warnings, unless tokio_unstable is used within your local crates, in which case crate author will need to make sure that that custom cfg is expected with cargo::rustc-check-cfg in the build.rs of that crate.

How to expect custom cfgs without a build.rs?

UPDATE: Cargo with nightly-2024-05-19 now provides the [lints.rust.unexpected_cfgs.check-cfg] config to address the statically known custom cfgs.

\ There is currently no way to expect a custom cfg other than with cargo::rustc-check-cfg in a build.rs.

\ Crate authors that don't want to use a build.rs and cannot use [lints.rust.unexpected_cfgs.check-cfg], are encouraged to use Cargo features instead.

How does it interact with other build systems?

Non-Cargo based build systems are not affected by the lint by default. Build system authors that wish to have the same functionality should look at the rustc documentation for the --check-cfg flag for a detailed explanation of how to achieve the same functionality.

\

  1. The stabilized implementation and RFC 3013 diverge significantly, in particular there is only one form for --check-cfg: cfg() (instead of values() and names() being incomplete and subtlety incompatible with each other). ↩
  2. cargo::rustc-check-cfg will start working in Rust 1.80 (or nightly-2024-05-05). From Rust 1.77 to Rust 1.79 (inclusive) it is silently ignored. In Rust 1.76 and below a warning is emitted when used without the unstable Cargo flag -Zcheck-cfg. ↩

Urgau on behalf of The Cargo Team

\ Also published here

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

The Channel Factories We’ve Been Waiting For

The Channel Factories We’ve Been Waiting For

The post The Channel Factories We’ve Been Waiting For appeared on BitcoinEthereumNews.com. Visions of future technology are often prescient about the broad strokes while flubbing the details. The tablets in “2001: A Space Odyssey” do indeed look like iPads, but you never see the astronauts paying for subscriptions or wasting hours on Candy Crush.  Channel factories are one vision that arose early in the history of the Lightning Network to address some challenges that Lightning has faced from the beginning. Despite having grown to become Bitcoin’s most successful layer-2 scaling solution, with instant and low-fee payments, Lightning’s scale is limited by its reliance on payment channels. Although Lightning shifts most transactions off-chain, each payment channel still requires an on-chain transaction to open and (usually) another to close. As adoption grows, pressure on the blockchain grows with it. The need for a more scalable approach to managing channels is clear. Channel factories were supposed to meet this need, but where are they? In 2025, subnetworks are emerging that revive the impetus of channel factories with some new details that vastly increase their potential. They are natively interoperable with Lightning and achieve greater scale by allowing a group of participants to open a shared multisig UTXO and create multiple bilateral channels, which reduces the number of on-chain transactions and improves capital efficiency. Achieving greater scale by reducing complexity, Ark and Spark perform the same function as traditional channel factories with new designs and additional capabilities based on shared UTXOs.  Channel Factories 101 Channel factories have been around since the inception of Lightning. A factory is a multiparty contract where multiple users (not just two, as in a Dryja-Poon channel) cooperatively lock funds in a single multisig UTXO. They can open, close and update channels off-chain without updating the blockchain for each operation. Only when participants leave or the factory dissolves is an on-chain transaction…
Share
BitcoinEthereumNews2025/09/18 00:09
BitMine koopt $44 miljoen aan ETH

BitMine koopt $44 miljoen aan ETH

De grootste Ethereum (ETH) treasury ter wereld, BitMine Immersion Technologies, heeft weer toegeslagen op de crypto markt. Uit on-chain data blijkt dat BitMine, ook bekend onder het ticker symbool BMNR, voor $44 miljoen aan ETH munten heeft gekocht. Wat betekent dit voor de grootste altcoin? Check onze Discord Connect met "like-minded" crypto enthousiastelingen Leer gratis de basis van Bitcoin & trading - stap voor stap, zonder voorkennis. Krijg duidelijke uitleg & charts van ervaren analisten. Sluit je aan bij een community die samen groeit. Nu naar Discord BitMine verdubbelt inzet op Ethereum Om precies te zijn koopt BitMine 14.618 ETH munten erbij, goed voor dus $44 miljoen. Zo blijkt uit on-chain gegevens gedeeld door Lookonchain op X. Daarmee tilt de grote Ethereum treasury zijn voorraad naar maar liefst 3,63 miljoen ETH ter waarde van ruim $11 miljard, aldus data van StrategicETHReserve. Daarmee controleert het bedrijf nu 3% van alle Ethereum in omloop. Tom Lee(@fundstrat)’s #Bitmine just bought another 14,618 $ETH($44.34M) 4 hours ago.https://t.co/P684j5Yil8 pic.twitter.com/LHOpDto1R5 — Lookonchain (@lookonchain) November 28, 2025 De ambities liggen desondanks een stuk hoger: BitMine wil uiteindelijk 5% van de volledige ETH voorraad bezitten. Oftewel, we kunnen nog flink wat Ethereum aankopen verwachten van het bedrijf in de komende maanden. Door de aggresssieve ETH strategie van het bedrijf zijn ze bij uitstek de grootste Ethereum reserve. De nummer twee, SharpLink Gaming, bezit ongeveer 859.400 ETH munten ter waarde van zo’n $2,62 miljard. Deze agressieve uitbreiding volgt een duidelijke strategie. BitMine verwacht dat Ethereum een grotere rol in de tokenisatie. Bedrijven bezitten samen al bijna 5,01% van alle ETH, een signaal dat corporates zich voorbereiden op een toekomst waarin Ethereum een basislaag wordt voor financiële infrastructuur. Waarom BitMine zijn treasury blijft uitbreiden BitMine bouwt zijn treasury verder uit omdat het een dominante positie in het Ethereum netwerk wil innemen. Meer ETH geeft BitMine straks hogere staking-opbrengsten en meer invloed op de liquiditeit binnen het netwerk. Ook gelooft BMNR sterk in de rol van Ethereum in de toekomst van financiële infrastructuur. Bestuurslid Tom Lee verwacht dat ETH een dominante speler zal zijn in de stablecoin en tokenisatie markt. Beide sectoren zijn hard aan het groeien, mede dankzij duidelijke wet- en regelgeving onder de Trump administratie zoals de GENIUS Act. Daarnaast gelooft Tom Lee in een zogeheten supercycle voor ETH. Volgens de bekende top analist kan de grootste altcoin zelfs Bitcoin (BTC) voorbijstreven, allemaal dankzij grootschalige adoptie door tokenisatie. Als Ethereum de huidige marketcap van BTC wil evenaren dan zou de ETH koers al op ruim $15.000 komen. ETH en BMNR krabbelen langzaam op uit diepe dip De ethereum prijs reageerde vandaag beperkt op het nieuws. De altcoin steeg over de afgelopen 24 uur met 0,8% tot een huidige koers van $3.050. Daarmee zet de munt samen met de rest van de crypto markt een stijgende trend voort. Na een heftige crash in de afgelopen weken zakte de ETH koers vorige week vrijdag tot onder de $2.700. Ook het BMNR aandeel is langzaam aan het terugkrabbelen. Het ETH treasury bedrijf zakte vorige week tot $26. Een flinke crash ten opzichte van de all time high van $135 dat het bedrijf in juli van dit jaar nog wist te realiseren. De sterke daling van het BMNR aandeel valt samen met een algehele neerwaartse trend onder crypto treasury bedrijven. Ook Strategy, de grootste publieke Bitcoin houder, is ook flink lager aan het handelen vanaf zijn all time. Zo staat het MSTR aandeel momenteel op $175 tegenover een prijs record van $457 in juli. Ethereum (ETH) kopen op Bitvavo Bitvavo - grootste crypto exchange in Nederland Meer dan 340 beschikbare cryptocurrencies Lage transactiekosten Gemakkelijk via iDeal geld storten Professionele traders dashboard Bitvavo review Koop ETH op Bitvavo Let op: cryptocurrency is een zeer volatiele en ongereguleerde investering. Doe je eigen onderzoek. Het bericht BitMine koopt $44 miljoen aan ETH is geschreven door Thomas van Welsenes en verscheen als eerst op Bitcoinmagazine.nl.
Share
Coinstats2025/11/28 20:31
Upbit hack sparks altcoin season in Korea? Thailand targets WLD

Upbit hack sparks altcoin season in Korea? Thailand targets WLD

The post Upbit hack sparks altcoin season in Korea? Thailand targets WLD appeared on BitcoinEthereumNews.com. Korean crypto bros are pumping altcoins after Upbit’s $36M exploit Korean crypto traders are having an outsize effect on local altcoin prices following a major hack at South Korean exchange Upbit, according to CryptoQuant CEO Ki Young Ju. (Ki Young Ju) “Upbit got hacked and paused withdrawals, but Koreans are pumping alts since arbitrage bots are no longer running,” Ju said in an X post on Thursday, shortly after the exchange halted transaction activity after detecting an “abnormal transaction” with a value of around $36 million. With arbitrage activity suspended, local buy orders are having more significant pressure on prices, allowing Korean-listed altcoins to surge, as the selling pressure that typically puts a ceiling on price increases has disappeared. Crypto trader R2D2 said, “Unbelievable scenes here.” Crypto analyst A79 said, “Hack happens, and Koreans just flip it into a rally.” Upbit announced on Thursday that it had suspended deposits and withdrawals after identifying an unauthorized transaction worth approximately 54 billion won ($36 million), involving mainly Solana-based assets that were transferred to an unidentified wallet address. Assets reportedly affected by the hack include BONK (BONK), Official Trump (TRUMP), MOODENG (MOODENG), and Render (RENDER). Upbit to cover loss to prevent “any damage” to user assets The exchange clarified that while the hot wallet was impacted, its cold wallets — where the majority of user funds are stored — were not compromised. Dunamu CEO Oh Kyung-seok said: “We immediately identified the extent of the digital asset outflow caused by the abnormal withdrawals and will cover the entire amount with Upbit assets to prevent any damage to our members’ assets.” Some industry participants were confused by the fact that all the red numbers Ju shared were positive. StarkWare ecosystem lead Brother Odin was quick to ask the obvious question, before Ju explained that red…
Share
BitcoinEthereumNews2025/11/28 21:20