rust/tests
bors f5079d00e6 Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obk
(Re-)Implement `impl_trait_in_bindings`

This reimplements the `impl_trait_in_bindings` feature for local bindings.

"`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference):

```rust
let _: impl Fn(&u8) -> &u8 = |x| x;
```

They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes:

```rust
trait Static: 'static {}
impl<T> Static for T where T: 'static {}

let local = 1;
let x: impl Static = &local;
//~^ ERROR `local` does not live long enough
```

r? oli-obk

cc #63065

---

Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example:

```rust
type TAIT = impl Display;
let local = 0;
let x: TAIT = &local;
//~^ ERROR `local` does not live long enough
```

That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here.

---

I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
2024-12-14 10:22:43 +00:00
..
assembly Auto merge of #133818 - matthiaskrgr:rollup-iav1wq7, r=matthiaskrgr 2024-12-04 00:47:09 +00:00
auxiliary Support input/output in vector registers of s390x inline assembly 2024-11-22 04:18:14 +09:00
codegen Auto merge of #133899 - scottmcm:strip-mir-debuginfo, r=oli-obk 2024-12-13 08:32:20 +00:00
codegen-units Remove polymorphization 2024-12-06 16:42:09 -05:00
coverage Stabilize async closures 2024-12-13 00:04:56 +00:00
coverage-run-rustdoc
crashes Rollup merge of #134256 - krtab:suggestion_overlapping, r=petrochenkov 2024-12-14 03:54:36 +01:00
debuginfo Reformat Python code with ruff 2024-12-04 23:03:44 +01:00
incremental Add more info on type/trait mismatches for different crate versions 2024-12-07 18:18:08 +00:00
mir-opt Auto merge of #133899 - scottmcm:strip-mir-debuginfo, r=oli-obk 2024-12-13 08:32:20 +00:00
pretty Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
run-make Rollup merge of #134094 - estebank:const-trait-errors, r=compiler-errors 2024-12-10 20:16:02 +01:00
rustdoc Stabilize async closures 2024-12-13 00:04:56 +00:00
rustdoc-gui Update GUI test after rebase 2024-12-05 22:50:21 +01:00
rustdoc-js rustdoc-search: fix mismatched path when parent re-exported twice 2024-12-12 13:29:18 -07:00
rustdoc-js-std rustdoc-search: update test with now-shorter function path 2024-12-13 09:08:44 -07:00
rustdoc-json Rollup merge of #133721 - aDotInTheVoid:rdj-dyn-link, r=GuillaumeGomez 2024-12-02 17:36:05 +01:00
rustdoc-ui Account for /// when rendering multiline spans 2024-12-13 18:48:33 +00:00
ui Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obk 2024-12-14 10:22:43 +00:00
ui-fulldeps Rollup merge of #134043 - ehuss:unicode-version, r=jieyouxu 2024-12-09 23:39:05 +01:00
COMPILER_TESTS.md