rust/compiler
bors 003a902792 Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr
Remove the `ty` field from type system `Const`s

Fixes #125556
Fixes #122908

Part of the work on `adt_const_params`/`generic_const_param_types`/`min_generic_const_exprs`/generally making the compiler nicer. cc rust-lang/project-const-generics#44

Please review commit-by-commit otherwise I wasted a lot of time not just squashing this into a giant mess (and also it'll be SO much nicer because theres a lot of fluff changes mixed in with other more careful changes if looking via File Changes

---

Why do this?
- The `ty` field keeps causing ICEs and weird behaviour due to it either being treated as "part of the const" or it being forgotten about leading to ICEs.
- As we move forward with `adt_const_params` and a potential `min_generic_const_exprs` it's going to become more complex to actually lower the correct `Ty<'tcx>`
- It muddles the idea behind how we check `Const` arguments have the correct type. By having the `ty` field it may seem like we ought to be relating it when we relate two types, or that its generally important information about the `Const`.
- Brings the compiler more in line with `a-mir-formality` as that also tracks the type of type system `Const`s via `ConstArgHasType` bounds in the env instead of on the `Const` itself.
- A lot of stuff is a lot nicer when you dont have to pass around the type of a const lol. Everywhere we construct `Const` is now significantly nicer 😅

See #125671's description for some more information about the `ty` field

---

General summary of changes in this PR:

- Add `Ty` to `ConstKind::Value` as otherwise there is no way to implement `ConstArgHasType` to ensure that const arguments are correctly typed for the parameter when we stop creating anon consts for all const args. It's also just incredibly difficult/annoying to thread the correct `Ty` around to a bunch of ctfe functions otherwise.
-  Fully implement `ConstArgHasType` in both the old and new solver. Since it now has no reliance on the `ty` field it serves its originally intended purpose of being able to act as a double check that trait vs impls have correctly typed const parameters. It also will now be able to be responsible for checking types of const arguments to parameters under `min_generic_const_exprs`.
- Add `Ty` to `mir::Const::Ty`. I dont have a great understanding of why mir constants are setup like this to be honest. Regardless they need to be able to determine the type of the const and the easiest way to make this happen was to simply store the `Ty` along side the `ty::Const`. Maybe we can do better here in the future but I'd have to spend way more time looking at everywhere we use `mir::Const`.
- rustdoc has its own `Const` which also has a `ty` field. It was relatively easy to remove this.

---

r? `@lcnr` `@compiler-errors`
2024-06-06 03:41:23 +00:00
..
rustc Change SIGPIPE ui from #[unix_sigpipe = "..."] to -Zon-broken-pipe=... 2024-05-02 19:48:29 +02:00
rustc_abi don't inhibit random field reordering on repr(packed(1)) 2024-05-21 19:22:04 +02:00
rustc_arena
rustc_ast Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_ast_ir Remove extern crate rustc_macros from numerous crates. 2024-04-29 10:21:54 +10:00
rustc_ast_lowering Rollup merge of #125790 - WaffleLapkin:no-tail-recomputation-in-lower-stmts, r=lcnr 2024-05-31 08:50:24 +02:00
rustc_ast_passes Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_ast_pretty Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_attr Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
rustc_baked_icu_data
rustc_borrowck Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_builtin_macros Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
rustc_codegen_cranelift Misc fixes to cranelift/clippy/miri 2024-06-05 22:25:42 +01:00
rustc_codegen_gcc Uplift TypeRelation and Relate 2024-06-01 12:50:58 -04:00
rustc_codegen_llvm Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_codegen_ssa Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_const_eval Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr 2024-06-06 03:41:23 +00:00
rustc_data_structures Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_driver
rustc_driver_impl Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
rustc_error_codes Rollup merge of #124746 - OliverKillane:E0582-explain-assoc-types-improvement, r=pnkfelix 2024-06-05 18:21:08 +02:00
rustc_error_messages Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote 2024-05-27 08:44:12 +00:00
rustc_errors Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote 2024-05-27 08:44:12 +00:00
rustc_expand Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
rustc_feature Rollup merge of #124486 - beetrees:vectorcall-tracking-issue, r=ehuss 2024-06-04 08:25:46 +01:00
rustc_fluent_macro
rustc_fs_util Stabilize std::path::absolute 2024-04-24 14:35:02 +00:00
rustc_graphviz
rustc_hir Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk 2024-05-31 10:12:24 +00:00
rustc_hir_analysis Misc fixes (pattern type lowering, cfi, pretty printing) 2024-06-05 22:25:42 +01:00
rustc_hir_pretty Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
rustc_hir_typeck Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr 2024-06-06 03:41:23 +00:00
rustc_incremental Run rustfmt on files that need it. 2024-05-24 15:17:21 +10:00
rustc_index Simplify static_assert_sizes. 2024-04-18 15:36:25 +10:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_interface Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
rustc_lexer Improved the compiler code with clippy 2024-04-24 09:41:44 +02:00
rustc_lint Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebank 2024-06-04 21:41:33 +02:00
rustc_lint_defs Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebank 2024-06-04 21:41:33 +02:00
rustc_llvm thinlto: only build summary file if needed 2024-05-23 14:58:30 -04:00
rustc_log remove tracing tree indent lines 2024-05-30 15:26:48 +02:00
rustc_macros Nits and formatting 2024-06-03 10:02:08 -04:00
rustc_metadata Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk 2024-05-31 10:12:24 +00:00
rustc_middle Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr 2024-06-06 03:41:23 +00:00
rustc_mir_build Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_mir_dataflow Remove #[macro_use] extern crate tracing from rustc_mir_dataflow. 2024-05-23 18:02:40 +10:00
rustc_mir_transform Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr 2024-06-06 03:41:23 +00:00
rustc_monomorphize Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_next_trait_solver Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_parse Make top-level rustc_parse functions fallible. 2024-06-05 10:38:03 +10:00
rustc_parse_format Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_passes Also support generic constants 2024-06-05 15:40:11 +00:00
rustc_pattern_analysis Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_privacy Make body_owned_by return the body directly. 2024-05-29 10:04:08 +00:00
rustc_query_impl Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
rustc_query_system Add a footer in FileEncoder and check for it in MemDecoder 2024-05-21 20:12:29 -04:00
rustc_resolve Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgr 2024-06-05 20:53:32 +00:00
rustc_sanitizers Misc fixes (pattern type lowering, cfi, pretty printing) 2024-06-05 22:25:42 +01:00
rustc_serialize Apply x clippy --fix and x fmt 2024-05-30 09:51:27 +08:00
rustc_session coverage: Add CLI support for -Zcoverage-options=condition 2024-05-30 15:38:46 +10:00
rustc_smir Add Ty to mir::Const::Ty 2024-06-05 22:25:41 +01:00
rustc_span Rollup merge of #125921 - Zalathar:buckets, r=oli-obk 2024-06-05 18:21:11 +02:00
rustc_symbol_mangling Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_target Rollup merge of #117671 - kjetilkjeka:nvptx_c_abi_avoid_direct, r=davidtwco 2024-05-28 18:04:31 +02:00
rustc_trait_selection Auto merge of #125958 - BoxyUwU:remove_const_ty, r=lcnr 2024-06-06 03:41:23 +00:00
rustc_traits Align Term methods with GenericArg methods 2024-06-03 20:36:27 -04:00
rustc_transmute Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_ty_utils ty::Expr reviews 2024-06-05 22:25:42 +01:00
rustc_type_ir Add Ty to ConstKind::Value 2024-06-05 22:25:41 +01:00
rustc_type_ir_macros Uplift TraitPredicate 2024-05-11 18:20:00 -04:00
stable_mir Split smir Const into TyConst and MirConst 2024-06-04 10:14:45 +01:00