diff options
| author | bors <bors@rust-lang.org> | 2021-07-24 20:01:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-24 20:01:51 +0000 |
| commit | d9aa28767287670df6cf823b94629122e04442c0 (patch) | |
| tree | 65a1904d98acc4b5afd896d93652ae506ece8e3c /compiler/rustc_mir/src/transform/coverage/graph.rs | |
| parent | bddb59cf07efcf6e606f16b87f85e3ecd2c1ca69 (diff) | |
| parent | d1e5e72f7d25cc60ccfc54d3cd3e1ef3efa3dab9 (diff) | |
| download | rust-d9aa28767287670df6cf823b94629122e04442c0.tar.gz rust-d9aa28767287670df6cf823b94629122e04442c0.zip | |
Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakis
dont provide fwd declared params to cg defaults
Fixes #83938
```rust
#![feature(const_evaluatable_checked, const_generics, const_generics_defaults)]
#![allow(incomplete_features)]
pub struct Bar<const N: usize, const M: usize = { N + 1 }>;
pub fn foo<const N1: usize>() -> Bar<N1> { loop {} }
fn main() {}
```
This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE.
This PR doesn't handle the predicates of the const so
```rust
trait Foo<const N: usize> { const Assoc: usize; }
pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>;
```
Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly.
```rust
trait Foo<const N: usize> {}
struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>;
```
This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params
PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
Diffstat (limited to 'compiler/rustc_mir/src/transform/coverage/graph.rs')
0 files changed, 0 insertions, 0 deletions
