rust/tests/ui/const-generics
bors 068161ea48 Auto merge of #107940 - BoxyUwU:const_ty_assertion_use_semantic_equality, r=compiler-errors
use semantic equality for const param type equality assertion

Fixes #107898

See added test for what caused this ICE

---

The current in assertion in `relate.rs` is rather inadequate when keeping in mind future expansions to const generics:
- it will ICE when there are infer vars in a projection in a const param ty
- it will spurriously return false when either ty has infer vars because of using `==` instead of `infcx.at(..).eq`
- i am also unsure if it would be possible with `adt_const_params` to craft a situation where the const param type is not wf causing `normalize_erasing_regions` to `bug!` when we would have emitted a diagnostic.

This impl feels pretty Not Great to me  although i am not sure what a better idea would be.

- We have to have the logic behind a query because neither `relate.rs` or `combine.rs` have access to trait solving machinery (without evaluating nested obligations this assert will become _far_ less useful under lazy norm, which consts are already doing)
- `relate.rs` does not have access to canonicalization machinery which is necessary in order to have types potentially containing infer vars in query arguments.

We could possible add a method to `TypeRelation` to do this assertion rather than a query but to avoid implementing the same logic over and over we'd probably end up with the logic in a free function somewhere in `rustc_trait_selection` _anyway_ so I don't think that would be much better.

We could also just remove this assertion, it should not actually be necessary for it to be present. It has caught some bugs in the past though so if possible I would like to keep it.

r? `@compiler-errors`
2023-02-15 05:17:58 +00:00
..
array-impls Move /src/test to /tests 2023-01-11 09:32:08 +00:00
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
backcompat Move /src/test to /tests 2023-01-11 09:32:08 +00:00
defaults Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
early Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic_arg_infer Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic_const_exprs make relate's const ty assertion use semantic equality 2023-02-11 23:05:16 +00:00
infer Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issues Introduce ReError 2023-02-09 10:26:49 +00:00
late-bound-vars Move /src/test to /tests 2023-01-11 09:32:08 +00:00
min_const_generics preserve delim spans during macro_rules! expansion if able 2023-01-20 20:16:37 +01:00
occurs-check Move /src/test to /tests 2023-01-11 09:32:08 +00:00
parser-error-recovery Move /src/test to /tests 2023-01-11 09:32:08 +00:00
std Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-dependent Move /src/test to /tests 2023-01-11 09:32:08 +00:00
apit-with-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
arg-in-pat-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
arg-in-pat-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
arg-in-pat-3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
argument_order.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
argument_order.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array-wrapper-struct-ctor.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
assoc_const_eq_diagnostic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
assoc_const_eq_diagnostic.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
associated-type-bound-fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
associated-type-bound-fail.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
associated-type-bound.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bad-const-generic-exprs.rs recover more unbraced const args 2023-01-27 19:26:04 +01:00
bad-const-generic-exprs.stderr recover more unbraced const args 2023-01-27 19:26:04 +01:00
broken-mir-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
broken-mir-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cannot-infer-type-for-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
coerce_unsized_array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
concrete-const-as-fn-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
concrete-const-impl-method.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
condition-in-trait-const-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_trait_fn-issue-88433.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-in-const-arg.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-in-const-arg.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-in-const-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-in-fn.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-type-arg-misordered.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-arg-type-arg-misordered.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-cross-crate-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-cross-crate-mismatch.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-cross-crate.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-if-length.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-if-length.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-if-length.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-non-static-lifetime.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-argument-non-static-lifetime.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-fn-with-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-generic-default-wont-borrowck.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-generic-default-wont-borrowck.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-generic-function.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-generic-function.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-generic-type_name.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-after-const-literal-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-before-other-params.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-before-other-params.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-elided-lifetime.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-elided-lifetime.min.stderr Introduce ReError 2023-02-09 10:26:49 +00:00
const-param-elided-lifetime.rs Introduce ReError 2023-02-09 10:26:49 +00:00
const-param-in-async.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-const-param.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-const-param.min.stderr defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
const-param-type-depends-on-const-param.rs defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
const-param-type-depends-on-type-param-ungated.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-type-param-ungated.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-type-param.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-type-param.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-param-type-depends-on-type-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-parameter-uppercase-lint.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const-parameter-uppercase-lint.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
core-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cross_crate_complex.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deref-into-array-generic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
different_generic_args_array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
different_generic_args_array.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
different_generic_args.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
different_generic_args.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
different_generic_args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont-evaluate-array-len-on-err-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont-evaluate-array-len-on-err-1.stderr defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
dyn-supertraits.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ensure_is_evaluatable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ensure_is_evaluatable.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum-variants.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
exhaustive-value.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
exhaustive-value.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
expose-default-substs-param-env.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
float-generic.adt_const_params.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
float-generic.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
float-generic.simple.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn_with_two_const_inputs.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn_with_two_const_inputs.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn_with_two_same_const_inputs.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-call.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-call.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-call.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-infer.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-infer.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn-const-param-infer.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
forbid-non-structural_match-types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
forbid-non-structural_match-types.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
foreign-item-const-parameter.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
foreign-item-const-parameter.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-param-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic-param-mismatch.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-68875.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-68875.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-const-generic-function-return-ty.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ice-const-generic-function-return-ty.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
impl-const-generic-struct.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
incorrect-number-of-const-args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
incorrect-number-of-const-args.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infer_arg_from_pat.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
infer_arr_len_from_pat.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inhabited-assoc-ty-ice-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inhabited-assoc-ty-ice-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
integer-literal-generic-arg-in-where-clause.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
intrinsics-type_name-as-const-argument.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
intrinsics-type_name-as-const-argument.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-const-arg-for-type-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-const-arg-for-type-param.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-constant-in-args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-constant-in-args.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-enum.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invalid-enum.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invariant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
invariant.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-46511.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-46511.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-66451.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-66451.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-70408.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80471.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-80471.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-93647.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-93647.stderr fix fmt and bless 2023-01-12 02:28:38 +00:00
issue-97007.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-102124.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-105689.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-106419-struct-with-multiple-const-params.rs Added UI test case for issue #106419 2023-01-19 15:39:05 +01:00
legacy-const-generics-bad.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
legacy-const-generics-bad.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
legacy-const-generics.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nested-type.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nested-type.min.stderr defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
nested-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
outer-lifetime-in-const-generic-default.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
outer-lifetime-in-const-generic-default.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
overlapping_impls.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
params-in-ct-in-ty-param-lazy-norm.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
params-in-ct-in-ty-param-lazy-norm.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
params-in-ct-in-ty-param-lazy-norm.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
parent_generics_of_encoding_impl_trait.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
parent_generics_of_encoding_impl_trait.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
parent_generics_of_encoding.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
projection-as-arg-const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
projection-as-arg-const.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
promotion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param-deref.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param-deref.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param-deref.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
raw-ptr-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-const-param-mismatch.full.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-const-param-mismatch.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-const-param-mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
sneaky-array-repeat-expr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
sneaky-array-repeat-expr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-with-invalid-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
struct-with-invalid-const-param.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest_const_for_array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suggest_const_for_array.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
trait-const-args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const-param-static-reference.min.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transmute-const-param-static-reference.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
transparent-maybeunit-array-wrapper.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
try_unify_ignore_lifetimes.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
two_matching_preds.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type_mismatch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type_mismatch.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
type_not_in_scope.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type_not_in_scope.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
type_of_anon_const.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
type-after-const-ok.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
types-mismatch-const-args.full.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
types-mismatch-const-args.min.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
types-mismatch-const-args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unify_with_nested_expr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unify_with_nested_expr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninferred-consts-during-codegen-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninferred-consts-during-codegen-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unknown_adt.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unknown_adt.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused_braces.fixed Fix unused_braces on generic const expr macro call 2023-01-14 15:49:08 +00:00
unused_braces.full.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused_braces.min.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused_braces.rs Fix unused_braces on generic const expr macro call 2023-01-14 15:49:08 +00:00
unused_braces.stderr Fix unused_braces on generic const expr macro call 2023-01-14 15:49:08 +00:00
unused-const-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused-type-param-suggestion.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unused-type-param-suggestion.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
where-clauses.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
wrong-normalization.rs Add test for implementation on projection 2023-02-10 14:44:54 +01:00
wrong-normalization.stderr Tighter spans for bad inherent impl types 2023-02-13 18:41:18 +00:00