#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
-struct Foo<T, const N: usize>([T; {N}]);
+struct Foo<T, const N: usize>([T; N]);
-impl<T, const N: usize> Foo<T, {N}> {
+impl<T, const N: usize> Foo<T, N> {
fn foo(&self) -> usize {
- {N}
+ N
}
}
struct Wrapper<const F: fn() -> u32>;
-impl<const F: fn() -> u32> Wrapper<{F}> {
+impl<const F: fn() -> u32> Wrapper<F> {
fn call() -> u32 {
F()
}
}
fn main() {
- assert_eq!(Wrapper::<{function}>::call(), 17);
+ assert_eq!(Wrapper::<function>::call(), 17);
}
fn generic<T>(val: usize) -> bool { val != 1 }
fn main() {
- let _: Option<Checked<{not_one}>> = None;
- let _: Checked<{not_one}> = Checked::<{not_one}>;
- let _: Checked<{not_one}> = Checked::<{not_two}>; //~ mismatched types
+ let _: Option<Checked<not_one>> = None;
+ let _: Checked<not_one> = Checked::<not_one>;
+ let _: Checked<not_one> = Checked::<not_two>; //~ mismatched types
- let _ = Checked::<{generic_arg}>;
+ let _ = Checked::<generic_arg>;
let _ = Checked::<{generic_arg::<usize>}>;
let _ = Checked::<{generic_arg::<u32>}>; //~ mismatched types
- let _ = Checked::<{generic}>; //~ type annotations needed
+ let _ = Checked::<generic>; //~ type annotations needed
let _ = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u16>}> = Checked::<{generic::<u16>}>;
let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>; //~ mismatched types
= note: `#[warn(incomplete_features)]` on by default
error[E0308]: mismatched types
- --> $DIR/fn-const-param-infer.rs:16:33
+ --> $DIR/fn-const-param-infer.rs:16:31
|
-LL | let _: Checked<{not_one}> = Checked::<{not_two}>;
- | ^^^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
+LL | let _: Checked<not_one> = Checked::<not_two>;
+ | ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
|
= note: expected type `Checked<not_one>`
found type `Checked<not_two>`
found type `fn(u32) -> bool {generic_arg::<u32>}`
error[E0282]: type annotations needed
- --> $DIR/fn-const-param-infer.rs:22:24
+ --> $DIR/fn-const-param-infer.rs:22:23
|
-LL | let _ = Checked::<{generic}>;
- | ^^^^^^^ cannot infer type for `T`
+LL | let _ = Checked::<generic>;
+ | ^^^^^^^ cannot infer type for `T`
error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:25:40
struct S<const X: u32>;
-impl<const X: u32> S<{X}> {
+impl<const X: u32> S<X> {
fn x() -> u32 {
X
}
struct Const<const P: *const u32>;
-impl<const P: *const u32> Const<{P}> {
+impl<const P: *const u32> Const<P> {
fn get() -> u32 {
unsafe {
*P
struct Array<T, const N: usize>([T; N]);
-impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<T, {N}> {
+impl<T: fmt::Debug, const N: usize> fmt::Debug for Array<T, N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.0.iter()).finish()
}