2021-10-23 16:57:49 +01:00
|
|
|
#![feature(adt_const_params)]
|
2020-08-22 03:32:07 +00:00
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
2023-05-17 04:05:46 +00:00
|
|
|
use std::marker::ConstParamTy;
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, ConstParamTy)]
|
2020-08-22 03:32:07 +00:00
|
|
|
enum CompileFlag {
|
2021-02-14 04:35:18 +00:00
|
|
|
A,
|
|
|
|
B,
|
2020-08-22 03:32:07 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 17:12:53 +00:00
|
|
|
pub fn test_1<const CF: CompileFlag>() {}
|
|
|
|
pub fn test_2<T, const CF: CompileFlag>(x: T) {}
|
|
|
|
pub struct Example<const CF: CompileFlag, T=u32>{
|
2021-02-14 04:35:18 +00:00
|
|
|
x: T,
|
2020-08-31 17:12:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<const CF: CompileFlag, T> Example<CF, T> {
|
|
|
|
const ASSOC_FLAG: CompileFlag = CompileFlag::A;
|
|
|
|
}
|
2020-08-22 03:32:07 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2020-08-31 17:12:53 +00:00
|
|
|
test_1::<CompileFlag::A>();
|
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-14 04:35:18 +00:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 17:12:53 +00:00
|
|
|
|
|
|
|
test_2::<_, CompileFlag::A>(0);
|
2020-08-22 03:32:07 +00:00
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-14 04:35:18 +00:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 17:12:53 +00:00
|
|
|
|
|
|
|
let _: Example<CompileFlag::A, _> = Example { x: 0 };
|
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-14 04:35:18 +00:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 17:12:53 +00:00
|
|
|
|
|
|
|
let _: Example<Example::ASSOC_FLAG, _> = Example { x: 0 };
|
2020-11-13 20:23:37 +01:00
|
|
|
//~^ ERROR: type provided when a constant was expected
|
2020-08-22 03:32:07 +00:00
|
|
|
}
|