From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- .../auto-trait-leakage3.stderr | 2 + tests/ui/type-alias-impl-trait/broken_mir.rs | 16 ++++++ tests/ui/type-alias-impl-trait/coherence.rs | 2 +- tests/ui/type-alias-impl-trait/coherence.stderr | 8 +-- .../coherence_generalization.rs | 5 +- .../type-alias-impl-trait/hidden_type_mismatch.rs | 57 ++++++++++++++++++++++ .../hidden_type_mismatch.stderr | 14 ++++++ .../type-alias-impl-trait/inference-cycle.stderr | 2 + .../ui/type-alias-impl-trait/issue-53092-2.stderr | 1 + .../issue-96572-unconstrained.rs | 2 + .../nested-rpit-with-lifetimes.rs | 49 +++++++++++++++++++ tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs | 15 ++++++ .../type-alias-impl-trait/nested-tait-hrtb.stderr | 23 +++++++++ .../recursive-tait-conflicting-defn-2.rs | 21 ++++++++ .../recursive-tait-conflicting-defn-2.stderr | 14 ++++++ .../recursive-tait-conflicting-defn.rs | 34 +++++++++++++ .../recursive-tait-conflicting-defn.stderr | 14 ++++++ tests/ui/type-alias-impl-trait/reveal_local.stderr | 3 ++ .../unconstrained-impl-param.rs | 25 ++++++++++ .../unconstrained-impl-param.stderr | 9 ++++ tests/ui/type-alias-impl-trait/under-binder.rs | 9 ++++ tests/ui/type-alias-impl-trait/under-binder.stderr | 12 +++++ .../wf-check-rpit-lifetimes.rs | 19 ++++++++ 23 files changed, 349 insertions(+), 7 deletions(-) create mode 100644 tests/ui/type-alias-impl-trait/broken_mir.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs create mode 100644 tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr create mode 100644 tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs create mode 100644 tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs create mode 100644 tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs create mode 100644 tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr create mode 100644 tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs create mode 100644 tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr create mode 100644 tests/ui/type-alias-impl-trait/under-binder.rs create mode 100644 tests/ui/type-alias-impl-trait/under-binder.stderr create mode 100644 tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs (limited to 'tests/ui/type-alias-impl-trait') diff --git a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr index dd56c59bf..5bd0f76c3 100644 --- a/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr +++ b/tests/ui/type-alias-impl-trait/auto-trait-leakage3.stderr @@ -16,6 +16,7 @@ note: cycle used when checking item types in module `m` | LL | mod m { | ^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` --> $DIR/auto-trait-leakage3.rs:7:20 @@ -34,6 +35,7 @@ note: cycle used when checking item types in module `m` | LL | mod m { | ^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: cannot check whether the hidden type of `auto_trait_leakage3[211d]::m::Foo::{opaque#0}` satisfies auto traits --> $DIR/auto-trait-leakage3.rs:16:17 diff --git a/tests/ui/type-alias-impl-trait/broken_mir.rs b/tests/ui/type-alias-impl-trait/broken_mir.rs new file mode 100644 index 000000000..b68e798fb --- /dev/null +++ b/tests/ui/type-alias-impl-trait/broken_mir.rs @@ -0,0 +1,16 @@ +//! ICE: https://github.com/rust-lang/rust/issues/114121 +//! This test checks that MIR validation never constrains +//! new hidden types that *differ* from the actual hidden types. +//! This test used to ICE because oli-obk assumed mir validation +//! was only ever run after opaque types were revealed in MIR. + +// compile-flags: -Zvalidate-mir +// check-pass + +fn main() { + let _ = Some(()).into_iter().flat_map(|_| Some(()).into_iter().flat_map(func)); +} + +fn func(_: ()) -> impl Iterator { + Some(()).into_iter().flat_map(|_| vec![]) +} diff --git a/tests/ui/type-alias-impl-trait/coherence.rs b/tests/ui/type-alias-impl-trait/coherence.rs index 077a31494..1700c800e 100644 --- a/tests/ui/type-alias-impl-trait/coherence.rs +++ b/tests/ui/type-alias-impl-trait/coherence.rs @@ -11,7 +11,7 @@ fn use_alias(val: T) -> AliasOfForeignType { foreign_crate::ForeignType(val) } -impl foreign_crate::ForeignTrait for AliasOfForeignType {} +impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {} //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr index c923eb08a..36bbb985e 100644 --- a/tests/ui/type-alias-impl-trait/coherence.stderr +++ b/tests/ui/type-alias-impl-trait/coherence.stderr @@ -1,10 +1,10 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence.rs:14:1 | -LL | impl foreign_crate::ForeignTrait for AliasOfForeignType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------- - | | | - | | `AliasOfForeignType` is not defined in the current crate +LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------- + | | | + | | `AliasOfForeignType<()>` is not defined in the current crate | impl doesn't use only types from inside the current crate | = note: define and implement a trait or new type instead diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.rs b/tests/ui/type-alias-impl-trait/coherence_generalization.rs index 679b2b0f1..1ec8877ea 100644 --- a/tests/ui/type-alias-impl-trait/coherence_generalization.rs +++ b/tests/ui/type-alias-impl-trait/coherence_generalization.rs @@ -2,6 +2,7 @@ // FIXME(type_alias_impl_trait): What does this test? This needs a comment // explaining what we're worried about here. + #![feature(type_alias_impl_trait)] trait Trait {} type Opaque = impl Sized; @@ -9,7 +10,7 @@ fn foo() -> Opaque { () } -impl Trait for (T, V, V, u32) {} -impl Trait for (Opaque, V, i32, V) {} +impl Trait for (T, U, V, V, u32) {} +impl Trait for (Opaque, U, V, i32, V) {} fn main() {} diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs new file mode 100644 index 000000000..12ce6b14e --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.rs @@ -0,0 +1,57 @@ +//! This test checks that we don't lose hidden types +//! for *other* opaque types that we register and use +//! to prove bounds while checking that a hidden type +//! satisfies its opaque type's bounds. + +#![feature(trivial_bounds, type_alias_impl_trait)] +#![allow(trivial_bounds)] + +mod sus { + use super::*; + pub type Sep = impl Sized + std::fmt::Display; + //~^ ERROR: concrete type differs from previous defining opaque type use + pub fn mk_sep() -> Sep { + String::from("hello") + } + + pub trait Proj { + type Assoc; + } + impl Proj for () { + type Assoc = sus::Sep; + } + + pub struct Bar { + pub inner: ::Assoc, + pub _marker: T, + } + impl Clone for Bar { + fn clone(&self) -> Self { + todo!() + } + } + impl + Copy> Copy for Bar {} + // This allows producing `Tait`s via `From`, even though + // `define_tait` is not actually callable, and thus assumed + // `Bar<()>: Copy` even though it isn't. + pub type Tait = impl Copy + From> + Into>; + pub fn define_tait() -> Tait + where + // this proves `Bar<()>: Copy`, but `define_tait` is + // now uncallable + (): Proj, + { + Bar { inner: 1i32, _marker: () } + } +} + +fn copy_tait(x: sus::Tait) -> (sus::Tait, sus::Tait) { + (x, x) +} + +fn main() { + let bar = sus::Bar { inner: sus::mk_sep(), _marker: () }; + let (y, z) = copy_tait(bar.into()); // copy a string + drop(y.into()); // drop one instance + println!("{}", z.into().inner); // print the other +} diff --git a/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr new file mode 100644 index 000000000..85e8a600c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/hidden_type_mismatch.rs:11:20 + | +LL | pub type Sep = impl Sized + std::fmt::Display; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `String` + | +note: previous use here + --> $DIR/hidden_type_mismatch.rs:37:21 + | +LL | pub type Tait = impl Copy + From> + Into>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/inference-cycle.stderr b/tests/ui/type-alias-impl-trait/inference-cycle.stderr index 4d5f36747..41530dda9 100644 --- a/tests/ui/type-alias-impl-trait/inference-cycle.stderr +++ b/tests/ui/type-alias-impl-trait/inference-cycle.stderr @@ -16,6 +16,7 @@ note: cycle used when checking item types in module `m` | LL | mod m { | ^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` --> $DIR/inference-cycle.rs:5:20 @@ -34,6 +35,7 @@ note: cycle used when checking item types in module `m` | LL | mod m { | ^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: cannot check whether the hidden type of `inference_cycle[4ecc]::m::Foo::{opaque#0}` satisfies auto traits --> $DIR/inference-cycle.rs:16:17 diff --git a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr index 2565a28b4..6148131b4 100644 --- a/tests/ui/type-alias-impl-trait/issue-53092-2.stderr +++ b/tests/ui/type-alias-impl-trait/issue-53092-2.stderr @@ -23,6 +23,7 @@ LL | | type Bug = impl Fn(T) -> U + Copy; LL | | CONST_BUG(0); LL | | } | |_^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0277]: the trait bound `U: From` is not satisfied --> $DIR/issue-53092-2.rs:9:5 diff --git a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs index 2c740ccc1..fdd8fa65b 100644 --- a/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs +++ b/tests/ui/type-alias-impl-trait/issue-96572-unconstrained.rs @@ -1,5 +1,7 @@ #![feature(type_alias_impl_trait)] // check-pass +// revisions: default edition2021 +//[edition2021] compile-flags: --edition 2021 fn main() { type T = impl Copy; diff --git a/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs new file mode 100644 index 000000000..11b659eec --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested-rpit-with-lifetimes.rs @@ -0,0 +1,49 @@ +// Regression test for issue #83190, triggering an ICE in borrowck. + +// check-pass + +pub trait Any {} +impl Any for T {} + +pub trait StreamOnce { + type Range; +} + +pub trait Parser: Sized { + type Output; + type PartialState; + fn map(self) -> Map { + todo!() + } +} + +pub struct Map

(P); +impl> Parser for Map

{ + type Output = (); + type PartialState = P::PartialState; +} + +struct TakeWhile1(Input); +impl Parser for TakeWhile1 { + type Output = I::Range; + type PartialState = (); +} +impl TakeWhile1 { + fn new() -> Self { + todo!() + } +} + +impl> Parser for (A,) { + type Output = (); + type PartialState = Map; +} + +pub fn metric_stream_parser<'a, I>() -> impl Parser +where + I: StreamOnce, +{ + (TakeWhile1::new(),).map() +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs new file mode 100644 index 000000000..ba705d6f8 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.rs @@ -0,0 +1,15 @@ +#![feature(type_alias_impl_trait)] + +trait Trait<'a> { type Assoc; } +impl<'a> Trait<'a> for () { type Assoc = &'a str; } + +type WithoutLt = impl Sized; +fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {} +//~^ ERROR captures lifetime that does not appear in bounds + +type WithLt<'a> = impl Sized + 'a; + +fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {} +//~^ ERROR expected generic lifetime parameter, found `'a` + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr new file mode 100644 index 000000000..f20873055 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested-tait-hrtb.stderr @@ -0,0 +1,23 @@ +error[E0700]: hidden type for `WithoutLt` captures lifetime that does not appear in bounds + --> $DIR/nested-tait-hrtb.rs:7:62 + | +LL | type WithoutLt = impl Sized; + | ---------- opaque type defined here +LL | fn without_lt() -> impl for<'a> Trait<'a, Assoc = WithoutLt> {} + | -- ^^ + | | + | hidden type `&'a str` captures the lifetime `'a` as defined here + +error[E0792]: expected generic lifetime parameter, found `'a` + --> $DIR/nested-tait-hrtb.rs:12:60 + | +LL | type WithLt<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +LL | +LL | fn with_lt() -> impl for<'a> Trait<'a, Assoc = WithLt<'a>> {} + | ^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0700, E0792. +For more information about an error, try `rustc --explain E0700`. diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs new file mode 100644 index 000000000..10588398c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.rs @@ -0,0 +1,21 @@ +// issue: 113314 + +#![feature(type_alias_impl_trait)] + +type Op = impl std::fmt::Display; +fn foo() -> Op { &"hello world" } + +fn transform() -> impl std::fmt::Display { + &0usize +} +fn bad() -> Op { + transform::() + //~^ ERROR concrete type differs from previous defining opaque type use +} + +fn main() { + let mut x = foo(); + println!("{x}"); + x = bad(); + println!("{x}"); +} diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr new file mode 100644 index 000000000..7481557fc --- /dev/null +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn-2.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/recursive-tait-conflicting-defn-2.rs:12:5 + | +LL | transform::() + | ^^^^^^^^^^^^^^^^^ expected `&'static &'static str`, got `impl std::fmt::Display` + | +note: previous use here + --> $DIR/recursive-tait-conflicting-defn-2.rs:6:18 + | +LL | fn foo() -> Op { &"hello world" } + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs new file mode 100644 index 000000000..e221f4f3f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.rs @@ -0,0 +1,34 @@ +// issue: 113596 + +#![feature(type_alias_impl_trait)] + +trait Test {} + +struct A; + +impl Test for A {} + +struct B { + inner: T, +} + +impl Test for B {} + +type TestImpl = impl Test; + +fn test() -> TestImpl { + A +} + +fn make_option() -> Option { + Some(test()) +} + +fn make_option2() -> Option { + let inner = make_option().unwrap(); + + Some(B { inner }) + //~^ ERROR concrete type differs from previous defining opaque type use +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr new file mode 100644 index 000000000..e4209643b --- /dev/null +++ b/tests/ui/type-alias-impl-trait/recursive-tait-conflicting-defn.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/recursive-tait-conflicting-defn.rs:30:3 + | +LL | Some(B { inner }) + | ^^^^^^^^^^^^^^^^^ expected `A`, got `B` + | +note: previous use here + --> $DIR/recursive-tait-conflicting-defn.rs:20:3 + | +LL | A + | ^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/reveal_local.stderr b/tests/ui/type-alias-impl-trait/reveal_local.stderr index 0c5ef4a6f..813185c13 100644 --- a/tests/ui/type-alias-impl-trait/reveal_local.stderr +++ b/tests/ui/type-alias-impl-trait/reveal_local.stderr @@ -22,6 +22,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` --> $DIR/reveal_local.rs:5:12 @@ -46,6 +47,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits --> $DIR/reveal_local.rs:15:15 @@ -92,6 +94,7 @@ LL | | LL | | LL | | fn main() {} | |____________^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: cannot check whether the hidden type of `reveal_local[9507]::Foo::{opaque#0}` satisfies auto traits --> $DIR/reveal_local.rs:25:15 diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs new file mode 100644 index 000000000..b35100670 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs @@ -0,0 +1,25 @@ +#![feature(type_alias_impl_trait)] + +use std::fmt::Display; + +type Opaque = impl Sized + 'static; +fn define() -> Opaque {} + +trait Trait { + type Assoc: Display; +} +impl<'a> Trait for Opaque<&'a str> { + //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates + type Assoc = &'a str; +} + +// ======= Exploit ======= + +fn extend(s: T::Assoc) -> Box { + Box::new(s) +} + +fn main() { + let val = extend::>(&String::from("blah blah blah")); + println!("{}", val); +} diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr new file mode 100644 index 000000000..65139307f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr @@ -0,0 +1,9 @@ +error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-impl-param.rs:11:6 + | +LL | impl<'a> Trait for Opaque<&'a str> { + | ^^ unconstrained lifetime parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/under-binder.rs b/tests/ui/type-alias-impl-trait/under-binder.rs new file mode 100644 index 000000000..caf21d640 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/under-binder.rs @@ -0,0 +1,9 @@ +#![feature(type_alias_impl_trait)] + +type Opaque<'a> = impl Sized + 'a; + +fn test(f: fn(u8)) -> fn(Opaque<'_>) { + f //~ ERROR E0792 +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/under-binder.stderr b/tests/ui/type-alias-impl-trait/under-binder.stderr new file mode 100644 index 000000000..82c4ec973 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/under-binder.stderr @@ -0,0 +1,12 @@ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/under-binder.rs:6:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | f + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs new file mode 100644 index 000000000..b92e15aad --- /dev/null +++ b/tests/ui/type-alias-impl-trait/wf-check-rpit-lifetimes.rs @@ -0,0 +1,19 @@ +//check-pass + +pub struct Key; +#[derive(Clone)] +pub struct Value; + +use std::collections::HashMap; + +pub struct DiagnosticBuilder<'db> { + inner: HashMap<&'db Key, Vec<&'db Value>>, +} + +impl<'db> DiagnosticBuilder<'db> { + pub fn iter<'a>(&'a self) -> impl Iterator)> { + self.inner.iter().map(|(key, values)| (*key, values.iter().map(|v| *v))) + } +} + +fn main() {} -- cgit v1.2.3