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

Fed Decides On Interest Rates Today—Here’s What To Watch For

Fed Decides On Interest Rates Today—Here’s What To Watch For

The post Fed Decides On Interest Rates Today—Here’s What To Watch For appeared on BitcoinEthereumNews.com. Topline The Federal Reserve on Wednesday will conclude a two-day policymaking meeting and release a decision on whether to lower interest rates—following months of pressure and criticism from President Donald Trump—and potentially signal whether additional cuts are on the way. President Donald Trump has urged the central bank to “CUT INTEREST RATES, NOW, AND BIGGER” than they might plan to. Getty Images Key Facts The central bank is poised to cut interest rates by at least a quarter-point, down from the 4.25% to 4.5% range where they have been held since December to between 4% and 4.25%, as Wall Street has placed 100% odds of a rate cut, according to CME’s FedWatch, with higher odds (94%) on a quarter-point cut than a half-point (6%) reduction. Fed governors Christopher Waller and Michelle Bowman, both Trump appointees, voted in July for a quarter-point reduction to rates, and they may dissent again in favor of a large cut alongside Stephen Miran, Trump’s Council of Economic Advisers’ chair, who was sworn in at the meeting’s start on Tuesday. It’s unclear whether other policymakers, including Kansas City Fed President Jeffrey Schmid and St. Louis Fed President Alberto Musalem, will favor larger cuts or opt for no reduction. Fed Chair Jerome Powell said in his Jackson Hole, Wyoming, address last month the central bank would likely consider a looser monetary policy, noting the “shifting balance of risks” on the U.S. economy “may warrant adjusting our policy stance.” David Mericle, an economist for Goldman Sachs, wrote in a note the “key question” for the Fed’s meeting is whether policymakers signal “this is likely the first in a series of consecutive cuts” as the central bank is anticipated to “acknowledge the softening in the labor market,” though they may not “nod to an October cut.” Mericle said he…
Share
BitcoinEthereumNews2025/09/18 00:23
Stunning 230% Surge: UAE Sovereign Fund’s Massive Bitcoin ETF Expansion Signals Institutional Confidence

Stunning 230% Surge: UAE Sovereign Fund’s Massive Bitcoin ETF Expansion Signals Institutional Confidence

BitcoinWorld Stunning 230% Surge: UAE Sovereign Fund’s Massive Bitcoin ETF Expansion Signals Institutional Confidence Have you ever wondered what happens when one of the world’s wealthiest sovereign funds decides to go all-in on Bitcoin? The United Arab Emirates is making headlines with an astonishing 230% increase in their Bitcoin ETF holdings since June, signaling a massive shift in institutional cryptocurrency adoption. What Does This Bitcoin ETF Explosion Mean for Crypto Markets? The UAE sovereign wealth fund now holds 7.9 million shares of Bitcoin ETFs, valued at approximately $517 million. This represents one of the most significant institutional moves into cryptocurrency this year. The rapid expansion demonstrates growing confidence among traditional financial giants in digital assets. This massive Bitcoin ETF accumulation didn’t happen overnight. Let’s break down what makes this development so crucial: Institutional validation – Sovereign wealth funds represent the most conservative investment entities Market confidence – A 230% increase shows strong belief in Bitcoin’s long-term value Regional leadership – UAE positions itself as a crypto hub in the Middle East Why Are Sovereign Wealth Funds Embracing Bitcoin ETF Products? Sovereign wealth funds typically manage national savings for future generations. Their investment in Bitcoin ETF products indicates a strategic shift toward digital assets as legitimate store-of-value instruments. The timing is particularly interesting given recent market conditions. The benefits driving this Bitcoin ETF adoption include: Portfolio diversification beyond traditional assets >Inflation hedging capabilities Exposure to technological innovation Liquidity and regulatory clarity through ETF structures How Does This Impact Global Bitcoin ETF Adoption Trends? The UAE’s move creates a powerful domino effect across global markets. Other sovereign wealth funds and institutional investors often follow early adopters in conservative investment circles. This Bitcoin ETF accumulation sets a precedent that could accelerate worldwide institutional adoption. Consider these implications for the broader Bitcoin ETF landscape: Increased legitimacy for cryptocurrency investments Potential for other Middle Eastern funds to follow suit Enhanced regulatory acceptance in traditional finance circles Strong price support through institutional buying pressure What Challenges Do Institutions Face with Bitcoin ETF Investments? Despite the enthusiasm, sovereign wealth funds encounter several hurdles when investing in Bitcoin ETF products. Regulatory uncertainty remains a primary concern, along with volatility management and custody solutions. However, the UAE’s substantial commitment suggests these challenges are being effectively addressed. The successful navigation of these obstacles paves the way for: More sophisticated risk management frameworks Improved regulatory guidelines for institutional crypto investing Enhanced security protocols for digital asset custody Better integration with traditional portfolio strategies Conclusion: A New Era for Bitcoin ETF Institutional Adoption The UAE sovereign wealth fund’s staggering 230% Bitcoin ETF expansion marks a pivotal moment in cryptocurrency history. This move demonstrates that digital assets have graduated from speculative instruments to legitimate components of sovereign investment strategies. The massive capital allocation signals confidence that will likely inspire similar moves from other conservative institutions worldwide. Frequently Asked Questions What exactly is a Bitcoin ETF? A Bitcoin ETF is an exchange-traded fund that tracks Bitcoin’s price, allowing investors to gain exposure without directly holding cryptocurrency. Why are sovereign wealth funds investing in Bitcoin ETFs now? Sovereign funds seek diversification, inflation protection, and exposure to innovative assets that traditional markets no longer provide adequately. How significant is a $517 million Bitcoin ETF investment? For context, this represents one of the largest public institutional Bitcoin positions and signals strong confidence to other conservative investors. Will other sovereign funds follow the UAE’s Bitcoin ETF strategy? Industry experts believe this could trigger a wave of similar investments as sovereign funds typically monitor and emulate each other’s successful strategies. What risks do sovereign funds face with Bitcoin ETF investments? Primary concerns include regulatory changes, price volatility, custody security, and integration with existing investment frameworks. How does this affect individual Bitcoin investors? Institutional adoption typically brings increased market stability, regulatory clarity, and mainstream acceptance, benefiting all participants. Found this analysis of the UAE’s massive Bitcoin ETF expansion insightful? Share this groundbreaking institutional adoption story with your network on social media to spread awareness about cryptocurrency’s growing mainstream acceptance! To learn more about the latest Bitcoin trends, explore our article on key developments shaping Bitcoin institutional adoption. This post Stunning 230% Surge: UAE Sovereign Fund’s Massive Bitcoin ETF Expansion Signals Institutional Confidence first appeared on BitcoinWorld.
Share
Coinstats2025/11/15 01:10