rust/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
497 B
Rust
Raw Normal View History

2021-05-06 15:33:44 +00:00
//@ [feature] run-pass
//@ revisions: normal feature
#![cfg_attr(feature, feature(generic_arg_infer))]
fn foo<const N: usize>(_: [u8; N]) -> [u8; N] {
2025-01-08 21:05:35 +00:00
[0; N]
2021-05-06 15:33:44 +00:00
}
2021-12-23 09:05:43 +00:00
fn bar() {
let _x: [u8; 3] = [0; _];
//[normal]~^ ERROR: using `_` for array lengths is unstable
let _y: [u8; _] = [0; 3];
//[normal]~^ ERROR: using `_` for array lengths is unstable
}
2021-05-06 15:33:44 +00:00
fn main() {
2025-01-08 21:05:35 +00:00
let _x = foo::<_>([1, 2]);
//[normal]~^ ERROR: const arguments cannot yet be inferred with `_`
bar();
2021-05-06 15:33:44 +00:00
}