From 359031e1d38a5705fa85b866130379da98d54329 Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Tue, 10 Nov 2020 09:35:02 +0100 Subject: [PATCH] add generic param mismatch test --- .../generic-param-mismatch.full.stderr | 14 ++++++++++++++ .../generic-param-mismatch.min.stderr | 14 ++++++++++++++ .../ui/const-generics/generic-param-mismatch.rs | 10 ++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/test/ui/const-generics/generic-param-mismatch.full.stderr create mode 100644 src/test/ui/const-generics/generic-param-mismatch.min.stderr create mode 100644 src/test/ui/const-generics/generic-param-mismatch.rs diff --git a/src/test/ui/const-generics/generic-param-mismatch.full.stderr b/src/test/ui/const-generics/generic-param-mismatch.full.stderr new file mode 100644 index 00000000000..6befa9d1f69 --- /dev/null +++ b/src/test/ui/const-generics/generic-param-mismatch.full.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/generic-param-mismatch.rs:7:5 + | +LL | fn test() -> [u8; M] { + | ------- expected `[u8; M]` because of return type +LL | [0; N] + | ^^^^^^ expected `M`, found `N` + | + = note: expected array `[u8; M]` + found array `[u8; N]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/generic-param-mismatch.min.stderr b/src/test/ui/const-generics/generic-param-mismatch.min.stderr new file mode 100644 index 00000000000..6befa9d1f69 --- /dev/null +++ b/src/test/ui/const-generics/generic-param-mismatch.min.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/generic-param-mismatch.rs:7:5 + | +LL | fn test() -> [u8; M] { + | ------- expected `[u8; M]` because of return type +LL | [0; N] + | ^^^^^^ expected `M`, found `N` + | + = note: expected array `[u8; M]` + found array `[u8; N]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/const-generics/generic-param-mismatch.rs b/src/test/ui/const-generics/generic-param-mismatch.rs new file mode 100644 index 00000000000..e409094eb73 --- /dev/null +++ b/src/test/ui/const-generics/generic-param-mismatch.rs @@ -0,0 +1,10 @@ +// revisions: full min +#![cfg_attr(full, allow(incomplete_features))] +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(min, feature(min_const_generics))] + +fn test() -> [u8; M] { + [0; N] //~ ERROR mismatched types +} + +fn main() {}