public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add testcase to prove bug is fixed
@ 2022-06-08 12:50 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61

commit 3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Wed May 25 15:01:52 2022 +0100

    Add testcase to prove bug is fixed
    
    This bug was fixed in commit cb4d935508def8b250345ba5205a90ad9e177ab4
    with related PR #1223
    
    The issue is that associated tpyes get updated depending on the context
    they are used so we need to monomorphize the types when we can so that we
    don't then throw off the rest of typechecking with bogus errors like this.
    
    Fixes #1237

Diff:
---
 gcc/testsuite/rust/compile/issue-1237.rs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gcc/testsuite/rust/compile/issue-1237.rs b/gcc/testsuite/rust/compile/issue-1237.rs
new file mode 100644
index 00000000000..542be897949
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-1237.rs
@@ -0,0 +1,23 @@
+// { dg-additional-options "-w" }
+mod intrinsics {
+    extern "rust-intrinsic" {
+        pub fn offset<T>(ptr: *const T, count: isize) -> *const T;
+    }
+}
+
+impl<T> *const T {
+    pub unsafe fn offset(self, count: isize) -> *const T {
+        unsafe { intrinsics::offset(self, count) }
+    }
+}
+
+impl<T> [T] {
+    pub unsafe fn get_unchecked(&self, index: usize) -> &T {
+        unsafe { &*(self as *const [T] as *const T).offset(index as isize) }
+    }
+}
+
+#[inline]
+unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
+    (unsafe { *buf.get_unchecked(start) } as u64)
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:50 [gcc/devel/rust/master] Add testcase to prove bug is fixed Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).