diff options
| author | lcnr <rust@lcnr.de> | 2025-08-07 14:20:19 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-08-07 14:20:19 +0200 |
| commit | 064d5886544de3f28b0804fb15654ea49eb6b9c7 (patch) | |
| tree | 0a119ee2e03d2dcd0484aad908f464f02b08f425 /tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs | |
| parent | 61cb1e97fcf954c37d0a457a8084ed9ad8b3cb82 (diff) | |
| download | rust-064d5886544de3f28b0804fb15654ea49eb6b9c7.tar.gz rust-064d5886544de3f28b0804fb15654ea49eb6b9c7.zip | |
move member-constraints tests
Diffstat (limited to 'tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs')
| -rw-r--r-- | tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs b/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs new file mode 100644 index 00000000000..4633ad68230 --- /dev/null +++ b/tests/ui/impl-trait/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 `[&'?15 u8; 1]`, we have two distinct member constraints: +// - '?15 member ['static, 'a, 'b] // from outer impl-trait +// - '?15 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() {} |
