2021-10-23 10:57:49 -05:00
|
|
|
#![feature(adt_const_params)]
|
2020-08-21 22:32:07 -05:00
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
enum CompileFlag {
|
2021-02-13 22:35:18 -06:00
|
|
|
A,
|
|
|
|
B,
|
2020-08-21 22:32:07 -05:00
|
|
|
}
|
|
|
|
|
2020-08-31 12:12:53 -05: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-13 22:35:18 -06:00
|
|
|
x: T,
|
2020-08-31 12:12:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<const CF: CompileFlag, T> Example<CF, T> {
|
|
|
|
const ASSOC_FLAG: CompileFlag = CompileFlag::A;
|
|
|
|
}
|
2020-08-21 22:32:07 -05:00
|
|
|
|
|
|
|
pub fn main() {
|
2020-08-31 12:12:53 -05:00
|
|
|
test_1::<CompileFlag::A>();
|
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-13 22:35:18 -06:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 12:12:53 -05:00
|
|
|
|
|
|
|
test_2::<_, CompileFlag::A>(0);
|
2020-08-21 22:32:07 -05:00
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-13 22:35:18 -06:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 12:12:53 -05:00
|
|
|
|
|
|
|
let _: Example<CompileFlag::A, _> = Example { x: 0 };
|
|
|
|
//~^ ERROR: expected type, found variant
|
2021-02-13 22:35:18 -06:00
|
|
|
//~| ERROR: unresolved item provided when a constant was expected
|
2020-08-31 12:12:53 -05:00
|
|
|
|
|
|
|
let _: Example<Example::ASSOC_FLAG, _> = Example { x: 0 };
|
2020-11-13 13:23:37 -06:00
|
|
|
//~^ ERROR: type provided when a constant was expected
|
2020-08-21 22:32:07 -05:00
|
|
|
}
|