Skip to content

Commit 1d4306f

Browse files
committed
Fix testcase module path
Those tests are coming from libcore and module inlining was wrong, in libcore there was a use declaration to import those modules which was missing here. gcc/testsuite/ChangeLog: * rust/compile/issue-2330.rs: Use complete path from crate root. * rust/compile/issue-1901.rs: Likewise. * rust/compile/issue-1981.rs: Likewise. * rust/compile/iterators1.rs: Likewise. * rust/compile/sizeof-stray-infer-var-bug.rs: Likewise. * rust/compile/for-loop1.rs: Likewise. * rust/compile/for-loop2.rs: Likewise. * rust/compile/torture/builtin_abort.rs: Likewise. * rust/compile/torture/uninit-intrinsic-1.rs: Likewise. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
1 parent bb08a82 commit 1d4306f

File tree

9 files changed

+139
-137
lines changed

9 files changed

+139
-137
lines changed

gcc/testsuite/rust/compile/for-loop1.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -102,51 +102,51 @@ mod ptr {
102102
#[lang = "const_ptr"]
103103
impl<T> *const T {
104104
pub unsafe fn offset(self, count: isize) -> *const T {
105-
intrinsics::offset(self, count)
105+
crate::intrinsics::offset(self, count)
106106
}
107107
}
108108

109109
#[lang = "mut_ptr"]
110110
impl<T> *mut T {
111111
pub unsafe fn offset(self, count: isize) -> *mut T {
112-
intrinsics::offset(self, count) as *mut T
112+
crate::intrinsics::offset(self, count) as *mut T
113113
}
114114
}
115115

116116
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
117117
let x = x as *mut u8;
118118
let y = y as *mut u8;
119-
let len = mem::size_of::<T>() * count;
119+
let len = crate::mem::size_of::<T>() * count;
120120
swap_nonoverlapping_bytes(x, y, len)
121121
}
122122

123123
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
124124
// For types smaller than the block optimization below,
125125
// just swap directly to avoid pessimizing codegen.
126-
if mem::size_of::<T>() < 32 {
126+
if crate::mem::size_of::<T>() < 32 {
127127
let z = read(x);
128-
intrinsics::copy_nonoverlapping(y, x, 1);
128+
crate::intrinsics::copy_nonoverlapping(y, x, 1);
129129
write(y, z);
130130
} else {
131131
swap_nonoverlapping(x, y, 1);
132132
}
133133
}
134134

135135
pub unsafe fn write<T>(dst: *mut T, src: T) {
136-
intrinsics::move_val_init(&mut *dst, src)
136+
crate::intrinsics::move_val_init(&mut *dst, src)
137137
}
138138

139139
pub unsafe fn read<T>(src: *const T) -> T {
140-
let mut tmp: T = mem::uninitialized();
141-
intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
140+
let mut tmp: T = crate::mem::uninitialized();
141+
crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
142142
tmp
143143
}
144144

145145
pub unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
146146
struct Block(u64, u64, u64, u64);
147147
struct UnalignedBlock(u64, u64, u64, u64);
148148

149-
let block_size = mem::size_of::<Block>();
149+
let block_size = crate::mem::size_of::<Block>();
150150

151151
// Loop through x & y, copying them `Block` at a time
152152
// The optimizer should unroll the loop fully for most types
@@ -155,31 +155,31 @@ mod ptr {
155155
while i + block_size <= len {
156156
// Create some uninitialized memory as scratch space
157157
// Declaring `t` here avoids aligning the stack when this loop is unused
158-
let mut t: Block = mem::uninitialized();
158+
let mut t: Block = crate::mem::uninitialized();
159159
let t = &mut t as *mut _ as *mut u8;
160160
let x = x.offset(i as isize);
161161
let y = y.offset(i as isize);
162162

163163
// Swap a block of bytes of x & y, using t as a temporary buffer
164164
// This should be optimized into efficient SIMD operations where available
165-
intrinsics::copy_nonoverlapping(x, t, block_size);
166-
intrinsics::copy_nonoverlapping(y, x, block_size);
167-
intrinsics::copy_nonoverlapping(t, y, block_size);
165+
crate::intrinsics::copy_nonoverlapping(x, t, block_size);
166+
crate::intrinsics::copy_nonoverlapping(y, x, block_size);
167+
crate::intrinsics::copy_nonoverlapping(t, y, block_size);
168168
i += block_size;
169169
}
170170

171171
if i < len {
172172
// Swap any remaining bytes
173-
let mut t: UnalignedBlock = mem::uninitialized();
173+
let mut t: UnalignedBlock = crate::mem::uninitialized();
174174
let rem = len - i;
175175

176176
let t = &mut t as *mut _ as *mut u8;
177177
let x = x.offset(i as isize);
178178
let y = y.offset(i as isize);
179179

180-
intrinsics::copy_nonoverlapping(x, t, rem);
181-
intrinsics::copy_nonoverlapping(y, x, rem);
182-
intrinsics::copy_nonoverlapping(t, y, rem);
180+
crate::intrinsics::copy_nonoverlapping(x, t, rem);
181+
crate::intrinsics::copy_nonoverlapping(y, x, rem);
182+
crate::intrinsics::copy_nonoverlapping(t, y, rem);
183183
}
184184
}
185185
}
@@ -194,7 +194,7 @@ mod mem {
194194

195195
pub fn swap<T>(x: &mut T, y: &mut T) {
196196
unsafe {
197-
ptr::swap_nonoverlapping_one(x, y);
197+
crate::ptr::swap_nonoverlapping_one(x, y);
198198
}
199199
}
200200

@@ -204,7 +204,7 @@ mod mem {
204204
}
205205

206206
pub unsafe fn uninitialized<T>() -> T {
207-
intrinsics::uninit()
207+
crate::intrinsics::uninit()
208208
}
209209
}
210210

@@ -214,25 +214,25 @@ macro_rules! impl_uint {
214214
impl $ty {
215215
pub fn wrapping_add(self, rhs: Self) -> Self {
216216
unsafe {
217-
intrinsics::wrapping_add(self, rhs)
217+
crate::intrinsics::wrapping_add(self, rhs)
218218
}
219219
}
220220

221221
pub fn wrapping_sub(self, rhs: Self) -> Self {
222222
unsafe {
223-
intrinsics::wrapping_sub(self, rhs)
223+
crate::intrinsics::wrapping_sub(self, rhs)
224224
}
225225
}
226226

227227
pub fn rotate_left(self, n: u32) -> Self {
228228
unsafe {
229-
intrinsics::rotate_left(self, n as Self)
229+
crate::intrinsics::rotate_left(self, n as Self)
230230
}
231231
}
232232

233233
pub fn rotate_right(self, n: u32) -> Self {
234234
unsafe {
235-
intrinsics::rotate_right(self, n as Self)
235+
crate::intrinsics::rotate_right(self, n as Self)
236236
}
237237
}
238238

@@ -243,7 +243,7 @@ macro_rules! impl_uint {
243243
}
244244
}
245245

246-
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
246+
pub const fn from_le_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
247247
Self::from_le(Self::from_ne_bytes(bytes))
248248
}
249249

@@ -254,8 +254,8 @@ macro_rules! impl_uint {
254254
}
255255
}
256256

257-
pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
258-
unsafe { mem::transmute(bytes) }
257+
pub const fn from_ne_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
258+
unsafe { crate::mem::transmute(bytes) }
259259
}
260260

261261
pub fn checked_add(self, rhs: Self) -> Option<Self> {
@@ -268,7 +268,7 @@ macro_rules! impl_uint {
268268
}
269269

270270
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
271-
let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
271+
let (a, b) = unsafe { crate::intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
272272
(a as Self, b)
273273
}
274274
}
@@ -384,12 +384,12 @@ macro_rules! step_identical_methods {
384384
() => {
385385
#[inline]
386386
fn replace_one(&mut self) -> Self {
387-
mem::replace(self, 1)
387+
crate::mem::replace(self, 1)
388388
}
389389

390390
#[inline]
391391
fn replace_zero(&mut self) -> Self {
392-
mem::replace(self, 0)
392+
crate::mem::replace(self, 0)
393393
}
394394

395395
#[inline]
@@ -505,7 +505,7 @@ impl<A: Step> Iterator for Range<A> {
505505
// and this won't actually result in an extra check in an optimized build.
506506
match self.start.add_usize(1) {
507507
Option::Some(mut n) => {
508-
mem::swap(&mut n, &mut self.start);
508+
crate::mem::swap(&mut n, &mut self.start);
509509
Option::Some(n)
510510
}
511511
Option::None => Option::None,

0 commit comments

Comments
 (0)