From: Philip Herron <[email protected]>

Fixes Rust-GCC/gccrs#4152

gcc/testsuite/ChangeLog:

        * rust/compile/issues/issue-4152.rs: New test.

Signed-off-by: Philip Herron <[email protected]>

Tested on x86_64-pc-linux-gnu.

---
 .../rust/compile/issues/issue-4152.rs         | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issues/issue-4152.rs

diff --git a/gcc/testsuite/rust/compile/issues/issue-4152.rs 
b/gcc/testsuite/rust/compile/issues/issue-4152.rs
new file mode 100644
index 00000000000..257fd55b8ca
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issues/issue-4152.rs
@@ -0,0 +1,36 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+impl<'a> Thing for &'a u8 {
+    type Output = u8;
+
+    fn calc(&mut self) -> u8 {
+        **self
+    }
+}
+
+trait Thing {
+    type Output: 'static;
+
+    fn calc(&mut self) -> Self::Output;
+}
+
+impl<'a> Thing for &'a u8 {
+    type Output = u8;
+
+    fn calc(&mut self) -> u8 {
+        **self
+    }
+}
+
+fn get_thing(x: &u8) -> impl Thing + '_ {
+    x
+}
+
+fn f(n: &u8) -> impl Thing + 'static { // { dg-error "bounds not satisfied for 
u8 .Thing. is not satisfied" }
+    let mut t = get_thing(n);
+    t.calc()
+}
-- 
2.55.0

Reply via email to