rust/compiler
Matthias Krüger 2c7ce1c453
Rollup merge of #119894 - fmease:tilde-const-assoc-ty-bounds, r=compiler-errors
Allow `~const` on associated type bounds again

This follows from [this Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/419616-t-compiler.2Fproject-const-traits/topic/projections.20on.20.28~.29const.20Trait.20.26.20.28~.29const.20assoc.20ty.20bounds).

Basically in my opinion, it makes sense to allow `~const` on associated type bounds again since they're quite useful even though we haven't implemented the proposed syntax `<Ty as ~const Trait>::Proj`/`<Ty as const Trait>::Proj` yet; that can happen as a follow-up.

This already allows more code to compile since `T::Assoc` where `T` is a type parameter and where the predicate `<T as ~const Trait>` is in the environment gets elaborated to (pseudo) `<T as ~const Trait>::Assoc`.

```rs
#[const_trait]
trait Trait {
    type Assoc: ~const Trait;
    fn func() -> i32;
}

const fn function<T: ~const Trait>() -> i32 {
    T::Assoc::func()
}
```

`~const` associated type bounds also work together with `const` bounds:

```rs
struct Type<const N: i32>;

fn procedure<T: const Trait>() -> Type<{ T::Assoc::func() }> { // `Trait` comes from above
    Type
}
```

NB: This PR also starts allowing `~const` bounds in the generics and the where-clause of trait associated types since it's trivial to support them. However, I don't know if those bounds are actually useful. Maybe we should continue to reject them?
For reference, it wouldn't make any sense to allow `~const Trait` in GACs (generic associated constants, `generic_const_items`) because they'd be absolutely useless (contrary to `const Trait`).

~~[``@]rustbot`` ping project-const-traits~~
r? project-const-traits
2024-01-13 15:10:29 +01:00
..
rustc
rustc_abi Avoid specialization for the Span Encodable and Decodable impls 2023-12-31 20:42:17 +00:00
rustc_arena rustc_arena: add alloc_str 2023-12-05 17:52:51 -08:00
rustc_ast Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_ast_lowering Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_ast_passes Rollup merge of #119894 - fmease:tilde-const-assoc-ty-bounds, r=compiler-errors 2024-01-13 15:10:29 +01:00
rustc_ast_pretty Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_attr Rename consuming chaining methods on DiagnosticBuilder. 2024-01-10 07:40:00 +11:00
rustc_baked_icu_data Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_borrowck Stop using DiagnosticBuilder::buffer in BorrowckErrors. 2024-01-11 16:55:10 +11:00
rustc_builtin_macros Rename --env option flag to --env-set 2024-01-12 11:02:57 +01:00
rustc_codegen_cranelift Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 2024-01-09 13:23:15 +01:00
rustc_codegen_gcc Rename {create,emit}_warning as {create,emit}_warn. 2024-01-10 07:33:06 +11:00
rustc_codegen_llvm Revert "Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix" 2024-01-12 18:23:04 +08:00
rustc_codegen_ssa Revert "Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix" 2024-01-12 18:23:04 +08:00
rustc_const_eval Stop using DiagnosticBuilder::buffer in Checker. 2024-01-11 16:55:10 +11:00
rustc_data_structures Rollup merge of #119527 - klensy:ordering, r=compiler-errors 2024-01-09 13:23:17 +01:00
rustc_driver Bump cfg(bootstrap)s 2023-11-15 19:41:28 -05:00
rustc_driver_impl Rename {create,emit}_warning as {create,emit}_warn. 2024-01-10 07:33:06 +11:00
rustc_error_codes Add error code for missing base expression in struct update syntax 2024-01-09 19:25:54 +00:00
rustc_error_messages Remove rustc_error_messages/messages.ftl. 2023-11-26 08:37:27 +11:00
rustc_errors Don't consider delayed bugs for -Ztreat-err-as-bug. 2024-01-13 09:59:56 +11:00
rustc_expand Change how force-warn lint diagnostics are recorded. 2024-01-11 07:56:17 +11:00
rustc_feature Rollup merge of #119866 - smoelius:patch-2, r=compiler-errors 2024-01-12 08:23:59 +01:00
rustc_fluent_macro annotate-snippets: update to 0.10 2024-01-07 16:53:32 +03:00
rustc_fs_util
rustc_graphviz remove unused pub fn 2023-11-23 14:11:02 +03:00
rustc_hir Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_hir_analysis Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov 2024-01-13 15:10:28 +01:00
rustc_hir_pretty Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_hir_typeck Rollup merge of #119841 - nnethercote:rm-DiagnosticBuilder-buffer, r=oli-obk 2024-01-11 19:42:51 +01:00
rustc_incremental Rename {create,emit}_warning as {create,emit}_warn. 2024-01-10 07:33:06 +11:00
rustc_index Auto merge of #119499 - cjgillot:dtm-opt, r=nnethercote 2024-01-06 11:54:15 +00:00
rustc_index_macros Put backticks around some attributes in doc comments. 2023-11-27 09:37:01 +11:00
rustc_infer rename reported_signature_mismatch to reflect its use 2024-01-12 16:21:04 +01:00
rustc_interface Auto merge of #119473 - Urgau:check-cfg-explicit-none, r=petrochenkov 2024-01-13 06:17:46 +00:00
rustc_lexer Rename some unescaping functions. 2023-12-13 14:17:50 +11:00
rustc_lint Auto merge of #118924 - Urgau:check-cfg-exclude-well-known-from-diag, r=petrochenkov 2024-01-13 02:13:20 +00:00
rustc_lint_defs Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco 2024-01-09 13:23:15 +01:00
rustc_llvm Revert "Auto merge of #113923 - DianQK:restore-no-builtins-lto, r=pnkfelix" 2024-01-12 18:23:04 +08:00
rustc_log rustc_log: provide a way to init logging based on the values, not names, of the env vars 2023-11-11 15:24:33 +01:00
rustc_macros u8 tags for smaller enums 2024-01-09 20:08:44 -05:00
rustc_metadata Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov 2024-01-13 15:10:28 +01:00
rustc_middle Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnr 2024-01-13 04:19:17 +00:00
rustc_mir_build Rollup merge of #119715 - Nadrieril:graceful-type-error, r=compiler-errors 2024-01-11 03:02:41 +01:00
rustc_mir_dataflow Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_mir_transform Rollup merge of #119842 - Zalathar:kind, r=oli-obk 2024-01-11 19:42:51 +01:00
rustc_monomorphize Stop mentioning internal lang items in no_std binary errors 2024-01-10 21:18:54 +01:00
rustc_next_trait_solver Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
rustc_parse Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_parse_format Removing redudant note from parse error 2024-01-08 19:41:01 +01:00
rustc_passes Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_pattern_analysis Only lint ranges that really overlap 2024-01-11 14:04:11 +01:00
rustc_privacy Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
rustc_query_impl Rollup merge of #119527 - klensy:ordering, r=compiler-errors 2024-01-09 13:23:17 +01:00
rustc_query_system Add DiagCtxt::delayed_bug. 2024-01-10 07:33:07 +11:00
rustc_resolve Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
rustc_serialize Remove more needless leb128 coding for enum variants 2024-01-09 20:08:44 -05:00
rustc_session Auto merge of #118924 - Urgau:check-cfg-exclude-well-known-from-diag, r=petrochenkov 2024-01-13 02:13:20 +00:00
rustc_smir Rollup merge of #119790 - celinval:smir-all-traits, r=oli-obk 2024-01-11 03:02:42 +01:00
rustc_span Auto merge of #118947 - Bryanskiy:delegStep1, r=petrochenkov,lcnr 2024-01-13 04:19:17 +00:00
rustc_symbol_mangling Rename consuming chaining methods on DiagnosticBuilder. 2024-01-10 07:40:00 +11:00
rustc_target Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov 2024-01-13 15:10:28 +01:00
rustc_trait_selection Rollup merge of #119891 - lcnr:rename-field, r=compiler-errors 2024-01-13 15:10:28 +01:00
rustc_traits add unused NormalizesTo predicate 2023-12-07 17:52:51 +01:00
rustc_transmute Fix an ICE that occurs after an error has already been reported 2024-01-09 16:09:30 +00:00
rustc_ty_utils Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov 2024-01-13 15:10:28 +01:00
rustc_type_ir Fix tidy error 2023-12-31 20:58:36 +00:00
stable_mir Rollup merge of #119877 - celinval:smir-visit-projection, r=oli-obk 2024-01-12 15:16:57 +01:00