From 4e8199b572f2035b7749cba276ece3a26630d23e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:21 +0200 Subject: Adding upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/impl-trait/issues/issue-104815.rs | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/test/ui/impl-trait/issues/issue-104815.rs (limited to 'src/test/ui/impl-trait/issues/issue-104815.rs') diff --git a/src/test/ui/impl-trait/issues/issue-104815.rs b/src/test/ui/impl-trait/issues/issue-104815.rs new file mode 100644 index 000000000..7a9826a8d --- /dev/null +++ b/src/test/ui/impl-trait/issues/issue-104815.rs @@ -0,0 +1,66 @@ +// check-pass + +struct It; + +struct Data { + items: Vec, +} + +impl Data { + fn new() -> Self { + Self { + items: vec![It, It], + } + } + + fn content(&self) -> impl Iterator { + self.items.iter() + } +} + +struct Container<'a> { + name: String, + resolver: Box, +} + +impl<'a> Container<'a> { + fn new(name: &str, resolver: R) -> Self { + Self { + name: name.to_owned(), + resolver: Box::new(resolver), + } + } +} + +trait Resolver {} + +impl Resolver for &R {} + +impl Resolver for It {} + +fn get<'a>(mut items: impl Iterator) -> impl Resolver + 'a { + items.next().unwrap() +} + +fn get2<'a, 'b: 'b>(mut items: impl Iterator) -> impl Resolver + 'a { + items.next().unwrap() +} + +fn main() { + let data = Data::new(); + let resolver = get(data.content()); + + let _ = ["a", "b"] + .iter() + .map(|&n| Container::new(n, &resolver)) + .map(|c| c.name) + .collect::>(); + + let resolver = get2(data.content()); + + let _ = ["a", "b"] + .iter() + .map(|&n| Container::new(n, &resolver)) + .map(|c| c.name) + .collect::>(); +} -- cgit v1.2.3