Skip to content

Commit e276b86

Browse files
committed
redo tests
1 parent b44be27 commit e276b86

8 files changed

+96
-31
lines changed

src/test/ui/const-generics/defaults/cec-build-subst-ice.rs

-10
This file was deleted.

src/test/ui/const-generics/defaults/cec-build-subst-ice.stderr

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
2+
#![allow(incomplete_features)]
3+
4+
struct Foo<const N: usize, const M: usize = { N + 1 }>;
5+
fn no_constraining() -> Foo<10> {
6+
Foo::<10, 11>
7+
}
8+
9+
pub fn different_than_default() -> Foo<10> {
10+
Foo::<10, 12>
11+
//~^ error: mismatched types
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/cec-concrete-default.rs:10:5
3+
|
4+
LL | Foo::<10, 12>
5+
| ^^^^^^^^^^^^^ expected `11_usize`, found `12_usize`
6+
|
7+
= note: expected type `11_usize`
8+
found type `12_usize`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
2+
#![allow(incomplete_features)]
3+
4+
struct Foo<const N: usize, const M: usize = { N + 1 }>;
5+
fn should_unify<const N: usize>() -> Foo<N> where [(); { N + 1 }]: {
6+
Foo::<N, { N + 1 }>
7+
}
8+
pub fn shouldnt_unify<const N: usize>() -> Foo<N>
9+
where
10+
[(); { N + 1 }]:,
11+
[(); { N + 2 }]:, {
12+
Foo::<N, { N + 2 }>
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/cec-generic-default-mismatched-types.rs:12:5
3+
|
4+
LL | Foo::<N, { N + 2 }>
5+
| ^^^^^^^^^^^^^^^^^^^ expected `{ N + 1 }`, found `{ N + 2 }`
6+
|
7+
= note: expected type `{ N + 1 }`
8+
found type `{ N + 2 }`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(const_evaluatable_checked, const_generics, const_generics_defaults)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct Foo<const N: usize, const M: usize = { N + 1 }>;
5+
pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
6+
//~^ error: unconstrained generic constant
7+
loop {}
8+
}
9+
pub fn has_evaluatable_bound<const N1: usize>() -> Foo<N1> where [(); N1 + 1]: {
10+
loop {}
11+
}
12+
13+
type FooAlias<const N: usize, const NP: usize = { N + 1 }> = [(); NP];
14+
fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
15+
{
16+
//~^^ error: unconstrained generic constant
17+
todo!()
18+
}
19+
fn has_evaluatable_bound_alias<const N: usize>() -> FooAlias<N>
20+
where [(); N + 1]: {
21+
todo!()
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error: unconstrained generic constant
2+
--> $DIR/cec-generic-default.rs:5:54
3+
|
4+
LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
5+
| ^^^^^^^
6+
|
7+
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
8+
9+
error: unconstrained generic constant
10+
--> $DIR/cec-generic-default.rs:14:58
11+
|
12+
LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
13+
| ^^^^^^^^^^^
14+
|
15+
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
16+
17+
error: aborting due to 2 previous errors
18+

0 commit comments

Comments
 (0)