aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-05-25 15:01:52 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-05-25 15:01:52 +0100
commit3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61 (patch)
tree6c97278aeaf9147d25198ad683127425a1b02dee /gcc
parentd5c1531cc41ea7fab4d522dafe3ff725a766fb49 (diff)
downloadgcc-3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61.zip
gcc-3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61.tar.gz
gcc-3a95f28788d6a7b1870f6247c5fa1e5af1ff8a61.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/issue-1237.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-1237.rs b/gcc/testsuite/rust/compile/issue-1237.rs
new file mode 100644
index 0000000..542be89
--- /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)
+}