diff options
| author | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2023-01-16 01:31:58 +0300 |
|---|---|---|
| committer | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2023-01-17 18:38:49 +0300 |
| commit | 837c1aff0546edca18b43fbfc65b8dacf0b0b699 (patch) | |
| tree | f434baeb3ff12e942abd82b1dcee4e7fd3049a6d /tests/ui/nll/member-constraints/nested-impl-trait-pass.rs | |
| parent | 159ba8a92c9e2fa4121f106176309521f4af87e9 (diff) | |
| download | rust-837c1aff0546edca18b43fbfc65b8dacf0b0b699.tar.gz rust-837c1aff0546edca18b43fbfc65b8dacf0b0b699.zip | |
rework min_choice algorithm of member constraints
See the inline comments for the description of the new algorithm.
Diffstat (limited to 'tests/ui/nll/member-constraints/nested-impl-trait-pass.rs')
| -rw-r--r-- | tests/ui/nll/member-constraints/nested-impl-trait-pass.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs b/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs new file mode 100644 index 00000000000..15540cb460e --- /dev/null +++ b/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs @@ -0,0 +1,29 @@ +// Nested impl-traits can impose different member constraints on the same region variable. + +// check-pass + +trait Cap<'a> {} +impl<T> Cap<'_> for T {} + +// Assuming the hidden type is `[&'_#15r u8; 1]`, we have two distinct member constraints: +// - '_#15r member ['static, 'a, 'b] // from outer impl-trait +// - '_#15r member ['static, 'a] // from inner impl-trait +// To satisfy both we can only choose 'a. +fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> +where + 's: 'a, + 's: 'b, +{ + [a] +} + +// Same as the above but with late-bound regions. +fn pass_late_bound<'s, 'a, 'b>( + a: &'s u8, + _: &'a &'s u8, + _: &'b &'s u8, +) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> { + [a] +} + +fn main() {} |
