-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
src/test/ui/const-generics/defaults/cec-build-subst-ice.rs
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/test/ui/const-generics/defaults/cec-build-subst-ice.stderr
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/test/ui/const-generics/defaults/cec-concrete-default.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
src/test/ui/const-generics/defaults/cec-concrete-default.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
16 changes: 16 additions & 0 deletions
16
src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
24
src/test/ui/const-generics/defaults/cec-generic-default.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
18
src/test/ui/const-generics/defaults/cec-generic-default.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|