From 88f81a0de122843afc122468823f1ed6f0b8f2c8 Mon Sep 17 00:00:00 2001 From: Boxy Date: Sat, 14 Jan 2023 19:01:31 +0000 Subject: [PATCH] test for non local anon const printing --- .../auxiliary/anon_const_non_local.rs | 8 ++++++++ .../non_local_anon_const_diagnostics.rs | 16 ++++++++++++++++ .../non_local_anon_const_diagnostics.stderr | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr diff --git a/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs new file mode 100644 index 00000000000..97be074933d --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/auxiliary/anon_const_non_local.rs @@ -0,0 +1,8 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +pub struct Foo; + +pub fn foo() -> Foo<{ N + 1 }> { + Foo +} diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs new file mode 100644 index 00000000000..1254b4435f7 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.rs @@ -0,0 +1,16 @@ +// aux-build:anon_const_non_local.rs + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +extern crate anon_const_non_local; + +fn bar() +where + [(); M + 1]:, +{ + let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); + //~^ ERROR: mismatched types +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr new file mode 100644 index 00000000000..c18281beb05 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non_local_anon_const_diagnostics.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/non_local_anon_const_diagnostics.rs:12:43 + | +LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `_` + | + = note: expected constant `2` + found constant `_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`.