Skip to content

Commit a7bd0d0

Browse files
authored
Rollup merge of #97580 - JohnTitor:issue-71546, r=compiler-errors
Add regression test for #71546 Closes #71546 r? `@compiler-errors`
2 parents 2f99f1b + ea50d77 commit a7bd0d0

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for #71546.
2+
3+
// ignore-compare-mode-nll
4+
// NLL stderr is different from the original one.
5+
6+
pub fn serialize_as_csv<V>(value: &V) -> Result<String, &str>
7+
where
8+
V: 'static,
9+
for<'a> &'a V: IntoIterator,
10+
for<'a> <&'a V as IntoIterator>::Item: ToString + 'static,
11+
{
12+
let csv_str: String = value //~ ERROR: the associated type `<&'a V as IntoIterator>::Item` may not live long enough
13+
.into_iter()
14+
.map(|elem| elem.to_string())
15+
.collect::<String>();
16+
Ok(csv_str)
17+
}
18+
19+
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:12: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:10: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)