rust/tests
Michael Goulet d72d44d8ed
Rollup merge of #129629 - compiler-errors:rtn-in-path, r=jackh726
Implement Return Type Notation (RTN)'s path form in where clauses

Implement return type notation (RTN) in path position for where clauses. We already had RTN in associated type position ([e.g.](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=627a4fb8e2cb334863fbd08ed3722c09)), but per [the RFC](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#where-rtn-can-be-used-for-now):

> As a standalone type, RTN can only be used as the Self type of a where-clause [...]

Specifically, in order to enable code like:

```rust
trait Foo {
    fn bar() -> impl Sized;
}

fn is_send(_: impl Send) {}

fn test<T>()
where
    T: Foo,
    T::bar(..): Send,
{
    is_send(T::bar());
}
```

* In the resolver, when we see a `TyKind::Path` whose final segment is `GenericArgs::ParenthesizedElided` (i.e. `(..)`), resolve that path in the *value* namespace, since we're looking for a method.
* When lowering where clauses in HIR lowering, we first try to intercept an RTN self type via `lower_ty_maybe_return_type_notation`. If we find an RTN type, we lower it manually in a way that respects its higher-ranked-ness (see below) and resolves to the corresponding RPITIT. Anywhere else, we'll emit the same "return type notation not allowed in this position yet" error we do when writing RTN in every other position.
* In `resolve_bound_vars`, we add some special treatment for RTN types in where clauses. Specifically, we need to add new lifetime variables to our binders for the early- and late-bound vars we encounter on the method. This implements the higher-ranked desugaring [laid out in the RFC](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#converting-to-higher-ranked-trait-bounds).

This PR also adds a bunch of tests, mostly negative ones (testing error messages).

In a follow-up PR, I'm going to mark RTN as no longer incomplete, since this PR basically finishes the impl surface that we should initially stabilize, and the RFC was accepted.

cc [RFC 3654](https://github.com/rust-lang/rfcs/pull/3654) and https://github.com/rust-lang/rust/issues/109417
2024-09-21 15:18:56 -04:00
..
assembly Add assembly test for the cmse unstable features 2024-09-21 13:05:23 +02:00
auxiliary
codegen Auto merge of #129283 - saethlin:unreachable-allocas, r=scottmcm 2024-09-21 13:48:14 +00:00
codegen-units
coverage Update the minimum external LLVM to 18 2024-09-18 13:53:31 -07:00
coverage-run-rustdoc
crashes Auto merge of #127546 - workingjubilee:5-level-paging-exists, r=saethlin 2024-09-21 16:20:10 +00:00
debuginfo Auto merge of #130052 - khuey:clear-dilocation-after-const-emission, r=michaelwoerister 2024-09-13 08:57:41 +00:00
incremental simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
mir-opt Remove semi-nondeterminism of DefPathHash ordering from inliner 2024-09-16 21:41:15 -04:00
pretty Use doc(hidden) instead of allow(missing_docs) in the test harness 2024-09-11 12:14:35 +02:00
run-make Pass the current cargo to run-make tests 2024-09-20 15:47:36 -07:00
run-pass-valgrind
rustdoc rustdoc: rename issue-\d+.rs tests to have meaningful names 2024-09-12 13:47:51 -07:00
rustdoc-gui Add GUI tests for line numbers padding 2024-09-20 16:02:32 +02:00
rustdoc-js rustdoc-search: allow trailing Foo -> arg search 2024-09-05 17:58:05 -07:00
rustdoc-js-std rustdoc-search: allow trailing Foo -> arg search 2024-09-05 17:58:05 -07:00
rustdoc-json rustdoc: normalise type/field names in rustdoc-json-types/jsondoclint 2024-09-01 23:58:08 +03:00
rustdoc-ui rustdoc: use the correct span for doctests 2024-09-19 13:57:44 -07:00
ui Rollup merge of #129629 - compiler-errors:rtn-in-path, r=jackh726 2024-09-21 15:18:56 -04:00
ui-fulldeps Auto merge of #130483 - matthiaskrgr:rollup-q1r0g0y, r=matthiaskrgr 2024-09-17 19:37:03 +00:00
COMPILER_TESTS.md