-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #81433 - lcnr:stop-looking-into-ty-alias, r=oli-obk
const_evaluatable: stop looking into type aliases see https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const_evaluatable.3A.20type.20alias r? `@oli-obk`
- Loading branch information
Showing
5 changed files
with
35 additions
and
38 deletions.
There are no files selected for viewing
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
8 changes: 7 additions & 1 deletion
8
src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/simple_fail.rs:9:48 | ||
| | ||
LL | fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized { | ||
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/simple_fail.rs:6:33 | ||
| | ||
LL | type Arr<const N: usize> = [u8; N - 1]; | ||
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
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
6 changes: 4 additions & 2 deletions
6
src/test/ui/const-generics/const_evaluatable_checked/simple_fail.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
14 changes: 14 additions & 0 deletions
14
src/test/ui/const-generics/const_evaluatable_checked/ty-alias-substitution.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 @@ | ||
// check-pass | ||
// Test that we correctly substitute generic arguments for type aliases. | ||
#![feature(const_generics, const_evaluatable_checked)] | ||
#![allow(incomplete_features)] | ||
|
||
type Alias<T, const N: usize> = [T; N + 1]; | ||
|
||
fn foo<const M: usize>() -> Alias<u32, M> where [u8; M + 1]: Sized { | ||
[0; M + 1] | ||
} | ||
|
||
fn main() { | ||
foo::<0>(); | ||
} |