Skip to content

Commit 88f81a0

Browse files
committed
test for non local anon const printing
1 parent 4ca5368 commit 88f81a0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct Foo<const N: usize>;
5+
6+
pub fn foo<const N: usize>() -> Foo<{ N + 1 }> {
7+
Foo
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// aux-build:anon_const_non_local.rs
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
extern crate anon_const_non_local;
7+
8+
fn bar<const M: usize>()
9+
where
10+
[(); M + 1]:,
11+
{
12+
let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
13+
//~^ ERROR: mismatched types
14+
}
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/non_local_anon_const_diagnostics.rs:12:43
3+
|
4+
LL | let _: anon_const_non_local::Foo<2> = anon_const_non_local::foo::<M>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `_`
6+
|
7+
= note: expected constant `2`
8+
found constant `_`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)