rust/src/test/ui/const-generics/defaults
bors d9aa287672 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)
2021-07-24 20:01:51 +00:00
..
auxiliary loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
cec-concrete-default.rs redo tests 2021-07-10 17:38:47 +01:00
cec-concrete-default.stderr redo tests 2021-07-10 17:38:47 +01:00
cec-generic-default-mismatched-types.rs redo tests 2021-07-10 17:38:47 +01:00
cec-generic-default-mismatched-types.stderr redo tests 2021-07-10 17:38:47 +01:00
cec-generic-default.rs redo tests 2021-07-10 17:38:47 +01:00
cec-generic-default.stderr redo tests 2021-07-10 17:38:47 +01:00
complex-generic-default-expr.min.stderr only check cg defaults wf once instantiated 2021-07-08 22:57:10 +02:00
complex-generic-default-expr.rs only check cg defaults wf once instantiated 2021-07-08 22:57:10 +02:00
complex-unord-param.min.stderr Take type defaults into account in suggestions to reorder generic parameters 2020-12-30 16:00:25 -05:00
complex-unord-param.rs Prefer 4 spaces 2021-03-29 17:32:27 +09:00
const-default.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
const-param-as-default-value.rs completion uwu 2021-05-13 11:37:32 +01:00
const-param-in-ty-defaults.rs completion uwu 2021-05-13 11:37:32 +01:00
default-annotation.rs Prefer 4 spaces 2021-03-29 17:32:27 +09:00
default-const-param-cannot-reference-self.rs Change type param -> generic param 2021-07-14 19:22:39 +01:00
default-const-param-cannot-reference-self.stderr OOPS 2021-07-14 19:38:58 +01:00
default-on-impl.full.stderr loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
default-on-impl.min.stderr loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
default-on-impl.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
default-param-wf-concrete.rs completion uwu 2021-05-13 11:37:32 +01:00
default-param-wf-concrete.stderr wow 2021-05-13 14:00:04 +01:00
external.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
forward-declared.rs Add test for forward declared const param defaults 2021-06-01 17:44:54 +01:00
forward-declared.stderr Add test for forward declared const param defaults 2021-06-01 17:44:54 +01:00
intermixed-lifetime.full.stderr loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
intermixed-lifetime.min.stderr Make lifetime ordering error pretty print const param defaults 2021-05-29 03:54:32 +01:00
intermixed-lifetime.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
mismatch.full.stderr note uwuuu 2021-06-07 10:09:47 +01:00
mismatch.min.stderr note uwuuu 2021-06-07 10:09:47 +01:00
mismatch.rs note uwuuu 2021-06-07 10:09:47 +01:00
needs-feature.min.stderr Take type defaults into account in suggestions to reorder generic parameters 2020-12-30 16:00:25 -05:00
needs-feature.none.stderr Take type defaults into account in suggestions to reorder generic parameters 2020-12-30 16:00:25 -05:00
needs-feature.rs Prefer 4 spaces 2021-03-29 17:32:27 +09:00
param-order-err-pretty-prints-default.rs Make lifetime ordering error pretty print const param defaults 2021-05-29 03:54:32 +01:00
param-order-err-pretty-prints-default.stderr Make lifetime ordering error pretty print const param defaults 2021-05-29 03:54:32 +01:00
pretty-printing-ast.rs completion uwu 2021-05-13 11:37:32 +01:00
pretty-printing-ast.stdout completion uwu 2021-05-13 11:37:32 +01:00
repr-c-issue-82792.rs completion uwu 2021-05-13 11:37:32 +01:00
simple-defaults.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
type-default-const-param-name.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
wrong-order.full.stderr loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
wrong-order.min.stderr loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00
wrong-order.rs loosen ordering restricts for const_generics_defaults 2021-04-21 15:25:58 +02:00