Skip to content

Commit 2534440

Browse files
committed
Add lowering tests for arrays and const params
1 parent 176fd2b commit 2534440

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

tests/lowering/mod.rs

+82-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,52 @@ fn check_variable_kinds() {
288288
"incorrect parameter kind for trait `IntoTime`: expected lifetime, found type"
289289
}
290290
}
291+
292+
lowering_error! {
293+
program {
294+
trait Length<const N> {}
295+
struct Foo {}
296+
impl<T> Length<T> for Foo {}
297+
}
298+
error_msg {
299+
"incorrect parameter kind for trait `Length`: expected const, found type"
300+
}
301+
}
302+
303+
lowering_error! {
304+
program {
305+
trait Length<const N> {}
306+
struct Foo {}
307+
impl<'a> Length<'a> for Foo {}
308+
}
309+
error_msg {
310+
"incorrect parameter kind for trait `Length`: expected const, found lifetime"
311+
}
312+
}
313+
314+
lowering_error! {
315+
program {
316+
trait Into<T> {}
317+
struct Foo {}
318+
impl<const N> Into<N> for Foo {}
319+
}
320+
321+
error_msg {
322+
"incorrect parameter kind for trait `Into`: expected type, found const"
323+
}
324+
}
325+
326+
lowering_error! {
327+
program {
328+
trait IntoTime<'a> {}
329+
struct Foo {}
330+
impl<const N> IntoTime<N> for Foo {}
331+
}
332+
333+
error_msg {
334+
"incorrect parameter kind for trait `IntoTime`: expected lifetime, found const"
335+
}
336+
}
291337
}
292338

293339
#[test]
@@ -584,7 +630,6 @@ fn fn_defs() {
584630
}
585631
}
586632
}
587-
588633
#[test]
589634
fn arrays() {
590635
lowering_success! {
@@ -595,4 +640,40 @@ fn arrays() {
595640
fn bar<const N>(baz: [Baz; N]);
596641
}
597642
}
643+
644+
lowering_error! {
645+
program {
646+
struct Baz { }
647+
648+
fn foo<T>(baz: [Baz; u32]);
649+
}
650+
651+
error_msg {
652+
"parse error: UnrecognizedToken"
653+
}
654+
}
655+
656+
lowering_error! {
657+
program {
658+
struct Baz { }
659+
660+
fn foo<T>(baz: [Baz; T]);
661+
}
662+
663+
error_msg {
664+
"incorrect parameter kind for `T`: expected const, found type"
665+
}
666+
}
667+
668+
lowering_error! {
669+
program {
670+
struct Baz { }
671+
672+
fn foo<'a>(baz: [Baz; 'a]);
673+
}
674+
675+
error_msg {
676+
"parse error: UnrecognizedToken"
677+
}
678+
}
598679
}

0 commit comments

Comments
 (0)