2 // aux-build:trait-with-const-param.rs
3 extern crate trait_with_const_param;
4 use trait_with_const_param::*;
6 // Trivial case, const param after local type.
8 impl<const N: usize, T> Trait<N, T> for Local1 {}
10 // Concrete consts behave the same as foreign types,
11 // so this also trivially works.
12 impl Trait<3, Local1> for i32 {}
14 // This case isn't as trivial as we would forbid type
15 // parameters here, we do allow const parameters though.
17 // The reason that type parameters are forbidden for
18 // `impl<T> Trait<T, LocalInA> for i32 {}` is that another
19 // downstream crate can add `impl<T> Trait<LocalInB, T> for i32`.
20 // As these two impls would overlap we forbid any impls which
21 // have a type parameter in front of a local type.
23 // With const parameters this issue does not exist as there are no
24 // constants local to another downstream crate.
26 impl<const N: usize> Trait<N, Local2> for i32 {}