惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
D
Docker
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
月光博客
月光博客
小众软件
小众软件
量子位
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
博客园 - 叶小钗
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
博客园 - 司徒正美
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
C
Check Point Blog

Rust Blog

Security Advisory for Cargo (CVE-2026-5223) | Rust Blog Security Advisory for Cargo (CVE-2026-5222) | Rust Blog Project goals update — April 2026 (end of 2025H2) | Rust Blog Rust is participating in Outreachy | Rust Blog Raising the baseline for the `nvptx64-nvidia-cuda` target | Rust Blog Announcing Google Summer of Code 2026 selected projects | Rust Blog Announcing Rust 1.95.0 | Rust Blog docs.rs: building fewer targets by default | Rust Blog Changes to WebAssembly targets and handling undefined symbols | Rust Blog Announcing Rust 1.94.1 | Rust Blog Security advisory for Cargo | Rust Blog What we heard about Rust's challenges | Rust Blog Call for Testing: Build Dir Layout v2 | Rust Blog Announcing rustup 1.29.0 | Rust Blog Announcing Rust 1.94.0 | Rust Blog 2025 State of Rust Survey Results | Rust Blog Rust debugging survey 2026 | Rust Blog Update on the October 15, 2018 incident on crates.io Announcing Rust 1.29.2 Announcing Rust 1.29 Announcing Rust 1.28 What is Rust 2018? Announcing Rust 1.27.2 Announcing Rust 1.27.1 Security Advisory for rustdoc Announcing Rust 1.27 Announcing Rust 1.26.2 Announcing Rust 1.26.1 Rust turns three Announcing Rust 1.26
Inferred const generic arguments: Call for Testing! | Ins...
BoxyUwU on behalf of The Const Generics Project Group · 2025-03-05 · via Rust Blog

We are excited to announce that feature(generic_arg_infer) is nearing the point of stabilization. In this post we'd like to talk a bit about what this feature does, and what comes next for it.

What is feature(generic_arg_infer)

When feature(min_const_generics) was stabilized in early 2021 it did not include the ability to use _ as an explicit const argument:

fn foo() {
  // This errors due to `_` as an array length being unsupported
  let a: [u8; _] = [Default::default()];
  // This is legal as `_` is permitted as a type argument
  let b: [_; 1] = a;
}

This is entirely a syntactic limitation; it is possible to entirely elide generic argument listings that may involve const arguments:

fn foo<const N: usize>(_: [u8; N]) {}

fn bar() {
  // This errors due to `_` as a const argument being unsupported
  foo::<_>([1]);
  // This is legal as even though the const argument is *inferred*
  // there is no explicit `_` written.
  foo([1]);
}

The compiler has always been able to infer values for const generic parameters, only the ability to explicitly ask for a const argument to be inferred is unstable.

It is currently also not possible to the infer the length of a repeat expression. Doing so would require moving the expression into a separate function generic over the array length.

fn foo() {
    // This errors due to `_` as a repeat count being unsupported
    let a: [_; 1] = [String::new(); _];
}

With feature(generic_arg_infer) all of the previous examples compile. This should hopefully feel like something that should "obviously" be supported by Rust.

What comes next

We have significantly reworked the implementation of this recently and it should now be ready for stabilization. We'd love for you to try it out on a recent nightly and report any issues you encounter.

Acknowledgements

My recent push to make this feature ready for testing would not have been possible without the help of many others.

A big thank you to @lcnr and @JulianKnodt for the initial implementation of generic_arg_infer, @camelid for refactoring our representation of const generic arguments to be more flexible, @voidc for helping unify the way we operate on array lengths and const generic arguments, @lcnr for design work on abstracting away differences between inferred type/const/generic arguments, and finally @compiler-errors for reviewing many PRs and implementation decisions made as part of work on this feature.