Skip to content

Commit 0fb9295

Browse files
committed
Add another test for const parameter (non) hygiene.
1 parent 8876b3b commit 0fb9295

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// A more comprehensive test that const parameters have correctly implemented
2+
// hygiene
3+
4+
// check-pass
5+
6+
#![feature(const_generics)]
7+
8+
use std::ops::Add;
9+
10+
struct VectorLike<T, const SIZE: usize>([T; {SIZE}]);
11+
12+
macro_rules! impl_operator_overload {
13+
($trait_ident:ident, $method_ident:ident) => {
14+
15+
impl<T, const SIZE: usize> $trait_ident for VectorLike<T, {SIZE}>
16+
where
17+
T: $trait_ident,
18+
{
19+
type Output = VectorLike<T, {SIZE}>;
20+
21+
fn $method_ident(self, _: VectorLike<T, {SIZE}>) -> VectorLike<T, {SIZE}> {
22+
let _ = SIZE;
23+
unimplemented!()
24+
}
25+
}
26+
27+
}
28+
}
29+
30+
impl_operator_overload!(Add, add);
31+
32+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-61574-const-parameters.rs:6:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+

0 commit comments

Comments
 (0)