Debian Codegraph @

gcc/testsuite/rust/compile/issue-1901.rs

raw
1 #![feature(intrinsics)]
2
3 #[lang = "sized"]
4 pub trait Sized {}
5
6 mod intrinsics {
7 extern "rust-intrinsic" {
8 pub fn offset<T>(ptr: *const T, count: isize) -> *const T;
9 }
10 }
11
12 mod ptr {
13 #[lang = "const_ptr"]
14 impl<T> *const T {
15 pub unsafe fn offset(self, count: isize) -> *const T {
16 crate::intrinsics::offset(self, count)
17 }
18 }
19
20 #[lang = "mut_ptr"]
21 impl<T> *mut T {
22 pub unsafe fn offset(self, count: isize) -> *mut T {
23 crate::intrinsics::offset(self, count) as *mut T
24 }
25 }
26 }
27
28 pub fn test_const(x: *const u8) {
29 unsafe {
30 x.offset(1);
31 }
32 }
33
34 pub fn test_mut(x: *mut u8) {
35 unsafe {
36 x.offset(1);
37 }
38 }