Skip to content

Commit

Permalink
redo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jul 10, 2021
1 parent b44be27 commit e276b86
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 31 deletions.
10 changes: 0 additions & 10 deletions src/test/ui/const-generics/defaults/cec-build-subst-ice.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/ui/const-generics/defaults/cec-build-subst-ice.stderr

This file was deleted.

14 changes: 14 additions & 0 deletions src/test/ui/const-generics/defaults/cec-concrete-default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
#![allow(incomplete_features)]

struct Foo<const N: usize, const M: usize = { N + 1 }>;
fn no_constraining() -> Foo<10> {
Foo::<10, 11>
}

pub fn different_than_default() -> Foo<10> {
Foo::<10, 12>
//~^ error: mismatched types
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/const-generics/defaults/cec-concrete-default.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/cec-concrete-default.rs:10:5
|
LL | Foo::<10, 12>
| ^^^^^^^^^^^^^ expected `11_usize`, found `12_usize`
|
= note: expected type `11_usize`
found type `12_usize`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
#![allow(incomplete_features)]

struct Foo<const N: usize, const M: usize = { N + 1 }>;
fn should_unify<const N: usize>() -> Foo<N> where [(); { N + 1 }]: {
Foo::<N, { N + 1 }>
}
pub fn shouldnt_unify<const N: usize>() -> Foo<N>
where
[(); { N + 1 }]:,
[(); { N + 2 }]:, {
Foo::<N, { N + 2 }>
//~^ error: mismatched types
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/cec-generic-default-mismatched-types.rs:12:5
|
LL | Foo::<N, { N + 2 }>
| ^^^^^^^^^^^^^^^^^^^ expected `{ N + 1 }`, found `{ N + 2 }`
|
= note: expected type `{ N + 1 }`
found type `{ N + 2 }`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
24 changes: 24 additions & 0 deletions src/test/ui/const-generics/defaults/cec-generic-default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![feature(const_evaluatable_checked, const_generics, const_generics_defaults)]
#![allow(incomplete_features)]

pub struct Foo<const N: usize, const M: usize = { N + 1 }>;
pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
//~^ error: unconstrained generic constant
loop {}
}
pub fn has_evaluatable_bound<const N1: usize>() -> Foo<N1> where [(); N1 + 1]: {
loop {}
}

type FooAlias<const N: usize, const NP: usize = { N + 1 }> = [(); NP];
fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
{
//~^^ error: unconstrained generic constant
todo!()
}
fn has_evaluatable_bound_alias<const N: usize>() -> FooAlias<N>
where [(); N + 1]: {
todo!()
}

fn main() {}
18 changes: 18 additions & 0 deletions src/test/ui/const-generics/defaults/cec-generic-default.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
error: unconstrained generic constant
--> $DIR/cec-generic-default.rs:5:54
|
LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
| ^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`

error: unconstrained generic constant
--> $DIR/cec-generic-default.rs:14:58
|
LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
| ^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`

error: aborting due to 2 previous errors

0 comments on commit e276b86

Please sign in to comment.