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 Adoption of Web3 in Europe: Current Status, Opportunities, and Challenges

The Adoption of Web3 in Europe: Current Status, Opportunities, and Challenges

How decentralization technologies are advancing in the Old Continent.
Share
The Cryptonomist2025/12/06 15:00
Wang Yongli, former vice president of the Bank of China: Why did China resolutely halt stablecoins?

Wang Yongli, former vice president of the Bank of China: Why did China resolutely halt stablecoins?

Written by: Wang Yongli , former Vice President of Bank of China China's policy orientation of accelerating the development of the digital yuan and resolutely curbing virtual currencies, including stablecoins, is now fully clear. This is based on a comprehensive consideration of factors such as China's leading global advantages in mobile payments and the digital yuan, the sovereignty and security of the yuan, and the stability of the monetary and financial system. Since May 2025, the United States and Hong Kong have been racing to advance stablecoin legislation, which has led to a surge in global legislation on stablecoins and crypto assets (also known as "cryptocurrencies" or "virtual currencies"). A large number of institutions and capital are flocking to issue stablecoins and invest in crypto assets, which has also sparked heated debate on whether China should fully promote stablecoin legislation and the development of RMB stablecoins (including offshore ones). Furthermore, after the United States legislated to prohibit the Federal Reserve from issuing digital dollars, whether China should continue to promote digital RMB has also become a hot topic of debate. For China, this involves the direction and path of national currency development. With the global spread of stablecoins and the increasingly acute and complex international relations and fiercer international currency competition, this has a huge and far-reaching impact on how the RMB innovates and develops, safeguards national security, and achieves the strategic goals of a strong currency and a financial power. We must calmly analyze, accurately grasp, and make decisions early. We cannot be indifferent or hesitant, nor can we blindly follow the trend and make directional and subversive mistakes. Subsequently, the People's Bank of China announced that it would optimize the positioning of the digital yuan within the monetary hierarchy (adjusting the previously determined M0 positioning. This is a point I have repeatedly advocated from the beginning; see Wang Yongli's WeChat public account article "Digital Yuan Should Not Be Positioned as M0" dated January 6, 2021), further optimize the digital yuan management system (establishing an international digital yuan operations center in Shanghai, responsible for cross-border cooperation and use of the digital yuan; and establishing a digital yuan operations management center in Beijing, responsible for the construction, operation, and maintenance of the digital yuan system), and promote and accelerate the development of the digital yuan . On November 28, the People's Bank of China and 13 other departments jointly convened a meeting of the coordination mechanism for combating virtual currency trading and speculation. The meeting pointed out that due to various factors, virtual currency speculation has recently resurfaced, and related illegal and criminal activities have occurred frequently, posing new challenges to risk prevention and control. It emphasized that all units should deepen coordination and cooperation, continue to adhere to the prohibitive policy on virtual currencies, and persistently crack down on illegal financial activities related to virtual currencies. It clarified that stablecoins are a form of virtual currency , and their issuance and trading activities are also illegal and subject to crackdown. This has greatly disappointed those who believed that China would promote the development of RMB stablecoins and correspondingly relax the ban on virtual currency (crypto asset) trading. Therefore, China's policy orientation of accelerating the development of the digital yuan and resolutely curbing virtual currencies, including stablecoins, is now fully clear . Of course, this policy orientation remains highly debated both domestically and internationally, and there is no consensus among the public. So, how should we view this major policy direction of China? This article will first answer why China resolutely halted stablecoins; how to accelerate the innovative development of the digital yuan will be discussed in another article . There is little room or opportunity for the development of non-USD stablecoins. Since Tether launched USDT, a stablecoin pegged to the US dollar, in 2014 , USD stablecoins have been operating for over a decade and have formed a complete international operating system. They have basically dominated the entire crypto asset trading market, accounting for over 99% of the global fiat stablecoin market capitalization and trading volume . This situation arises from two main factors. First, the US dollar is the most liquid and has the most comprehensive supporting system of international central currencies, making stablecoins pegged to the dollar the easiest to accept globally. Second, it is also a result of the US's long-standing tolerant policy towards crypto assets like Bitcoin and dollar-denominated stablecoins, rather than leading the international community to strengthen necessary regulation and safeguard the fundamental interests of all humanity. Even this year, when the US pushed for legislation on stablecoins and crypto assets, it was largely driven by the belief that dollar-denominated stablecoins would increase global demand for the dollar and dollar-denominated assets such as US Treasury bonds, reduce the financing costs for the US government and society, and strengthen the dollar's international dominance. This was a choice made to enhance US support for dollar-denominated stablecoins and control their potential impact on the US, prioritizing the maximization of national interests while giving little consideration to mitigating the international risks of stablecoins. With the US strongly promoting dollar-denominated stablecoins, other countries or regions launching non-dollar fiat currency stablecoins will find it difficult to compete with dollar-denominated stablecoins on an international level, except perhaps within their own sovereign territory or on the issuing institution's own e-commerce platform. Their development potential and practical significance are limited . Lacking a strong ecosystem and application scenarios, and lacking distinct characteristics compared to dollar-denominated stablecoins, as well as the advantage of attracting traders and transaction volume, the return on investment for issuing non-dollar fiat currency stablecoins is unlikely to meet expectations, and they will struggle to survive in an environment of increasingly stringent legislation and regulation in various countries. The legislation on stablecoins in the United States still faces many problems and challenges. Following President Trump's second election victory, his strong advocacy for crypto assets such as Bitcoin fueled a new international frenzy in cryptocurrency trading, driving the rapid development of dollar-denominated stablecoin trading and a surge in stablecoin market capitalization. This not only increased demand for the US dollar and US Treasury bonds, strengthening the dollar's international status, but also brought huge profits to the Trump family and their cryptocurrency associates. However, this also posed new challenges to the global monitoring of the dollar's circulation and the stability of the traditional US financial system. Furthermore, the trading and transfer of crypto assets backed by dollar-denominated stablecoins has become a new and more difficult-to-prevent tool for the US to harvest global wealth, posing a serious threat to the monetary sovereignty and wealth security of other countries . This is why the United States has accelerated legislation on stablecoins, but its legislation is more about prioritizing America and maximizing American and even group interests, at the expense of the interests of other countries and the common interests of the world. After the legislation on US dollar stablecoins came into effect, institutions that have not obtained approval and operating licenses from US regulators will find it difficult to issue and operate US dollar stablecoins in the United States (for this reason, Tether has announced that it will apply for US-issued USDT). Stablecoin issuers subject to US regulation must meet regulatory requirements such as Know Your Customer (KYC), Anti-Money Laundering (AML), and Counter-Terrorist Financing (FTC). They must be able to screen customers against government watchlists and report suspicious activities to regulators. Their systems must have the ability to freeze or intercept specific stablecoins when ordered by law enforcement agencies. Stablecoin issuers must have reserves of no less than 100% US dollar assets (including currency assets, short-term Treasury bonds, and repurchase agreements backed by Treasury bonds) approved by regulators, and must keep US customer funds in US banks and not transfer them overseas. They are prohibited from paying interest or returns on stablecoins, and strict control must be exercised over-issuance and self-operation. Reserve assets must be held in custody by an independent institution approved by regulators and must be audited by an auditing firm at least monthly and an audit report must be issued. This will greatly enhance the value stability of stablecoins relative to the US dollar, strengthen their payment function and compliance, while weakening their investment attributes and illegal use; it will also significantly increase the regulatory costs of stablecoins, thereby reducing their potential for exorbitant profits in an unregulated environment. The US stablecoin legislation officially took effect on July 18, but it still faces numerous challenges : While it stipulates the scope of reserve assets for stablecoin issuance (bank deposits, short-term Treasury bonds, repurchase agreements backed by Treasury bonds, etc.), since it primarily includes Treasury bonds with fluctuating trading prices, even if reserve assets are sufficient at the time of issuance, a subsequent decline in Treasury bond prices could lead to insufficient reserves; if the reserve asset structures of different issuing institutions are not entirely consistent, and there is no central bank guarantee, it means that the issued dollar stablecoins will not be the same, creating arbitrage opportunities and posing challenges to relevant regulation and market stability; even if there is no over-issuance of stablecoins at the time of issuance, allowing decentralized finance (DeFi) to engage in stablecoin lending could still lead to stablecoin derivation and over-issuance, unless it is entirely a matchmaking between lenders and borrowers rather than proprietary trading; getting stablecoin issuers outside of financial institutions to meet regulatory requirements is not easy, and regulation also presents significant challenges. More importantly, the earliest and most fundamental requirement for stablecoins is the borderless, decentralized, 24/7 pricing and settlement of crypto assets on the blockchain. It is precisely because crypto assets like Bitcoin cannot fulfill the fundamental requirement of currency as a measure of value and a value token—that the total amount of currency must change in line with the total value of tradable wealth requiring monetary pricing and settlement—that their price relative to fiat currency fluctuates wildly (therefore, using crypto assets like Bitcoin as collateral or strategic reserves carries significant risks), making it difficult to become a true circulating currency. This has led to the development of fiat stablecoins pegged to fiat currencies. (Therefore, Bitcoin and similar crypto assets can only be considered crypto assets; calling them "cryptocurrency" or "virtual currency" is inaccurate; translating the English word "Token" as "币" or "币" is also inappropriate; it should be directly transliterated as "通证" and clearly defined as an asset, not currency.) The emergence and development of fiat-backed stablecoins have brought fiat currencies and more real-world assets (RWAs) onto the blockchain, strongly supporting on-chain cryptocurrency trading and development. They serve as a channel connecting the on-chain cryptocurrency world with the off-chain real-world, thereby strengthening the integration and influence of the cryptocurrency world on the real world. This will significantly enhance the scope, speed, scale, and volatility of global wealth financialization and financial transactions, accelerating the transfer and concentration of global wealth in a few countries or groups. In this context, failing to strengthen global joint regulation of stablecoins and cryptocurrency issuance and trading poses extremely high risks and dangers . Therefore, the surge in stablecoin and cryptocurrency development driven by the Trump administration in the United States has already revealed a huge bubble and potential risks, making it unsustainable. The international community must be highly vigilant about this! Stablecoin legislation could severely backfire on stablecoins. One unexpected outcome of stablecoin legislation is that the inclusion of fiat-backed stablecoins in legislative regulation will inevitably lead to legislative regulation of crypto asset transactions denominated and settled using fiat-backed stablecoins, including blockchain-generated assets such as Bitcoin and on-chain real-world assets (RWA). This will have a profound impact on stablecoins. Before crypto assets receive legislative regulation and compliance protection, licensed financial institutions such as banks find it difficult to directly participate in crypto asset trading, clearing, custody, and other related activities, thus ceding opportunities to private organizations outside of financial institutions. Due to the lack of regulation and the absence of regulatory costs, existing stablecoin issuers and crypto asset trading platforms have become highly profitable and attractive entities, exerting an increasing impact on banks and the financial system, forcing governments and monetary authorities in countries like the United States to accelerate legislative regulation of stablecoins. However, once crypto assets receive legislative regulation and compliance protection, banks and other financial institutions will undoubtedly participate fully. Payment institutions such as banks can directly promote the on-chain operation of fiat currency deposits (deposit tokenization), completely replacing stablecoins as a new channel and hub connecting the crypto world and the real world . Similarly, existing stock, bond, money market fund, and ETF exchanges can promote the on-chain trading of these relatively standardized financial products through RWA (Real-Time Asset Exchange). Having adequately regulated financial institutions such as banks act as the main entities connecting the crypto world and the real world on the blockchain is more conducive to implementing current legislative requirements for stablecoins, upholding the principle of "equal regulation for the same business" for all institutions, and reducing the impact and risks of crypto asset development on the existing monetary and financial system. This trend has already emerged in the United States and is rapidly intensifying, proving difficult to stop . Therefore, stablecoin legislation may seriously backfire on or subvert stablecoins ( see Wang Yongli's WeChat public account article "Stablecoin Legislation May Seriously Backfire on Stablecoins" on September 3, 2025 ). In this situation, it is not a reasonable choice for other countries to follow the US lead and vigorously promote stablecoin legislation and development. China should not follow the path of stablecoins taken by the United States. China already has a leading global advantage in mobile payments and the digital yuan. Promoting a stablecoin for the yuan has no advantage domestically, and it will have little room for development and influence internationally. It should not follow the path of the US dollar stablecoin, but should instead focus on promoting the development of stablecoins for the yuan, both domestically and offshore. More importantly, crypto assets and stablecoins like Bitcoin can achieve 24/7 global trading and clearing through borderless blockchains and crypto asset trading platforms. While this significantly improves efficiency, the highly anonymous and high-frequency global flow, lacking coordinated international oversight, makes it difficult to meet regulatory requirements such as KYC, AML, and FTC. This poses a clear risk and has been demonstrated in real-world cases of being used for money laundering, fundraising fraud, and illegal cross-border fund transfers. Given that US dollar stablecoins already dominate the crypto asset trading market, and the US has greater control or influence over major global blockchain operating systems, crypto asset trading platforms, and the exchange rate between crypto assets and the US dollar (as evidenced by the US's ability to trace, identify, freeze, and confiscate the crypto asset accounts of some institutions and individuals, and to punish or even arrest some crypto asset trading platforms and their leaders), China's development of a RMB stablecoin following the path of US dollar stablecoins not only fails to challenge the international status of US dollar stablecoins but may even turn the RMB stablecoin into a vassal of US dollar stablecoins. This could impact national tax collection, foreign exchange management, and cross-border capital flows, posing a serious threat to the sovereignty and security of the RMB and the stability of the monetary and financial system. Faced with a more acute and complex international situation, China should prioritize national security and exercise high vigilance and strict control over the trading and speculation of crypto assets, including stablecoins, rather than simply pursuing increased efficiency and reduced costs . It is necessary to accelerate the improvement of relevant regulatory policies and legal frameworks, focus on key links such as information flow and capital flow, strengthen information sharing among relevant departments, further enhance monitoring and tracking capabilities, and severely crack down on illegal and criminal activities involving crypto assets. Of course, while resolutely halting stablecoins and cracking down on virtual currency trading and speculation, we must also accelerate the innovative development and widespread application of the digital yuan at home and abroad, establish the international leading advantage of the digital yuan, forge a Chinese path for the development of digital currency, and actively explore the establishment of a fair, reasonable and secure new international monetary and financial system . Taking into account the above factors, it is not difficult to understand why China has chosen to resolutely curb virtual currencies, including stablecoins, while firmly promoting and accelerating the development of the digital yuan.
Share
PANews2025/12/06 15:08
Current Status, Opportunities, and Challenges

Current Status, Opportunities, and Challenges

The post Current Status, Opportunities, and Challenges appeared on BitcoinEthereumNews.com. In recent years, even Europe, traditionally cautious towards new technologies, seems to be experiencing a phase of progressive adoption of Web3. The Old Continent is tackling the challenges of decentralization technologies, amidst innovative momentum, strict regulations, and new opportunities for businesses and creatives.  Web3: The Technologies of Decentralization Web3 refers to the evolution of the Internet towards a decentralized model, based on blockchain, smart contracts, tokens, crypto, and distributed digital identities.  According to what is described by Amazon Web Services, other key technologies of Web3 include artificial intelligence (AI), machine learning, WebAssembly, semantic technologies and interfaces such as decentralized wallets and augmented reality (AR) and virtual reality (VR).  All these technologies aim to give users greater control over their own data and ownership of digital assets, eliminating reliance on centralized intermediaries. Moreover, Web3 projects are mostly driven directly by the community.  Thus, the first challenge of Web3 is to evolve Web2, dominated by centralized platforms. With decentralization technologies, Web3 aims to  return control and ownership of data to users; eliminate intermediaries thanks to smart contracts; create digital economies based on tokens and NFTs; promote greater transparency and security. Today, Web3 is capable of influencing sectors such as finance, art, video games, music, real estate, and digital governance.  The Adoption of Web3 in Europe: A Conscious Growth The adoption of Web3 in Europe is not predominant compared to other continents like North America and Asia. However, it can be stated that in the Old Continent, the adoption of Web3 is in a hybrid phase: it is not a matter of mass usage, but rather a growing number of businesses, professionals, and informed users.  For example, in the blockchain and crypto sector, the report by Chainalysis confirmed that between July 2023 and June 2024, the European region experienced significant growth and resilience. …
Share
BitcoinEthereumNews2025/12/06 15:24