rust/compiler
Manish Goregaokar 2d7a592c62
Rollup merge of #138259 - compiler-errors:disentangle-ribs, r=BoxyUwU
Disentangle `ForwardGenericParamBan` and `ConstParamTy` ribs

In #137617, the `ConstParamTy` rib was adjusted to act kinda like the `ForwardGenericParamBan`. However, this means that it no longer served its purpose banning generics from *parent items*. Although we still are checking for param type validity using the `ConstParamTy_` trait, which means that we weren't accepting code we shouldn't, I think it's a bit strange for us not to be rejecting code like this during *resolution* and instead letting these malformed const generics leak into the type system:

```rust
trait Foo<T> {
  fn bar<const N: T>() {}
}
```

This PR does a few things:
1. Introduce a `ForwardGenericParamBanReason` enum, and start using the `ForwardGenericParamBan` rib to ban forward-declared params in const tys when `generic_const_parameter_types` is enabled.
2. Start using the `ConstParamTy` rib to ban *all* generics when `generic_const_parameter_types` is disabled.
3. Improve the diagnostics for both of the cases above, and for forward-declared params in parameter defaults too :3

r? `@BoxyUwU` or reassign
2025-03-12 10:19:28 -07:00
..
rustc Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_abi Auto merge of #138302 - matthiaskrgr:rollup-an2up80, r=matthiaskrgr 2025-03-11 00:55:25 +00:00
rustc_arena Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_ast Introduce sym::dummy and Ident::dummy. 2025-03-12 09:35:11 +11:00
rustc_ast_ir Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_ast_lowering Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_ast_passes Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_ast_pretty Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_attr_data_structures Rollup merge of #138063 - compiler-errors:improve-attr-unpretty, r=jdonszelmann 2025-03-11 13:30:51 +01:00
rustc_attr_parsing Introduce sym::dummy and Ident::dummy. 2025-03-12 09:35:11 +11:00
rustc_baked_icu_data Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_borrowck Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_builtin_macros Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr 2025-03-11 21:17:18 +00:00
rustc_codegen_cranelift Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_codegen_gcc Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3 2025-03-11 12:05:16 +00:00
rustc_codegen_llvm Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3 2025-03-11 12:05:16 +00:00
rustc_codegen_ssa Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_const_eval Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_data_structures Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_driver Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_driver_impl Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
rustc_error_codes Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_error_messages Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
rustc_errors Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_expand Introduce sym::dummy and Ident::dummy. 2025-03-12 09:35:11 +11:00
rustc_feature Rollup merge of #138300 - RalfJung:unqualified-local-imports, r=jieyouxu 2025-03-11 13:30:53 +01:00
rustc_fluent_macro Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_fs_util Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_graphviz Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hashes Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_hir Rollup merge of #138376 - nnethercote:hir-ItemKind-ident-precursors, r=compiler-errors 2025-03-12 08:06:51 +01:00
rustc_hir_analysis Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_hir_pretty Inline and remove State::print_item_type. 2025-03-12 09:55:15 +11:00
rustc_hir_typeck Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_incremental Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
rustc_index Rollup merge of #138372 - Eclips4:issue-138196, r=scottmcm 2025-03-12 08:06:50 +01:00
rustc_index_macros Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_infer Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_interface Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
rustc_lexer Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_lint Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_lint_defs Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_llvm Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_log Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_macros Rollup merge of #138063 - compiler-errors:improve-attr-unpretty, r=jdonszelmann 2025-03-11 13:30:51 +01:00
rustc_metadata Rollup merge of #138175 - sam-mccall:binobj, r=nnethercote 2025-03-12 10:19:27 -07:00
rustc_middle Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_mir_build Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_mir_dataflow Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_mir_transform Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_monomorphize Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_next_trait_solver Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_parse Factor out some repeated code in parse_item_impl. 2025-03-12 09:55:29 +11:00
rustc_parse_format Auto merge of #136932 - m-ou-se:fmt-width-precision-u16, r=scottmcm 2025-03-11 04:07:05 +00:00
rustc_passes Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
rustc_pattern_analysis Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_privacy Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_query_impl Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_query_system Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_resolve Disentangle ForwardGenericParamBan and ConstParamTy ribs 2025-03-12 16:56:26 +00:00
rustc_sanitizers Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_serialize Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_session Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_smir Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
rustc_span Introduce sym::dummy and Ident::dummy. 2025-03-12 09:35:11 +11:00
rustc_symbol_mangling Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_target Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3 2025-03-11 12:05:16 +00:00
rustc_trait_selection Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_traits Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_transmute Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
rustc_ty_utils Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar 2025-03-12 10:19:26 -07:00
rustc_type_ir Remove unnecessary [lints.rust] sections. 2025-03-11 12:11:04 +11:00
rustc_type_ir_macros Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00
stable_mir Revert "Use workspace lints for crates in compiler/ #138084" 2025-03-10 18:12:47 +08:00