rust/tests/ui-fulldeps
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 Port `tests/run-make-fulldeps/obtain-borrowck` to ui-fulldeps 2024-06-07 00:41:31 +10:00
codegen-backend Port `tests/run-make-fulldeps/hotplug_codegen_backend` to ui-fulldeps 2024-06-07 22:28:00 +10:00
fluent-messages Always use a colon in `//@ normalize-*:` headers 2024-07-11 12:23:44 +10:00
internal-lints Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent` 2024-07-18 13:03:26 +02:00
mod_dir_simple [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
session-diagnostic Always use a colon in `//@ normalize-*:` headers 2024-07-11 12:23:44 +10:00
stable-mir Add `ConstArgKind::Path` and make `ConstArg` its own HIR node 2024-07-16 19:27:28 -07:00
compiler-calls.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
deriving-global.rs Improve dead code analysis 2024-07-04 22:05:00 +08:00
deriving-hygiene.rs Improve dead code analysis 2024-07-04 22:05:00 +08:00
dropck-tarena-cycle-checked.rs Remove ignore-stage1 that was added when changing error count msg 2024-01-06 12:53:06 +01:00
dropck-tarena-cycle-checked.stderr Remove ignore-stage1 that was added when changing error count msg 2024-01-06 12:53:06 +01:00
dropck-tarena-unsound-drop.rs Remove ignore-stage1 that was added when changing error count msg 2024-01-06 12:53:06 +01:00
dropck-tarena-unsound-drop.stderr Remove ignore-stage1 that was added when changing error count msg 2024-01-06 12:53:06 +01:00
dropck_tarena_sound_drop.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
empty-struct-braces-derive.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
hash-stable-is-unstable.rs Run some ui-fulldeps tests on stage 1 again 2024-03-03 18:41:25 +01:00
hash-stable-is-unstable.stderr Run some ui-fulldeps tests on stage 1 again 2024-03-03 18:41:25 +01:00
lint-pass-macros.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00
missing-rustc-driver-error.rs Always use a colon in `//@ normalize-*:` headers 2024-07-11 12:23:44 +10:00
missing-rustc-driver-error.stderr Don't depend on crate names in tests/ui-fulldeps/missing-rustc-driver-error.rs 2023-07-11 22:30:28 -05:00
mod_dir_path_canonicalized.rs Make top-level `rustc_parse` functions fallible. 2024-06-05 10:38:03 +10:00
obtain-borrowck.rs Port `tests/run-make-fulldeps/obtain-borrowck` to ui-fulldeps 2024-06-07 00:41:31 +10:00
obtain-borrowck.run.stdout Port `tests/run-make-fulldeps/obtain-borrowck` to ui-fulldeps 2024-06-07 00:41:31 +10:00
pathless-extern-unstable.rs Run some ui-fulldeps tests on stage 1 again 2024-03-03 18:41:25 +01:00
pathless-extern-unstable.stderr Run some ui-fulldeps tests on stage 1 again 2024-03-03 18:41:25 +01:00
pprust-expr-roundtrip.rs Make top-level `rustc_parse` functions fallible. 2024-06-05 10:38:03 +10:00
regions-mock-tcx.rs Use the rustc_private libc less in tests 2024-04-15 08:54:11 -04:00
run-compiler-twice.rs Move codegen_and_build_linker from Queries to Linker 2024-07-01 11:00:49 +00:00
rustc_encodable_hygiene.rs [AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives 2024-02-22 16:04:04 +00:00