diff options
author | Yuki Okushi <jtitor@2k36.org> | 2022-06-01 23:36:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 23:36:51 +0900 |
commit | a7bd0d0e07ae1c5c680a32ecf2b5e5556c6935f6 (patch) | |
tree | 524f01d405933a251573a2a0c28094bba67073b9 | |
parent | 2f99f1b3a48eb03221c56681c0ed8252f04c9df4 (diff) | |
parent | ea50d773e3f75855ca8a40ca72ad8f8c67153474 (diff) | |
download | rust-a7bd0d0e07ae1c5c680a32ecf2b5e5556c6935f6.tar.gz |
Rollup merge of #97580 - JohnTitor:issue-71546, r=compiler-errors
Add regression test for #71546
Closes #71546
r? `@compiler-errors`
-rw-r--r-- | src/test/ui/borrowck/issue-71546.rs | 19 | ||||
-rw-r--r-- | src/test/ui/borrowck/issue-71546.stderr | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-71546.rs b/src/test/ui/borrowck/issue-71546.rs new file mode 100644 index 00000000000..943f7f86e55 --- /dev/null +++ b/src/test/ui/borrowck/issue-71546.rs @@ -0,0 +1,19 @@ +// Regression test for #71546. + +// ignore-compare-mode-nll +// NLL stderr is different from the original one. + +pub fn serialize_as_csv<V>(value: &V) -> Result<String, &str> +where + V: 'static, + for<'a> &'a V: IntoIterator, + for<'a> <&'a V as IntoIterator>::Item: ToString + 'static, +{ + let csv_str: String = value //~ ERROR: the associated type `<&'a V as IntoIterator>::Item` may not live long enough + .into_iter() + .map(|elem| elem.to_string()) + .collect::<String>(); + Ok(csv_str) +} + +fn main() {} diff --git a/src/test/ui/borrowck/issue-71546.stderr b/src/test/ui/borrowck/issue-71546.stderr new file mode 100644 index 00000000000..d479ca8f1d8 --- /dev/null +++ b/src/test/ui/borrowck/issue-71546.stderr @@ -0,0 +1,20 @@ +error[E0310]: the associated type `<&'a V as IntoIterator>::Item` may not live long enough + --> $DIR/issue-71546.rs:12:27 + | +LL | let csv_str: String = value + | ___________________________^ +LL | | .into_iter() +LL | | .map(|elem| elem.to_string()) + | |_____________________________________^ + | + = help: consider adding an explicit lifetime bound `<&'a V as IntoIterator>::Item: 'static`... + = note: ...so that the type `<&'a V as IntoIterator>::Item` will meet its required lifetime bounds... +note: ...that is required by this bound + --> $DIR/issue-71546.rs:10:55 + | +LL | for<'a> <&'a V as IntoIterator>::Item: ToString + 'static, + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. |