rust/src
bors 88d69b72b4 Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-dead
Introduce `const Trait` (always-const trait bounds)

Feature `const_trait_impl` currently lacks a way to express “always const” trait bounds. This makes it impossible to define generic items like fns or structs which contain types that depend on const method calls (\*). While the final design and esp. the syntax of effects / keyword generics isn't set in stone, some version of “always const” trait bounds will very likely form a part of it. Further, their implementation is trivial thanks to the `effects` backbone.

Not sure if this needs t-lang sign-off though.

(\*):

```rs
#![feature(const_trait_impl, effects, generic_const_exprs)]

fn compute<T: const Trait>() -> Type<{ T::generate() }> { /*…*/ }

struct Store<T: const Trait>
where
    Type<{ T::generate() }>:,
{
    field: Type<{ T::generate() }>,
}
```

Lastly, “always const” trait bounds are a perfect fit for `generic_const_items`.

```rs
#![feature(const_trait_impl, effects, generic_const_items)]

const DEFAULT<T: const Default>: T = T::default();
```

Previously, we (oli, fee1-dead and I) wanted to reinterpret `~const Trait` as `const Trait` in generic const items which would've been quite surprising and not very generalizable.
Supersedes #117530.

---

cc `@oli-obk`

As discussed
r? fee1-dead (or compiler)
2023-12-27 19:24:31 +00:00
..
bootstrap Update sysinfo version to 0.30.1 2023-12-25 22:44:49 +01:00
ci Auto merge of #119283 - GuillaumeGomez:warning-block-pos, r=notriddle 2023-12-25 02:08:21 +00:00
doc Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebank 2023-12-26 12:27:29 +00:00
etc Auto merge of #106790 - the8472:rawvec-niche, r=scottmcm 2023-12-20 02:19:10 +00:00
librustdoc Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-dead 2023-12-27 19:24:31 +00:00
llvm-project@606bc11367 Update LLVM submodule 2023-12-20 16:50:43 +03:00
rustdoc-json-types Add is_object_safe information for traits in JSON output 2023-12-23 11:43:31 +01:00
tools Update cargo 2023-12-26 21:04:15 -05:00
README.md Remove stale reference to the test suite location 2023-01-13 11:49:06 +00:00
stage0.json bump stage0 2023-12-22 11:04:31 +01:00
version bump version number to 1.77.0 2023-12-21 10:58:56 +01:00

This directory contains some source code for the Rust project, including:

  • The bootstrapping build system
  • Various submodules for tools, like cargo, tidy, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.