rust/src/test/ui/const-generics
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
..
array-impls Replace IntoIter::new with IntoIterator::into_iter in std 2021-06-02 16:09:04 +06:00
auxiliary move const-generic issues into seperate directory 2021-07-19 07:43:48 +02:00
const_evaluatable_checked Support HIR wf checking for function signatures 2021-07-20 10:58:14 -05:00
defaults Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakis 2021-07-24 20:01:51 +00:00
infer update tests 2020-12-26 18:24:10 +01:00
issues move const-generic issues into seperate directory 2021-07-19 07:43:48 +02:00
late-bound-vars correctly deal with late-bound lifetimes in anon consts 2021-01-16 19:27:42 +01:00
min_const_generics Address PR feedback 2021-06-25 14:51:56 +02:00
occurs-check Various diagnostics clean ups/tweaks 2021-07-19 08:43:35 -07:00
std fixed const_generics error help 2021-01-05 00:01:48 -07:00
type-dependent fixed const_generics error help 2021-01-05 00:01:48 -07:00
apit-with-const-param.rs update tests 2020-12-26 18:24:10 +01:00
arg-in-pat-1.rs support pattern as const parents in type_of 2020-12-31 14:10:49 +01:00
arg-in-pat-2.rs support pattern as const parents in type_of 2020-12-31 14:10:49 +01:00
arg-in-pat-3.rs support pattern as const parents in type_of 2020-12-31 14:10:49 +01:00
argument_order.full.stderr update tests 2020-12-26 18:24:10 +01:00
argument_order.min.stderr update tests 2020-12-26 18:24:10 +01:00
argument_order.rs update tests 2020-12-26 18:24:10 +01:00
array-size-in-generic-struct-param.full.stderr update tests 2020-12-26 18:24:10 +01:00
array-size-in-generic-struct-param.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
array-size-in-generic-struct-param.rs update tests 2020-12-26 18:24:10 +01:00
array-wrapper-struct-ctor.rs update tests 2020-12-26 18:24:10 +01:00
associated-type-bound-fail.full.stderr update tests 2020-12-26 18:24:10 +01:00
associated-type-bound-fail.min.stderr update tests 2020-12-26 18:24:10 +01:00
associated-type-bound-fail.rs update tests 2020-12-26 18:24:10 +01:00
associated-type-bound.rs update tests 2020-12-26 18:24:10 +01:00
broken-mir-1.rs update tests 2020-12-26 18:24:10 +01:00
broken-mir-2.rs update tests 2020-12-26 18:24:10 +01:00
cannot-infer-type-for-const-param.rs update tests 2020-12-26 18:24:10 +01:00
closing-args-token.full.stderr update tests 2020-12-26 18:24:10 +01:00
closing-args-token.min.stderr update tests 2020-12-26 18:24:10 +01:00
closing-args-token.rs update tests 2020-12-26 18:24:10 +01:00
coerce_unsized_array.rs update tests 2020-12-26 18:24:10 +01:00
concrete-const-as-fn-arg.rs update tests 2020-12-26 18:24:10 +01:00
concrete-const-impl-method.rs update tests 2020-12-26 18:24:10 +01:00
condition-in-trait-const-arg.rs update tests 2020-12-26 18:24:10 +01:00
conservative_is_privately_uninhabited_uses_correct_param_env-1.rs yeet 2021-02-23 23:35:59 +00:00
conservative_is_privately_uninhabited_uses_correct_param_env-2.rs yeet 2021-02-23 23:35:59 +00:00
const-arg-in-const-arg.min.stderr update tests 2020-12-26 18:24:10 +01:00
const-arg-in-const-arg.rs update tests 2020-12-26 18:24:10 +01:00
const-arg-in-fn.rs update tests 2020-12-26 18:24:10 +01:00
const-arg-type-arg-misordered.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-arg-type-arg-misordered.min.stderr update tests 2020-12-26 18:24:10 +01:00
const-arg-type-arg-misordered.rs update tests 2020-12-26 18:24:10 +01:00
const-argument-cross-crate-mismatch.full.stderr add test for lazy norm err 2021-01-23 22:47:36 +01:00
const-argument-cross-crate-mismatch.min.stderr add test for lazy norm err 2021-01-23 22:47:36 +01:00
const-argument-cross-crate-mismatch.rs add test for lazy norm err 2021-01-23 22:47:36 +01:00
const-argument-cross-crate.rs Add revisions to const generic UI tests. 2020-09-10 09:40:54 +02:00
const-argument-if-length.full.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
const-argument-if-length.min.stderr give full path of constraint in suggest_constraining_type_param 2021-03-31 09:47:31 +08:00
const-argument-if-length.rs update tests 2020-12-26 18:24:10 +01:00
const-argument-non-static-lifetime.rs Update stderr files 2020-08-12 20:04:36 +00:00
const-expression-parameter.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-expression-parameter.min.stderr update tests 2020-12-26 18:24:10 +01:00
const-expression-parameter.rs update tests 2020-12-26 18:24:10 +01:00
const-fn-with-const-param.rs update tests 2020-12-26 18:24:10 +01:00
const-generic-array-wrapper.rs update tests 2020-12-26 18:24:10 +01:00
const-generic-type_name.rs update tests 2020-12-26 18:24:10 +01:00
const-param-after-const-literal-arg.rs update tests 2020-12-26 18:24:10 +01:00
const-param-before-other-params.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-before-other-params.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
const-param-before-other-params.rs update tests 2020-12-26 18:24:10 +01:00
const-param-elided-lifetime.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-elided-lifetime.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
const-param-elided-lifetime.rs update tests 2020-12-26 18:24:10 +01:00
const-param-from-outer-fn.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-from-outer-fn.min.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-from-outer-fn.rs update tests 2020-12-26 18:24:10 +01:00
const-param-hygiene.rs update tests 2020-12-26 18:24:10 +01:00
const-param-in-async.rs update tests 2020-12-26 18:24:10 +01:00
const-param-in-trait.rs update tests 2020-12-26 18:24:10 +01:00
const-param-shadowing.rs update tests 2020-12-26 18:24:10 +01:00
const-param-shadowing.stderr Update w/ comments 2021-02-16 05:14:22 +00:00
const-param-type-depends-on-const-param.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-type-depends-on-const-param.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
const-param-type-depends-on-const-param.rs update tests 2020-12-26 18:24:10 +01:00
const-param-type-depends-on-type-param-ungated.rs update tests 2020-12-26 18:24:10 +01:00
const-param-type-depends-on-type-param-ungated.stderr update tests 2020-12-26 18:24:10 +01:00
const-param-type-depends-on-type-param.full.stderr Add help message for unused type param 2021-05-01 21:58:06 +00:00
const-param-type-depends-on-type-param.min.stderr Add help message for unused type param 2021-05-01 21:58:06 +00:00
const-param-type-depends-on-type-param.rs update tests 2020-12-26 18:24:10 +01:00
const-parameter-uppercase-lint.full.stderr update tests 2020-12-26 18:24:10 +01:00
const-parameter-uppercase-lint.min.stderr update tests 2020-12-26 18:24:10 +01:00
const-parameter-uppercase-lint.rs update tests 2020-12-26 18:24:10 +01:00
const-types.rs update tests 2020-12-26 18:24:10 +01:00
core-types.rs update tests 2020-12-26 18:24:10 +01:00
cross_crate_complex.rs update tests 2020-12-26 18:24:10 +01:00
derive-debug-array-wrapper.rs update tests 2020-12-26 18:24:10 +01:00
diagnostics.rs Update w/ comments 2021-02-16 05:14:22 +00:00
diagnostics.stderr Fix impl type parameter suggestion involving consts 2021-05-07 18:29:25 +02:00
different_byref.full.stderr update tests 2020-12-26 18:24:10 +01:00
different_byref.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
different_byref.rs update tests 2020-12-26 18:24:10 +01:00
different_byref_simple.full.stderr update tests 2020-12-26 18:24:10 +01:00
different_byref_simple.min.stderr update tests 2020-12-26 18:24:10 +01:00
different_byref_simple.rs update tests 2020-12-26 18:24:10 +01:00
dont-evaluate-array-len-on-err-1.rs the environment round here is awfully empty 2021-02-15 11:38:20 +00:00
dont-evaluate-array-len-on-err-1.stderr Various diagnostics clean ups/tweaks 2021-07-19 08:43:35 -07:00
dyn-supertraits.rs update tests 2020-12-26 18:24:10 +01:00
exhaustive-value.full.stderr Various diagnostics clean ups/tweaks 2021-07-19 08:43:35 -07:00
exhaustive-value.min.stderr Various diagnostics clean ups/tweaks 2021-07-19 08:43:35 -07:00
exhaustive-value.rs update tests 2020-12-26 18:24:10 +01:00
fn-const-param-call.full.stderr update tests 2020-12-26 18:24:10 +01:00
fn-const-param-call.min.stderr update tests 2020-12-26 18:24:10 +01:00
fn-const-param-call.rs update tests 2020-12-26 18:24:10 +01:00
fn-const-param-infer.full.stderr update tests 2020-12-26 18:24:10 +01:00
fn-const-param-infer.min.stderr update tests 2020-12-26 18:24:10 +01:00
fn-const-param-infer.rs update tests 2020-12-26 18:24:10 +01:00
fn-taking-const-generic-array.rs update tests 2020-12-26 18:24:10 +01:00
forbid-non-structural_match-types.full.stderr update tests 2020-12-26 18:24:10 +01:00
forbid-non-structural_match-types.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
forbid-non-structural_match-types.rs update tests 2020-12-26 18:24:10 +01:00
foreign-item-const-parameter.full.stderr update tests 2020-12-26 18:24:10 +01:00
foreign-item-const-parameter.min.stderr update tests 2020-12-26 18:24:10 +01:00
foreign-item-const-parameter.rs update tests 2020-12-26 18:24:10 +01:00
generic-function-call-in-array-length.full.stderr update tests 2020-12-26 18:24:10 +01:00
generic-function-call-in-array-length.min.stderr update tests 2020-12-26 18:24:10 +01:00
generic-function-call-in-array-length.rs update tests 2020-12-26 18:24:10 +01:00
generic-param-mismatch.full.stderr update tests 2020-12-26 18:24:10 +01:00
generic-param-mismatch.min.stderr update tests 2020-12-26 18:24:10 +01:00
generic-param-mismatch.rs update tests 2020-12-26 18:24:10 +01:00
generic-sum-in-array-length.full.stderr update tests 2020-12-26 18:24:10 +01:00
generic-sum-in-array-length.min.stderr update tests 2020-12-26 18:24:10 +01:00
generic-sum-in-array-length.rs update tests 2020-12-26 18:24:10 +01:00
impl-const-generic-struct.rs update tests 2020-12-26 18:24:10 +01:00
impl-trait-with-const-arguments.full.stderr Bless UI tests 2021-06-29 12:49:08 +02:00
impl-trait-with-const-arguments.min.stderr Bless UI tests 2021-06-29 12:49:08 +02:00
impl-trait-with-const-arguments.rs update tests 2020-12-26 18:24:10 +01:00
incorrect-number-of-const-args.full.stderr improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
incorrect-number-of-const-args.min.stderr improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
incorrect-number-of-const-args.rs improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
infer_arg_from_pat.rs update tests 2020-12-26 18:24:10 +01:00
infer_arr_len_from_pat.rs update tests 2020-12-26 18:24:10 +01:00
integer-literal-generic-arg-in-where-clause.rs update tests 2020-12-26 18:24:10 +01:00
intrinsics-type_name-as-const-argument.full.stderr update tests 2020-12-26 18:24:10 +01:00
intrinsics-type_name-as-const-argument.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
intrinsics-type_name-as-const-argument.rs update tests 2020-12-26 18:24:10 +01:00
invalid-const-arg-for-type-param.rs improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
invalid-const-arg-for-type-param.stderr improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
invalid-constant-in-args.rs Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00
invalid-constant-in-args.stderr improve diagnosts for GATs 2021-05-11 14:09:46 +02:00
invalid-enum.rs Update w/ comments 2021-02-16 05:14:22 +00:00
invalid-enum.stderr Update w/ comments 2021-02-16 05:14:22 +00:00
macro_rules-braces.full.stderr Show macro name in 'this error originates in macro' message 2021-05-12 19:03:06 -04:00
macro_rules-braces.min.stderr update tests 2020-12-26 18:24:10 +01:00
macro_rules-braces.rs update tests 2020-12-26 18:24:10 +01:00
mut-ref-const-param-array.rs update tests 2020-12-26 18:24:10 +01:00
nested-type.full.stderr update tests 2020-12-26 18:24:10 +01:00
nested-type.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
nested-type.rs update tests 2020-12-26 18:24:10 +01:00
params-in-ct-in-ty-param-lazy-norm.full.stderr supply substs to anon consts in defaults 2021-04-21 15:25:58 +02:00
params-in-ct-in-ty-param-lazy-norm.min.stderr supply substs to anon consts in defaults 2021-04-21 15:25:58 +02:00
params-in-ct-in-ty-param-lazy-norm.rs supply substs to anon consts in defaults 2021-04-21 15:25:58 +02:00
promotion.rs update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param-deref.full.stderr update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param-deref.min.stderr update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param-deref.rs update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param.full.stderr update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param.min.stderr update tests 2020-12-26 18:24:10 +01:00
raw-ptr-const-param.rs update tests 2020-12-26 18:24:10 +01:00
slice-const-param-mismatch.full.stderr update tests 2020-12-26 18:24:10 +01:00
slice-const-param-mismatch.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
slice-const-param-mismatch.rs update tests 2020-12-26 18:24:10 +01:00
slice-const-param.min.stderr fixed const_generics error help 2021-01-05 00:01:48 -07:00
slice-const-param.rs update tests 2020-12-26 18:24:10 +01:00
struct-with-invalid-const-param.full.stderr update tests 2020-12-26 18:24:10 +01:00
struct-with-invalid-const-param.min.stderr update tests 2020-12-26 18:24:10 +01:00
struct-with-invalid-const-param.rs update tests 2020-12-26 18:24:10 +01:00
struct-with-invalid-const-param.stderr Do not suggest similarly named enclosing item 2020-08-10 12:04:10 -07:00
suggest_const_for_array.rs Add check for array/usize mismatch in astconv 2021-01-04 10:07:15 +00:00
suggest_const_for_array.stderr Add check for array/usize mismatch in astconv 2021-01-04 10:07:15 +00:00
trait-const-args.rs update tests 2020-12-26 18:24:10 +01:00
transmute-const-param-static-reference.min.stderr Run full const-generics test for issue-72293 2021-06-11 06:48:34 +09:00
transmute-const-param-static-reference.rs Run full const-generics test for issue-72293 2021-06-11 06:48:34 +09:00
transparent-maybeunit-array-wrapper.rs update tests 2020-12-26 18:24:10 +01:00
type-after-const-ok.min.stderr update tests 2020-12-26 18:24:10 +01:00
type-after-const-ok.rs update tests 2020-12-26 18:24:10 +01:00
type_mismatch.rs Add a second regression test 2021-03-19 13:44:50 +00:00
type_mismatch.stderr Add a second regression test 2021-03-19 13:44:50 +00:00
type_not_in_scope.rs Do not ICE on ty::Error as an error must already have been reported 2021-03-19 11:46:27 +00:00
type_not_in_scope.stderr Do not ICE on ty::Error as an error must already have been reported 2021-03-19 11:46:27 +00:00
type_of_anon_const.rs update tests 2020-12-26 18:24:10 +01:00
types-mismatch-const-args.full.stderr update tests 2020-12-26 18:24:10 +01:00
types-mismatch-const-args.min.stderr update tests 2020-12-26 18:24:10 +01:00
types-mismatch-const-args.rs update tests 2020-12-26 18:24:10 +01:00
uninferred-consts-during-codegen-1.rs update tests 2020-12-26 18:24:10 +01:00
uninferred-consts-during-codegen-2.rs update tests 2020-12-26 18:24:10 +01:00
unknown_adt.full.stderr update tests 2020-12-26 18:24:10 +01:00
unknown_adt.min.stderr update tests 2020-12-26 18:24:10 +01:00
unknown_adt.rs update tests 2020-12-26 18:24:10 +01:00
unused-const-param.rs update tests 2020-12-26 18:24:10 +01:00
unused-type-param-suggestion.rs Add help message for unused type param 2021-05-01 21:58:06 +00:00
unused-type-param-suggestion.stderr Add help message for unused type param 2021-05-01 21:58:06 +00:00
unused_braces.fixed unused_delims: trim expr 2020-08-10 12:04:51 +02:00
unused_braces.full.fixed update tests 2020-12-26 18:24:10 +01:00
unused_braces.full.stderr update tests 2020-12-26 18:24:10 +01:00
unused_braces.min.fixed update tests 2020-12-26 18:24:10 +01:00
unused_braces.min.stderr update tests 2020-12-26 18:24:10 +01:00
unused_braces.rs update tests 2020-12-26 18:24:10 +01:00
wf-misc.full.stderr update tests 2020-12-26 18:24:10 +01:00
wf-misc.min.stderr update tests 2020-12-26 18:24:10 +01:00
wf-misc.rs update tests 2020-12-26 18:24:10 +01:00
where-clauses.rs update tests 2020-12-26 18:24:10 +01:00