diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-24 20:46:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-24 20:46:06 +0200 |
| commit | a73954c229fb373bebcfc37263c65f60a651b262 (patch) | |
| tree | 5077f9f629e549f7b04752732b06ae9f5dc98607 | |
| parent | a5875c18fe24d9e8d56accddbbc3f96893ad2c84 (diff) | |
| parent | 2973939f7a2d3840b2cbbfe5b9177538c126dea3 (diff) | |
| download | rust-a73954c229fb373bebcfc37263c65f60a651b262.tar.gz rust-a73954c229fb373bebcfc37263c65f60a651b262.zip | |
Rollup merge of #142883 - mominul:impl_in_bindings, r=lcnr
Add impl_trait_in_bindings tests from #61773 This adds the [three test cases](https://github.com/rust-lang/rust/issues/61773#issuecomment-2952638727) from the rust-lang/rust#61773 as was suggested by ``@lcnr.`` I have merged the first two cases into one, named as `region-lifetimes.rs` r? ``@lcnr`` Closes rust-lang/rust#61773
| -rw-r--r-- | tests/ui/impl-trait/in-bindings/lifetime-equality.rs | 19 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-bindings/region-lifetimes.rs | 17 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/in-bindings/lifetime-equality.rs b/tests/ui/impl-trait/in-bindings/lifetime-equality.rs new file mode 100644 index 00000000000..6cf48dccc7d --- /dev/null +++ b/tests/ui/impl-trait/in-bindings/lifetime-equality.rs @@ -0,0 +1,19 @@ +//@ check-pass + +#![feature(impl_trait_in_bindings)] + +// A test for #61773 which would have been difficult to support if we +// were to represent `impl_trait_in_bindings` using opaque types. + +trait Trait<'a, 'b> { } +impl<T> Trait<'_, '_> for T { } + + +fn bar<'a, 'b>(data0: &'a u32, data1: &'b u32) { + let x: impl Trait<'_, '_> = (data0, data1); + force_equal(x); +} + +fn force_equal<'a>(t: impl Trait<'a, 'a>) { } + +fn main() { } diff --git a/tests/ui/impl-trait/in-bindings/region-lifetimes.rs b/tests/ui/impl-trait/in-bindings/region-lifetimes.rs new file mode 100644 index 00000000000..189ab85a276 --- /dev/null +++ b/tests/ui/impl-trait/in-bindings/region-lifetimes.rs @@ -0,0 +1,17 @@ +//@ check-pass + +#![feature(impl_trait_in_bindings)] + +// A test for #61773 which would have been difficult to support if we +// were to represent `impl_trait_in_bindings` using opaque types. + +trait Foo<'a> { } +impl Foo<'_> for &u32 { } + +fn bar<'a>(data: &'a u32) { + let x: impl Foo<'_> = data; +} + +fn main() { + let _: impl Foo<'_> = &44; +} |
