From: Philip Herron <[email protected]>

Fixes Rust-GCC/gccrs#4675

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/a9842149166dca43b7808d64d06433c08c4e4912

The commit has been mentioned in the following issue(s):
 - Rust-GCC/gccrs#4675: https://github.com/Rust-GCC/gccrs/issues/4675

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4897

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

diff --git a/gcc/testsuite/rust/compile/issues/issue-4675.rs 
b/gcc/testsuite/rust/compile/issues/issue-4675.rs
new file mode 100644
index 000000000..5f516f7f5
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issues/issue-4675.rs
@@ -0,0 +1,19 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+struct Two<'a> { // { dg-warning "struct is never constructed: .Two." }
+    f: &'a i32,
+    g: &'a i32,
+}
+
+fn a() { // { dg-warning "function is never used: .a." }
+    let (mut t, f, g): (Two, i32, i32);
+    f = 42;
+    t = Two { f: &f, g: &f };
+    *t.f;
+    f = 42; // { dg-error "assignment of read-only variable 'f'" }
+    t.g = &g;
+}
-- 
2.55.0

Reply via email to