Rollup merge of #61698 - davidtwco:ice-const-generic-length, r=varkor
typeck: Fix const generic in repeat param ICE. Fixes #61336. Turns out this wasn't related to #49147 after all. r? @varkor
This commit is contained in:
commit
bd57c187fb
6 changed files with 104 additions and 25 deletions
12
src/test/ui/const-generics/issue-61336-1.rs
Normal file
12
src/test/ui/const-generics/issue-61336-1.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
|
||||
[x; N]
|
||||
//~^ ERROR array lengths can't depend on generic parameters
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: [u32; 5] = f::<u32, 5>(3);
|
||||
assert_eq!(x, [3u32; 5]);
|
||||
}
|
||||
14
src/test/ui/const-generics/issue-61336-1.stderr
Normal file
14
src/test/ui/const-generics/issue-61336-1.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/issue-61336-1.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: array lengths can't depend on generic parameters
|
||||
--> $DIR/issue-61336-1.rs:5:9
|
||||
|
|
||||
LL | [x; N]
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
16
src/test/ui/const-generics/issue-61336.rs
Normal file
16
src/test/ui/const-generics/issue-61336.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
|
||||
[x; N]
|
||||
}
|
||||
|
||||
fn g<T, const N: usize>(x: T) -> [T; N] {
|
||||
[x; N]
|
||||
//~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied [E0277]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x: [u32; 5] = f::<u32, 5>(3);
|
||||
assert_eq!(x, [3u32; 5]);
|
||||
}
|
||||
18
src/test/ui/const-generics/issue-61336.stderr
Normal file
18
src/test/ui/const-generics/issue-61336.stderr
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/issue-61336.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied
|
||||
--> $DIR/issue-61336.rs:9:5
|
||||
|
|
||||
LL | [x; N]
|
||||
| ^^^^^^ the trait `std::marker::Copy` is not implemented for `T`
|
||||
|
|
||||
= help: consider adding a `where T: std::marker::Copy` bound
|
||||
= note: the `Copy` trait is required because the repeated element will be copied
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue