rust/tests/ui/typeck
bors 8c3a94a1c7 Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwU
Represent type-level consts with new-and-improved `hir::ConstArg`

### Summary

This is a step toward `min_generic_const_exprs`. We now represent all const
generic arguments using an enum that differentiates between const *paths*
(temporarily just bare const params) and arbitrary anon consts that may perform
computations. This will enable us to cleanly implement the `min_generic_const_args`
plan of allowing the use of generics in paths used as const args, while
disallowing their use in arbitrary anon consts. Here is a summary of the salient
aspects of this change:

- Add `current_def_id_parent` to `LoweringContext`

  This is needed to track anon const parents properly once we implement
  `ConstArgKind::Path` (which requires moving anon const def-creation
  outside of `DefCollector`).

- Create `hir::ConstArgKind` enum with `Path` and `Anon` variants. Use it in the
  existing `hir::ConstArg` struct, replacing the previous `hir::AnonConst` field.

- Use `ConstArg` for all instances of const args. Specifically, use it instead
  of `AnonConst` for assoc item constraints, array lengths, and const param
  defaults.

- Some `ast::AnonConst`s now have their `DefId`s created in
  rustc_ast_lowering rather than `DefCollector`. This is because in some
  cases they will end up becoming a `ConstArgKind::Path` instead, which
  has no `DefId`. We have to solve this in a hacky way where we guess
  whether the `AnonConst` could end up as a path const since we can't
  know for sure until after name resolution (`N` could refer to a free
  const or a nullary struct). If it has no chance as being a const
  param, then we create a `DefId` in `DefCollector` -- otherwise we
  decide during ast_lowering. This will have to be updated once all path
  consts use `ConstArgKind::Path`.

- We explicitly use `ConstArgHasType` for array lengths, rather than
  implicitly relying on anon const type feeding -- this is due to the
  addition of `ConstArgKind::Path`.

- Some tests have their outputs changed, but the changes are for the
  most part minor (including removing duplicate or almost-duplicate
  errors). One test now ICEs, but it is for an incomplete, unstable
  feature and is now tracked at https://github.com/rust-lang/rust/issues/127009.

### Followup items post-merge

- Use `ConstArgKind::Path` for all const paths, not just const params.
- Fix (no github dont close this issue) #127009
- If a path in generic args doesn't resolve as a type, try to resolve as a const
  instead (do this in rustc_resolve). Then remove the special-casing from
  `rustc_ast_lowering`, so that all params will automatically be lowered as
  `ConstArgKind::Path`.
- (?) Consider making `const_evaluatable_unchecked` a hard error, or at least
  trying it in crater

r? `@BoxyUwU`
2024-07-19 08:44:51 +00:00
..
auxiliary
issue-87181
issue-114918 Add ConstArgKind::Path and make ConstArg its own HIR node 2024-07-16 19:27:28 -07:00
apit-with-error-type-in-sig.rs
apit-with-error-type-in-sig.stderr
assign-non-lval-derefmut.fixed
assign-non-lval-derefmut.rs
assign-non-lval-derefmut.stderr Change E0369 diagnostic give note information for foreign items. 2024-06-25 10:00:30 +08:00
assign-non-lval-mut-ref.fixed
assign-non-lval-mut-ref.rs
assign-non-lval-mut-ref.stderr
assign-non-lval-needs-deref.rs
assign-non-lval-needs-deref.stderr
autoderef-with-param-env-error.rs
autoderef-with-param-env-error.stderr
bad-index-due-to-nested.rs
bad-index-due-to-nested.stderr
bad-index-modulo-higher-ranked-regions.rs
bad-index-modulo-higher-ranked-regions.stderr
bad-recursive-type-sig-infer.rs
bad-recursive-type-sig-infer.stderr
bad-type-in-vec-contains.rs
bad-type-in-vec-contains.stderr
bad-type-in-vec-push.rs
bad-type-in-vec-push.stderr
call-block.rs
call-block.stderr
check-args-on-fn-err-2.rs
check-args-on-fn-err-2.stderr
check-args-on-fn-err.rs
check-args-on-fn-err.stderr
conversion-methods.rs
conversion-methods.stderr
cyclic_type_ice.rs
cyclic_type_ice.stderr Use ordinal number in argument error 2024-07-14 13:50:09 +09:00
deref-multi.rs
deref-multi.stderr
derive-sugg-arg-arity.rs
derive-sugg-arg-arity.stderr
do-not-suggest-adding-missing-zero-to-floating-point-number.rs
do-not-suggest-adding-missing-zero-to-floating-point-number.stderr
do-not-suggest-placeholder-to-const-static-without-type.rs
do-not-suggest-placeholder-to-const-static-without-type.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
dont-record-adjustments-when-pointing-at-arg.rs
dont-record-adjustments-when-pointing-at-arg.stderr
escaping_bound_vars.rs
escaping_bound_vars.stderr
explain_clone_autoref.rs
explain_clone_autoref.stderr
ice-self-mismatch-const-generics.rs
ice-self-mismatch-const-generics.stderr
ice-unexpected-region-123863.rs
ice-unexpected-region-123863.stderr
ice-with-expr-not-struct-127332.rs Move a span_bug under a condition that cx is tainted 2024-07-07 15:44:55 +05:30
ice-with-expr-not-struct-127332.stderr Move a span_bug under a condition that cx is tainted 2024-07-07 15:44:55 +05:30
invalid-stashed-level-issue-121812.rs
invalid-stashed-level-issue-121812.stderr
issue-1871.rs
issue-1871.stderr
issue-2063-resource.rs
issue-2063.rs
issue-7813.rs
issue-7813.stderr
issue-10401.rs
issue-10401.stderr
issue-10969.rs
issue-10969.stderr
issue-13853-2.rs
issue-13853-2.stderr
issue-13853-5.rs
issue-13853-5.stderr
issue-13853.rs
issue-13853.stderr
issue-16338.rs
issue-16338.stderr
issue-18937-1.rs
issue-18937.rs
issue-18937.stderr
issue-22375.rs
issue-29124.rs
issue-29124.stderr
issue-29181.rs
issue-29181.stderr
issue-31173.rs
issue-31173.stderr
issue-33575.rs
issue-33575.stderr
issue-36708.rs
issue-36708.stderr
issue-43189.rs
issue-43189.stderr
issue-46112.rs
issue-46112.stderr
issue-50687-ice-on-borrow.rs
issue-50687-ice-on-borrow.stderr
issue-52082-type-param-shadows-existing-type.rs
issue-52082-type-param-shadows-existing-type.stderr
issue-53712.rs Tweak slice and as_deref suggestion span 2024-07-04 05:50:21 +00:00
issue-53712.stderr Tweak raw-pointer field access and array indexing suggestions 2024-07-04 06:06:33 +00:00
issue-55810-must-typeck-match-pats-before-guards.rs
issue-57404.rs
issue-57404.stderr
issue-57673-ice-on-deref-of-boxed-trait.rs
issue-57673-ice-on-deref-of-boxed-trait.stderr
issue-61711-once-caused-rustc-inf-loop.rs
issue-65611.rs
issue-65611.stderr
issue-67971.rs
issue-67971.stderr
issue-68590-reborrow-through-derefmut.rs
issue-69378-ice-on-invalid-type-node-after-recovery.rs
issue-69378-ice-on-invalid-type-node-after-recovery.stderr
issue-72225-call-fnmut-through-derefmut.rs
issue-73592-borrow_mut-through-deref.fixed
issue-73592-borrow_mut-through-deref.rs
issue-73592-borrow_mut-through-deref.stderr
issue-74086.rs
issue-74086.stderr
issue-74933.rs
issue-75883.rs
issue-75883.stderr
issue-75889.rs
issue-75889.stderr
issue-79040.rs
issue-79040.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
issue-80207-unsized-return.rs
issue-80779.rs
issue-80779.stderr
issue-81293.rs
issue-81293.stderr
issue-81885.rs
issue-81885.stderr
issue-81943.rs
issue-81943.stderr
issue-82772.rs
issue-82772.stderr
issue-83621-placeholder-static-in-extern.rs
issue-83621-placeholder-static-in-extern.stderr
issue-83693.rs
issue-83693.stderr
issue-84160.rs
issue-84160.stderr
issue-84768.rs
issue-84768.stderr
issue-84831.rs
issue-84831.stderr
issue-86721-return-expr-ice.rev1.stderr
issue-86721-return-expr-ice.rev2.stderr
issue-86721-return-expr-ice.rs
issue-87771-ice-assign-assign-to-bool.rs
issue-87771-ice-assign-assign-to-bool.stderr
issue-87872-missing-inaccessible-field-literal.rs
issue-87872-missing-inaccessible-field-literal.stderr
issue-87872-missing-inaccessible-field-pattern.rs
issue-87872-missing-inaccessible-field-pattern.stderr
issue-88609.rs
issue-88643.rs
issue-88643.stderr
issue-88803-call-expr-method.fixed
issue-88803-call-expr-method.rs
issue-88803-call-expr-method.stderr
issue-88844.rs
issue-88844.stderr
issue-89044-wrapped-expr-method.fixed
issue-89044-wrapped-expr-method.rs
issue-89044-wrapped-expr-method.stderr
issue-89275.rs
issue-89275.stderr
issue-89806.rs
issue-89806.stderr
issue-89856.fixed
issue-89856.rs
issue-89856.stderr
issue-89935.rs
issue-90027-async-fn-return-suggestion.rs
issue-90027-async-fn-return-suggestion.stderr
issue-90101.rs
issue-90101.stderr
issue-90164.rs
issue-90164.stderr
issue-90319.rs
issue-90319.stderr
issue-90483-inaccessible-field-adjustment.rs
issue-90483-inaccessible-field-adjustment.stderr
issue-90804-incorrect-reference-suggestion.rs
issue-90804-incorrect-reference-suggestion.stderr
issue-91210-ptr-method.fixed
issue-91210-ptr-method.rs
issue-91210-ptr-method.stderr
issue-91267.rs
issue-91267.stderr
issue-91328.fixed
issue-91328.rs
issue-91328.stderr Tweak slice and as_deref suggestion span 2024-07-04 05:50:21 +00:00
issue-91334.rs
issue-91334.stderr
issue-91450-inner-ty-error.rs
issue-91450-inner-ty-error.stderr
issue-91633.rs
issue-92481.rs
issue-92481.stderr
issue-93486.rs
issue-93486.stderr
issue-96530.rs
issue-96530.stderr
issue-96738.rs
issue-96738.stderr
issue-98260.rs
issue-98260.stderr
issue-98982.rs
issue-98982.stderr
issue-100164.fixed
issue-100164.rs
issue-100164.stderr
issue-100246.rs
issue-100246.stderr
issue-100285.rs
issue-100285.stderr
issue-103899.rs
issue-104510-ice.rs
issue-104510-ice.stderr
issue-104513-ice.rs
issue-104513-ice.stderr
issue-104582.rs
issue-104582.stderr
issue-105946.rs
issue-105946.stderr
issue-106929.rs
issue-106929.stderr
issue-107087.rs
issue-107087.stderr
issue-107775.rs
issue-107775.stderr
issue-110017-format-into-help-deletes-macro.fixed
issue-110017-format-into-help-deletes-macro.rs
issue-110017-format-into-help-deletes-macro.stderr
issue-110052.rs
issue-110052.stderr
issue-112007-leaked-writeln-macro-internals.rs
issue-112007-leaked-writeln-macro-internals.stderr
issue-112252-ptr-arithmetics-help.fixed
issue-112252-ptr-arithmetics-help.rs
issue-112252-ptr-arithmetics-help.stderr
issue-112385-while-assign-lhs-place-expr-ice.rs
issue-112385-while-assign-lhs-place-expr-ice.stderr
issue-114423-ice-regression-in-suggestion.rs
issue-114423-ice-regression-in-suggestion.stderr
issue-114529-illegal-break-with-value.rs
issue-114529-illegal-break-with-value.stderr
issue-116473-ice-wrong-span-variant-args.rs
issue-116473-ice-wrong-span-variant-args.stderr
issue-116864.rs
issue-120856.rs
issue-120856.stderr
method-chain-gats.rs
method-chain-gats.stderr
mismatched-map-under-self.rs
mismatched-map-under-self.stderr Use verbose suggestion for changing arg type 2024-07-05 20:58:33 +00:00
missing-private-fields-in-struct-literal.rs
missing-private-fields-in-struct-literal.stderr
no-type-for-node-ice.rs
no-type-for-node-ice.stderr
nonexistent-field-not-ambiguous.rs
nonexistent-field-not-ambiguous.stderr
output-type-mismatch.rs
output-type-mismatch.stderr
path-to-method-sugg-unresolved-expr.rs
path-to-method-sugg-unresolved-expr.stderr
pin-unsound-issue-85099-derefmut.rs
point-at-type-param-in-path-expr.rs
point-at-type-param-in-path-expr.stderr
point-at-type-parameter-definition.rs
point-at-type-parameter-definition.stderr
prim-with-args.fixed
prim-with-args.rs
prim-with-args.stderr
project-cache-issue-37154.rs
ptr-null-mutability-suggestions.fixed
ptr-null-mutability-suggestions.rs
ptr-null-mutability-suggestions.stderr Use verbose suggestion for ptr::null_mut() 2024-07-05 20:38:21 +00:00
question-mark-operator-suggestion-span.rs
question-mark-operator-suggestion-span.stderr
quiet-type-err-let-binding.rs
quiet-type-err-let-binding.stderr
remove-extra-argument.fixed
remove-extra-argument.rs
remove-extra-argument.stderr Use ordinal number in argument error 2024-07-14 13:50:09 +09:00
remove-semi-but-confused-char.rs
remove-semi-but-confused-char.stderr
repeat-expr-checks-wf.rs
repeat-expr-checks-wf.stderr
return_type_containing_closure.rs
return_type_containing_closure.stderr
return-dyn-type-mismatch-2.rs
return-dyn-type-mismatch-2.stderr
return-dyn-type-mismatch.rs
return-dyn-type-mismatch.stderr
slow-lhs-suggestion.rs
slow-lhs-suggestion.stderr
span-bug-issue-121410.rs
span-bug-issue-121410.stderr
struct-enum-wrong-args.rs
struct-enum-wrong-args.stderr Use ordinal number in argument error 2024-07-14 13:50:09 +09:00
struct-index-err-ice-issue-126744.rs report pat no field error no recoverd struct variant 2024-07-11 00:18:47 +08:00
struct-index-err-ice-issue-126744.stderr report pat no field error no recoverd struct variant 2024-07-11 00:18:47 +08:00
suggest-adding-missing-zero-to-floating-point-number.fixed
suggest-adding-missing-zero-to-floating-point-number.rs
suggest-adding-missing-zero-to-floating-point-number.stderr
suggest-box-on-divergent-if-else-arms.fixed
suggest-box-on-divergent-if-else-arms.rs
suggest-box-on-divergent-if-else-arms.stderr
suggest-similar-impls-for-root-obligation.rs
suggest-similar-impls-for-root-obligation.stderr
suppressed-error.rs
suppressed-error.stderr
tag-that-dare-not-speak-its-name.rs
tag-that-dare-not-speak-its-name.stderr
terr-in-field.rs
terr-in-field.stderr
terr-sorts.rs
terr-sorts.stderr
type-placeholder-fn-in-const.rs
type-placeholder-fn-in-const.stderr
typeck_type_placeholder_1.rs
typeck_type_placeholder_item_help.rs
typeck_type_placeholder_item_help.stderr
typeck_type_placeholder_item.rs Fix a error suggestion for E0121 when using placeholder _ as return types on function signature. 2024-06-29 14:23:33 +08:00
typeck_type_placeholder_item.stderr Fix a error suggestion for E0121 when using placeholder _ as return types on function signature. 2024-06-29 14:23:33 +08:00
typeck_type_placeholder_lifetime_1.rs
typeck_type_placeholder_lifetime_1.stderr
typeck_type_placeholder_lifetime_2.rs
typeck_type_placeholder_lifetime_2.stderr
typeck_type_placeholder_mismatch.rs
typeck_type_placeholder_mismatch.stderr
typeck-builtin-bound-type-parameters.rs
typeck-builtin-bound-type-parameters.stderr
typeck-cast-pointer-to-float.rs
typeck-cast-pointer-to-float.stderr
typeck-closure-to-unsafe-fn-ptr.rs
typeck-default-trait-impl-assoc-type.fixed
typeck-default-trait-impl-assoc-type.rs
typeck-default-trait-impl-assoc-type.stderr
typeck-default-trait-impl-cross-crate-coherence.rs
typeck-default-trait-impl-cross-crate-coherence.stderr
typeck-default-trait-impl-negation-send.rs
typeck-default-trait-impl-negation-send.stderr
typeck-default-trait-impl-negation-sync.rs
typeck-default-trait-impl-negation-sync.stderr
typeck-default-trait-impl-send-param.rs
typeck-default-trait-impl-send-param.stderr
typeck-fn-to-unsafe-fn-ptr.rs
typeck-unsafe-always-share.rs
typeck-unsafe-always-share.stderr
ufcs-type-params.rs
unify-return-ty.rs
while-loop-block-cond.rs
while-loop-block-cond.stderr
while-type-error.rs
while-type-error.stderr
wrong-ret-type.rs
wrong-ret-type.stderr