rust/tests/ui/const-generics
Matthias Krüger 081c607b0a
Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwU
Constrain const vars to error if const types are mismatched

When equating two consts of different types, if either are const variables, constrain them to the correct const error kind.

This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection.

Fixes #109296

The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message...

r? `@BoxyUwU`
2023-03-21 19:00:12 +01: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 Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
early const generic -> const parameter in err msg 2023-02-20 12:58:11 +01:00
generic_arg_infer Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generic_const_exprs Only expect a GAT const arg 2023-03-19 23:46:09 +00:00
infer diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
issues Add regression test for #105821 2023-03-01 22:01:12 +09: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 Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
parser-error-recovery diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07: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
bad-generic-in-copy-impl.rs Suppress copy impl error when post-normalized type references errors 2023-03-08 00:12:33 +00:00
bad-generic-in-copy-impl.stderr Suppress copy impl error when post-normalized type references errors 2023-03-08 00:12:33 +00:00
bad-subst-const-kind.rs Constrain const vars to error if const types are mismatched 2023-03-19 03:45:47 +00:00
bad-subst-const-kind.stderr Constrain const vars to error if const types are mismatched 2023-03-19 03:45:47 +00: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 Error code E0794 for late-bound lifetime parameter error. 2023-03-07 21:26:19 +01:00
const-arg-in-const-arg.min.stderr Error code E0794 for late-bound lifetime parameter error. 2023-03-07 21:26:19 +01: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 Remove save-analysis. 2023-02-16 15:14:45 +11:00
const-argument-non-static-lifetime.rs Remove save-analysis. 2023-02-16 15:14:45 +11: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 Remove save-analysis. 2023-02-16 15:14:45 +11:00
const-param-type-depends-on-type-param-ungated.stderr Remove save-analysis. 2023-02-16 15:14:45 +11: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 Specify what 'this' actually is 2023-02-21 05:21:07 +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 Specify what 'this' actually is 2023-02-21 05:21:07 +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 diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07: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 diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
invalid-const-arg-for-type-param.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
invalid-constant-in-args.rs diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07:00
invalid-constant-in-args.stderr diagnostics: remove inconsistent English article "this" from E0107 2023-02-23 10:27:06 -07: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 add predicate evaluation logic 2023-02-17 09:32:39 +00:00
nested-type.rs add predicate evaluation logic 2023-02-17 09:32:39 +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 Use param's real type in try_eval_lit_or_param 2023-03-09 20:49:11 +00:00
type_mismatch.stderr Use param's real type in try_eval_lit_or_param 2023-03-09 20:49:11 +00:00
type_not_in_scope.rs Use param's real type in try_eval_lit_or_param 2023-03-09 20:49:11 +00:00
type_not_in_scope.stderr Use param's real type in try_eval_lit_or_param 2023-03-09 20:49:11 +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 Specify what 'this' actually is 2023-02-21 05:21:07 +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