Skip to content

Commit cf66d91

Browse files
committed
Add regression test for #71546
1 parent d35d972 commit cf66d91

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/test/ui/borrowck/issue-71546.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for #71546.
2+
3+
pub fn serialize_as_csv<V>(value: &V) -> Result<String, &str>
4+
where
5+
V: 'static,
6+
for<'a> &'a V: IntoIterator,
7+
for<'a> <&'a V as IntoIterator>::Item: ToString + 'static,
8+
{
9+
let csv_str: String = value //~ ERROR: the associated type `<&'a V as IntoIterator>::Item` may not live long enough
10+
.into_iter()
11+
.map(|elem| elem.to_string())
12+
.collect::<String>();
13+
Ok(csv_str)
14+
}
15+
16+
fn main() {}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0310]: the associated type `<&'a V as IntoIterator>::Item` may not live long enough
2+
--> $DIR/issue-71546.rs:9:27
3+
|
4+
LL | let csv_str: String = value
5+
| ___________________________^
6+
LL | | .into_iter()
7+
LL | | .map(|elem| elem.to_string())
8+
| |_____________________________________^
9+
|
10+
= help: consider adding an explicit lifetime bound `<&'a V as IntoIterator>::Item: 'static`...
11+
= note: ...so that the type `<&'a V as IntoIterator>::Item` will meet its required lifetime bounds...
12+
note: ...that is required by this bound
13+
--> $DIR/issue-71546.rs:7:55
14+
|
15+
LL | for<'a> <&'a V as IntoIterator>::Item: ToString + 'static,
16+
| ^^^^^^^
17+
18+
error: aborting due to previous error
19+
20+
For more information about this error, try `rustc --explain E0310`.

0 commit comments

Comments
 (0)