forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#61805 - davidtwco:ice-const-generic-repeat-…
…expr-count-sequel, r=varkor typeck: Fix ICE for blocks in repeat expr count. Fixes rust-lang#61336 (again). This PR fixes an ICE that occured when a block expression resolving to a const generic was used for the count of an array repeat expression. r? @varkor
- Loading branch information
Showing
3 changed files
with
43 additions
and
12 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
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)] | ||
//~^ 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]); | ||
} |
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 @@ | ||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash | ||
--> $DIR/issue-61336-2.rs:1:12 | ||
| | ||
LL | #![feature(const_generics)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied | ||
--> $DIR/issue-61336-2.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`. |