Pre-RFC: Function parameter defaults
Rust Internals [Unofficial]
February 25, 2026
It's a breaking change to add Fn* impls (they are fundamental traits), but there are probably ways around that.
- Accept it anyway due to negligible breakage as function items aren't nameable
- Consider each arity to be a different type
fn f(_: bool, _: i32 /* = 0 */) {
}
fn g(_: bool, _: i32 /* = 1 */) {
}
fn ex() {
let _array = [f, g];
}
This compiles today, and you have [fn(bool, i32); 2]. Conceivably if both have defaults, it could be [fn(bool); 2] instead. So it's at least in some senses ambiguous. Alternatively, there could be some fallback preference for "no defaults"...
...but then consider if f adds a third defaulted arg _: f64, and at some later point, g does too. Now it infers to a new type, either changing semantics or breaking code. (If the fallback is "all defaults" you have the opposite problem.)
Discussion in the ATmosphere