mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-29 03:53:55 +00:00
In some contexts, const expressions are OK. Add a `here` to the error message to clarify this.
20 lines
599 B
Rust
20 lines
599 B
Rust
//! Regression test for <https://github.com/rust-lang/rust/issues/79429>.
|
|
|
|
//@ revisions: full min
|
|
#![cfg_attr(full, feature(generic_const_exprs))]
|
|
#![cfg_attr(full, allow(incomplete_features))]
|
|
|
|
struct X<const S: usize>;
|
|
|
|
impl<const S: usize> X<S> {
|
|
const LEN: usize = S + 1; // `S + 1` is a valid const expression in this context.
|
|
}
|
|
|
|
struct Y<const S: usize> {
|
|
stuff: [u8; { S + 1 }], // `S + 1` is NOT a valid const expression in this context.
|
|
//[min]~^ ERROR generic parameters may not be used in const operations
|
|
//[full]~^^ ERROR unconstrained generic constant
|
|
}
|
|
|
|
fn main() {}
|