rust/compiler
bors 72b21e1a64 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
..
rustc Make llvm_enzyme a regular cargo feature 2025-09-15 15:31:56 +00:00
rustc_abi Rollup merge of #148518 - bjorn3:unify_compiler_doc_config, r=GuillaumeGomez 2025-11-05 21:28:29 +01:00
rustc_arena Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_ast Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_ast_ir Implement pattern matching for &pin mut|const T 2025-10-30 07:56:16 +08:00
rustc_ast_lowering Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_ast_passes Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_ast_pretty Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_attr_parsing add realtime sanitizer 2025-11-06 13:20:12 +01:00
rustc_baked_icu_data Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_borrowck Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_builtin_macros Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_codegen_cranelift Add missing --check-cfg 2025-11-08 15:04:45 +00:00
rustc_codegen_gcc Add -Zannotate-moves for profiler visibility of move/copy operations 2025-11-06 15:39:45 -08:00
rustc_codegen_llvm Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_codegen_ssa Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_const_eval Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_data_structures Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_driver Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_driver_impl Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_error_codes Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_error_messages Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_errors Auto merge of #148188 - Muscraft:annotate-snippets-default-on-nightly, r=estebank 2025-11-06 11:45:06 +00:00
rustc_expand Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_feature Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_fluent_macro Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_fs_util Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_graphviz Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_hashes some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_hir Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_hir_analysis Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_hir_id rustc_hir_id: Add a comment explaining why the crate exists 2025-08-20 15:04:00 -07:00
rustc_hir_pretty Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_hir_typeck Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_incremental Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_index Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_index_macros Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_infer Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_interface Add -Zannotate-moves for profiler visibility of move/copy operations 2025-11-06 15:39:45 -08:00
rustc_lexer Update memchr to 2.7.6 2025-09-26 17:53:49 +02:00
rustc_lint Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_lint_defs add warning for async 2025-11-06 13:20:12 +01:00
rustc_llvm Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_log Restrict sysroot crate imports to those defined in this repo. 2025-10-15 13:17:25 +01:00
rustc_macros use declarative macro for #[derive(TryFromU32)] 2025-10-06 14:54:38 +00:00
rustc_metadata Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_middle Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_mir_build Rollup merge of #147642 - camelid:misc-const-fixes, r=BoxyUwU 2025-11-02 15:56:48 +01:00
rustc_mir_dataflow Put Analysis back into Results. 2025-10-28 10:26:50 +11:00
rustc_mir_transform Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_monomorphize error on non-rustic ABIs using unsized parameters 2025-11-05 12:12:10 +01:00
rustc_next_trait_solver Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_parse Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_parse_format Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_passes Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_pattern_analysis split definition and use site hidden tys 2025-10-31 14:48:43 +01:00
rustc_privacy Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_proc_macro Revert introduction of [workspace.dependencies]. 2025-09-02 19:12:54 +10:00
rustc_public Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_public_bridge Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_query_impl Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_query_system fix dev guide link in rustc_query_system/dep_graph/README.MD 2025-11-06 17:17:03 +05:00
rustc_resolve Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_sanitizers Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr 2025-10-28 20:39:32 +11:00
rustc_serialize Allow internal_features lint in doc tests 2025-11-05 11:25:29 +00:00
rustc_session Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_span Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_symbol_mangling Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_target Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov 2025-11-08 12:24:15 +00:00
rustc_thread_pool some cleanups in compiler 2025-10-12 08:08:30 +00:00
rustc_trait_selection Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU 2025-11-08 22:31:33 +00:00
rustc_traits add const_of_item query and use it in normalization 2025-11-08 13:50:47 -05:00
rustc_transmute prefer to use repeat_n over repeat and take 2025-10-09 01:24:55 +08:00
rustc_ty_utils Unify the configuration of the compiler docs 2025-11-05 11:25:27 +00:00
rustc_type_ir add const_of_item query and use it in normalization 2025-11-08 13:50:47 -05:00
rustc_type_ir_macros compiler: Fix a couple issues around cargo feature unification 2025-10-31 14:14:05 -04:00
rustc_windows_rc [win] Use find-msvc-tools instead of cc to find the linker and rc on Windows 2025-09-19 12:00:30 -07:00