diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-01 08:15:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-01 08:15:21 +0100 |
| commit | 20af87858889b55c4533419f6722b630e255054d (patch) | |
| tree | 6271ed8f9d570ddd9ecd1a920a26c90ca3cb2764 /tests | |
| parent | fe4c6e8657271b0eeb5ada90e9ab751caab52a22 (diff) | |
| parent | 0f5759a00536ac7172090226538bd6870df4b07f (diff) | |
| download | rust-20af87858889b55c4533419f6722b630e255054d.tar.gz rust-20af87858889b55c4533419f6722b630e255054d.zip | |
Rollup merge of #132047 - compiler-errors:rbv-rtn-cleanup, r=cjgillot
Robustify and genericize return-type-notation resolution in `resolve_bound_vars` #129629 implemented return-type-notation (RTN) in its path form, like `where T::method(..): Bound`. As part of lowering, we must record the late-bound vars for the where clause introduced by the method (namely, its early- and late-bound lifetime arguments, since `where T::method(..)` turns into a higher-ranked where clause over all of the lifetimes according to [RFC 3654](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#converting-to-higher-ranked-trait-bounds)). However, this logic was only looking at the where clauses of the parent item that the `T::method(..)` bound was written on, and not any parent items. This PR generalizes that logic to look at the parent item (i.e. the outer impl or trait) instead and fixes a (debug only) assertion as an effect. This logic is also more general and likely easier to adapt to more interesting (though likely very far off) cases like non-lifetime binder `for<T: Trait> T::method(..): Send` bounds. Tracking: - https://github.com/rust-lang/rust/issues/109417
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/associated-type-bounds/all-generics-lookup.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/associated-type-bounds/all-generics-lookup.rs b/tests/ui/associated-type-bounds/all-generics-lookup.rs new file mode 100644 index 00000000000..c5940c14f44 --- /dev/null +++ b/tests/ui/associated-type-bounds/all-generics-lookup.rs @@ -0,0 +1,31 @@ +//@ check-pass + +#![feature(return_type_notation)] + +trait Trait { + fn method(&self) -> impl Sized; +} + +impl Trait for () { + fn method(&self) -> impl Sized {} +} + +struct Struct<T>(T); + +// This test used to fail a debug assertion since we weren't resolving the item +// for `T::method(..)` correctly, leading to two bound vars being given the +// index 0. The solution is to look at both generics of `test` and its parent impl. + +impl<T> Struct<T> +where + T: Trait, +{ + fn test() + where + T::method(..): Send + {} +} + +fn main() { + Struct::<()>::test(); +} |
