test for non local anon const printing

This commit is contained in:
Boxy 2023-01-14 19:01:31 +00:00
parent 4ca5368a12
commit 88f81a0de1
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub struct Foo<const N: usize>;
pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
Foo
}

View File

@ -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<const M: usize>()
where
[(); M + 1]:,
{
let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
//~^ ERROR: mismatched types
}
fn main() {}

View File

@ -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::<M>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`.