aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r--gcc/testsuite/rust/compile/cfg-core1.rs12
-rw-r--r--gcc/testsuite/rust/compile/cfg-core2.rs12
-rw-r--r--gcc/testsuite/rust/compile/const_generics_3.rs8
-rw-r--r--gcc/testsuite/rust/compile/feature_rust_attri0.rs6
-rw-r--r--gcc/testsuite/rust/compile/for-loop1.rs60
-rw-r--r--gcc/testsuite/rust/compile/for-loop2.rs66
-rw-r--r--gcc/testsuite/rust/compile/issue-1901.rs4
-rw-r--r--gcc/testsuite/rust/compile/issue-1981.rs40
-rw-r--r--gcc/testsuite/rust/compile/issue-2330.rs38
-rw-r--r--gcc/testsuite/rust/compile/issue-2905-2.rs8
-rw-r--r--gcc/testsuite/rust/compile/issue-3242.rs1
-rw-r--r--gcc/testsuite/rust/compile/issue-3541-1.rs5
-rw-r--r--gcc/testsuite/rust/compile/issue-3541-2.rs3
-rw-r--r--gcc/testsuite/rust/compile/issue-3549.rs3
-rw-r--r--gcc/testsuite/rust/compile/issue-3552.rs14
-rw-r--r--gcc/testsuite/rust/compile/issue-3553.rs18
-rw-r--r--gcc/testsuite/rust/compile/issue-3554-1.rs8
-rw-r--r--gcc/testsuite/rust/compile/issue-3554-2.rs18
-rw-r--r--gcc/testsuite/rust/compile/issue-3563.rs17
-rw-r--r--gcc/testsuite/rust/compile/issue-3566-1.rs8
-rw-r--r--gcc/testsuite/rust/compile/issue-3566-2.rs22
-rw-r--r--gcc/testsuite/rust/compile/issue-3567.rs4
-rw-r--r--gcc/testsuite/rust/compile/issue-3568.rs7
-rw-r--r--gcc/testsuite/rust/compile/issue-3588.rs5
-rw-r--r--gcc/testsuite/rust/compile/issue-3605.rs5
-rw-r--r--gcc/testsuite/rust/compile/issue-3606.rs6
-rw-r--r--gcc/testsuite/rust/compile/issue-3613.rs18
-rw-r--r--gcc/testsuite/rust/compile/issue-3614.rs3
-rw-r--r--gcc/testsuite/rust/compile/issue-3615.rs7
-rw-r--r--gcc/testsuite/rust/compile/iterators1.rs58
-rw-r--r--gcc/testsuite/rust/compile/macros/mbe/macro43.rs15
-rw-r--r--gcc/testsuite/rust/compile/nr2/exclude15
-rw-r--r--gcc/testsuite/rust/compile/self_import_namespace.rs14
-rw-r--r--gcc/testsuite/rust/compile/sizeof-stray-infer-var-bug.rs2
-rw-r--r--gcc/testsuite/rust/compile/torture/builtin_abort.rs4
-rw-r--r--gcc/testsuite/rust/compile/torture/uninit-intrinsic-1.rs4
36 files changed, 374 insertions, 164 deletions
diff --git a/gcc/testsuite/rust/compile/cfg-core1.rs b/gcc/testsuite/rust/compile/cfg-core1.rs
new file mode 100644
index 0000000..7780cc9
--- /dev/null
+++ b/gcc/testsuite/rust/compile/cfg-core1.rs
@@ -0,0 +1,12 @@
+// { dg-additional-options "-frust-cfg=A -frust-cfg=B" }
+
+#[cfg_attr(A, cfg(B))]
+struct Foo0;
+
+#[cfg_attr(A, cfg(C))]
+struct Bar0;
+
+fn main() {
+ let a = Foo0;
+ let a = Bar0; // { dg-error "cannot find value" }
+}
diff --git a/gcc/testsuite/rust/compile/cfg-core2.rs b/gcc/testsuite/rust/compile/cfg-core2.rs
new file mode 100644
index 0000000..e346edd
--- /dev/null
+++ b/gcc/testsuite/rust/compile/cfg-core2.rs
@@ -0,0 +1,12 @@
+// { dg-additional-options "-frust-cfg=B" }
+
+#[cfg(not(any(A, B)))]
+struct Foo0;
+
+#[cfg(not(any(A, C)))]
+struct Bar0;
+
+fn main() {
+ let a = Foo0; // { dg-error "cannot find value" }
+ let a = Bar0;
+}
diff --git a/gcc/testsuite/rust/compile/const_generics_3.rs b/gcc/testsuite/rust/compile/const_generics_3.rs
index e4e9008..524d48d 100644
--- a/gcc/testsuite/rust/compile/const_generics_3.rs
+++ b/gcc/testsuite/rust/compile/const_generics_3.rs
@@ -1,10 +1,12 @@
-// { dg-additional-options "-w" }
+// { dg-additional-options "-w -frust-name-resolution-2.0" }
+
+#[lang = "sized"]
+trait Sized {}
const M: usize = 4;
struct Foo<T, const N: usize = 1> {
- // FIXME: This error is bogus. But having it means parsing is valid!
- value: [i32; N], // { dg-error "cannot find value .N. in this scope" }
+ value: [T; N],
}
fn main() {
diff --git a/gcc/testsuite/rust/compile/feature_rust_attri0.rs b/gcc/testsuite/rust/compile/feature_rust_attri0.rs
index 9c11f56..1937acf 100644
--- a/gcc/testsuite/rust/compile/feature_rust_attri0.rs
+++ b/gcc/testsuite/rust/compile/feature_rust_attri0.rs
@@ -1,3 +1,7 @@
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
#[rustc_builtin_macro] //{ dg-error "internal implementation detail. " "" { target *-*-* } }
macro_rules! line {
() => {{}};
@@ -5,7 +9,7 @@ macro_rules! line {
fn main() -> i32 {
let a = line!();
- print(a);
+ printf("%d\0" as *const str as *const i8, a);
0
}
diff --git a/gcc/testsuite/rust/compile/for-loop1.rs b/gcc/testsuite/rust/compile/for-loop1.rs
index 1023ecd..21e0399 100644
--- a/gcc/testsuite/rust/compile/for-loop1.rs
+++ b/gcc/testsuite/rust/compile/for-loop1.rs
@@ -102,30 +102,30 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
swap_nonoverlapping_bytes(x, y, len)
}
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
- if mem::size_of::<T>() < 32 {
+ if crate::mem::size_of::<T>() < 32 {
let z = read(x);
- intrinsics::copy_nonoverlapping(y, x, 1);
+ crate::intrinsics::copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
@@ -133,12 +133,12 @@ mod ptr {
}
pub unsafe fn write<T>(dst: *mut T, src: T) {
- intrinsics::move_val_init(&mut *dst, src)
+ crate::intrinsics::move_val_init(&mut *dst, src)
}
pub unsafe fn read<T>(src: *const T) -> T {
- let mut tmp: T = mem::uninitialized();
- intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+ let mut tmp: T = crate::mem::uninitialized();
+ crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
tmp
}
@@ -146,7 +146,7 @@ mod ptr {
struct Block(u64, u64, u64, u64);
struct UnalignedBlock(u64, u64, u64, u64);
- let block_size = mem::size_of::<Block>();
+ let block_size = crate::mem::size_of::<Block>();
// Loop through x & y, copying them `Block` at a time
// The optimizer should unroll the loop fully for most types
@@ -155,31 +155,31 @@ mod ptr {
while i + block_size <= len {
// Create some uninitialized memory as scratch space
// Declaring `t` here avoids aligning the stack when this loop is unused
- let mut t: Block = mem::uninitialized();
+ let mut t: Block = crate::mem::uninitialized();
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
// Swap a block of bytes of x & y, using t as a temporary buffer
// This should be optimized into efficient SIMD operations where available
- intrinsics::copy_nonoverlapping(x, t, block_size);
- intrinsics::copy_nonoverlapping(y, x, block_size);
- intrinsics::copy_nonoverlapping(t, y, block_size);
+ crate::intrinsics::copy_nonoverlapping(x, t, block_size);
+ crate::intrinsics::copy_nonoverlapping(y, x, block_size);
+ crate::intrinsics::copy_nonoverlapping(t, y, block_size);
i += block_size;
}
if i < len {
// Swap any remaining bytes
- let mut t: UnalignedBlock = mem::uninitialized();
+ let mut t: UnalignedBlock = crate::mem::uninitialized();
let rem = len - i;
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
- intrinsics::copy_nonoverlapping(x, t, rem);
- intrinsics::copy_nonoverlapping(y, x, rem);
- intrinsics::copy_nonoverlapping(t, y, rem);
+ crate::intrinsics::copy_nonoverlapping(x, t, rem);
+ crate::intrinsics::copy_nonoverlapping(y, x, rem);
+ crate::intrinsics::copy_nonoverlapping(t, y, rem);
}
}
}
@@ -194,7 +194,7 @@ mod mem {
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
- ptr::swap_nonoverlapping_one(x, y);
+ crate::ptr::swap_nonoverlapping_one(x, y);
}
}
@@ -204,7 +204,7 @@ mod mem {
}
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
@@ -214,25 +214,25 @@ macro_rules! impl_uint {
impl $ty {
pub fn wrapping_add(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_add(self, rhs)
+ crate::intrinsics::wrapping_add(self, rhs)
}
}
pub fn wrapping_sub(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_sub(self, rhs)
+ crate::intrinsics::wrapping_sub(self, rhs)
}
}
pub fn rotate_left(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_left(self, n as Self)
+ crate::intrinsics::rotate_left(self, n as Self)
}
}
pub fn rotate_right(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_right(self, n as Self)
+ crate::intrinsics::rotate_right(self, n as Self)
}
}
@@ -243,7 +243,7 @@ macro_rules! impl_uint {
}
}
- pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
+ pub const fn from_le_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
}
@@ -254,8 +254,8 @@ macro_rules! impl_uint {
}
}
- pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
- unsafe { mem::transmute(bytes) }
+ pub const fn from_ne_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
+ unsafe { crate::mem::transmute(bytes) }
}
pub fn checked_add(self, rhs: Self) -> Option<Self> {
@@ -268,7 +268,7 @@ macro_rules! impl_uint {
}
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
- let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
+ let (a, b) = unsafe { crate::intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
(a as Self, b)
}
}
@@ -384,12 +384,12 @@ macro_rules! step_identical_methods {
() => {
#[inline]
fn replace_one(&mut self) -> Self {
- mem::replace(self, 1)
+ crate::mem::replace(self, 1)
}
#[inline]
fn replace_zero(&mut self) -> Self {
- mem::replace(self, 0)
+ crate::mem::replace(self, 0)
}
#[inline]
@@ -505,7 +505,7 @@ impl<A: Step> Iterator for Range<A> {
// and this won't actually result in an extra check in an optimized build.
match self.start.add_usize(1) {
Option::Some(mut n) => {
- mem::swap(&mut n, &mut self.start);
+ crate::mem::swap(&mut n, &mut self.start);
Option::Some(n)
}
Option::None => Option::None,
diff --git a/gcc/testsuite/rust/compile/for-loop2.rs b/gcc/testsuite/rust/compile/for-loop2.rs
index d18bddd..a0ad066 100644
--- a/gcc/testsuite/rust/compile/for-loop2.rs
+++ b/gcc/testsuite/rust/compile/for-loop2.rs
@@ -102,30 +102,30 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
swap_nonoverlapping_bytes(x, y, len)
}
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
- if mem::size_of::<T>() < 32 {
+ if crate::mem::size_of::<T>() < 32 {
let z = read(x);
- intrinsics::copy_nonoverlapping(y, x, 1);
+ crate::intrinsics::copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
@@ -133,12 +133,12 @@ mod ptr {
}
pub unsafe fn write<T>(dst: *mut T, src: T) {
- intrinsics::move_val_init(&mut *dst, src)
+ crate::intrinsics::move_val_init(&mut *dst, src)
}
pub unsafe fn read<T>(src: *const T) -> T {
- let mut tmp: T = mem::uninitialized();
- intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+ let mut tmp: T = crate::mem::uninitialized();
+ crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
tmp
}
@@ -146,7 +146,7 @@ mod ptr {
struct Block(u64, u64, u64, u64);
struct UnalignedBlock(u64, u64, u64, u64);
- let block_size = mem::size_of::<Block>();
+ let block_size = crate::mem::size_of::<Block>();
// Loop through x & y, copying them `Block` at a time
// The optimizer should unroll the loop fully for most types
@@ -155,31 +155,31 @@ mod ptr {
while i + block_size <= len {
// Create some uninitialized memory as scratch space
// Declaring `t` here avoids aligning the stack when this loop is unused
- let mut t: Block = mem::uninitialized();
+ let mut t: Block = crate::mem::uninitialized();
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
// Swap a block of bytes of x & y, using t as a temporary buffer
// This should be optimized into efficient SIMD operations where available
- intrinsics::copy_nonoverlapping(x, t, block_size);
- intrinsics::copy_nonoverlapping(y, x, block_size);
- intrinsics::copy_nonoverlapping(t, y, block_size);
+ crate::intrinsics::copy_nonoverlapping(x, t, block_size);
+ crate::intrinsics::copy_nonoverlapping(y, x, block_size);
+ crate::intrinsics::copy_nonoverlapping(t, y, block_size);
i += block_size;
}
if i < len {
// Swap any remaining bytes
- let mut t: UnalignedBlock = mem::uninitialized();
+ let mut t: UnalignedBlock = crate::mem::uninitialized();
let rem = len - i;
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
- intrinsics::copy_nonoverlapping(x, t, rem);
- intrinsics::copy_nonoverlapping(y, x, rem);
- intrinsics::copy_nonoverlapping(t, y, rem);
+ crate::intrinsics::copy_nonoverlapping(x, t, rem);
+ crate::intrinsics::copy_nonoverlapping(y, x, rem);
+ crate::intrinsics::copy_nonoverlapping(t, y, rem);
}
}
}
@@ -194,7 +194,7 @@ mod mem {
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
- ptr::swap_nonoverlapping_one(x, y);
+ crate::ptr::swap_nonoverlapping_one(x, y);
}
}
@@ -204,7 +204,7 @@ mod mem {
}
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
@@ -214,25 +214,25 @@ macro_rules! impl_uint {
impl $ty {
pub fn wrapping_add(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_add(self, rhs)
+ crate::intrinsics::wrapping_add(self, rhs)
}
}
pub fn wrapping_sub(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_sub(self, rhs)
+ crate::intrinsics::wrapping_sub(self, rhs)
}
}
pub fn rotate_left(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_left(self, n as Self)
+ crate::intrinsics::rotate_left(self, n as Self)
}
}
pub fn rotate_right(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_right(self, n as Self)
+ crate::intrinsics::rotate_right(self, n as Self)
}
}
@@ -243,7 +243,7 @@ macro_rules! impl_uint {
}
}
- pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
+ pub const fn from_le_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes))
}
@@ -254,8 +254,8 @@ macro_rules! impl_uint {
}
}
- pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
- unsafe { mem::transmute(bytes) }
+ pub const fn from_ne_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
+ unsafe { crate::mem::transmute(bytes) }
}
pub fn checked_add(self, rhs: Self) -> Option<Self> {
@@ -268,7 +268,7 @@ macro_rules! impl_uint {
}
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
- let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
+ let (a, b) = unsafe { crate::intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
(a as Self, b)
}
}
@@ -384,12 +384,12 @@ macro_rules! step_identical_methods {
() => {
#[inline]
fn replace_one(&mut self) -> Self {
- mem::replace(self, 1)
+ crate::mem::replace(self, 1)
}
#[inline]
fn replace_zero(&mut self) -> Self {
- mem::replace(self, 0)
+ crate::mem::replace(self, 0)
}
#[inline]
@@ -505,7 +505,7 @@ impl<A: Step> Iterator for Range<A> {
// and this won't actually result in an extra check in an optimized build.
match self.start.add_usize(1) {
Option::Some(mut n) => {
- mem::swap(&mut n, &mut self.start);
+ crate::mem::swap(&mut n, &mut self.start);
Option::Some(n)
}
Option::None => Option::None,
@@ -536,10 +536,12 @@ impl<I: Iterator> IntoIterator for I {
pub fn main() {
// make sure we can desugar for-loops inside other blocks
-
+
if true {
for _ in 20usize..40usize {
- unsafe { puts("loop\0" as *const str as *const i8); }
+ unsafe {
+ puts("loop\0" as *const str as *const i8);
+ }
}
}
}
diff --git a/gcc/testsuite/rust/compile/issue-1901.rs b/gcc/testsuite/rust/compile/issue-1901.rs
index cfd8ef4..b43e34f 100644
--- a/gcc/testsuite/rust/compile/issue-1901.rs
+++ b/gcc/testsuite/rust/compile/issue-1901.rs
@@ -13,14 +13,14 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
}
diff --git a/gcc/testsuite/rust/compile/issue-1981.rs b/gcc/testsuite/rust/compile/issue-1981.rs
index bfd8d2c..de9588c 100644
--- a/gcc/testsuite/rust/compile/issue-1981.rs
+++ b/gcc/testsuite/rust/compile/issue-1981.rs
@@ -16,30 +16,30 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
swap_nonoverlapping_bytes(x, y, len)
}
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
- if mem::size_of::<T>() < 32 {
+ if crate::mem::size_of::<T>() < 32 {
let z = read(x);
- intrinsics::copy_nonoverlapping(y, x, 1);
+ crate::intrinsics::copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
@@ -47,12 +47,12 @@ mod ptr {
}
pub unsafe fn write<T>(dst: *mut T, src: T) {
- intrinsics::move_val_init(&mut *dst, src)
+ crate::intrinsics::move_val_init(&mut *dst, src)
}
pub unsafe fn read<T>(src: *const T) -> T {
- let mut tmp: T = mem::uninitialized();
- intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+ let mut tmp: T = crate::mem::uninitialized();
+ crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
tmp
}
@@ -60,7 +60,7 @@ mod ptr {
struct Block(u64, u64, u64, u64);
struct UnalignedBlock(u64, u64, u64, u64);
- let block_size = mem::size_of::<Block>();
+ let block_size = crate::mem::size_of::<Block>();
// Loop through x & y, copying them `Block` at a time
// The optimizer should unroll the loop fully for most types
@@ -69,31 +69,31 @@ mod ptr {
while i + block_size <= len {
// Create some uninitialized memory as scratch space
// Declaring `t` here avoids aligning the stack when this loop is unused
- let mut t: Block = mem::uninitialized();
+ let mut t: Block = crate::mem::uninitialized();
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
// Swap a block of bytes of x & y, using t as a temporary buffer
// This should be optimized into efficient SIMD operations where available
- intrinsics::copy_nonoverlapping(x, t, block_size);
- intrinsics::copy_nonoverlapping(y, x, block_size);
- intrinsics::copy_nonoverlapping(t, y, block_size);
+ crate::intrinsics::copy_nonoverlapping(x, t, block_size);
+ crate::intrinsics::copy_nonoverlapping(y, x, block_size);
+ crate::intrinsics::copy_nonoverlapping(t, y, block_size);
i += block_size;
}
if i < len {
// Swap any remaining bytes
- let mut t: UnalignedBlock = mem::uninitialized();
+ let mut t: UnalignedBlock = crate::mem::uninitialized();
let rem = len - i;
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
- intrinsics::copy_nonoverlapping(x, t, rem);
- intrinsics::copy_nonoverlapping(y, x, rem);
- intrinsics::copy_nonoverlapping(t, y, rem);
+ crate::intrinsics::copy_nonoverlapping(x, t, rem);
+ crate::intrinsics::copy_nonoverlapping(y, x, rem);
+ crate::intrinsics::copy_nonoverlapping(t, y, rem);
}
}
}
@@ -106,7 +106,7 @@ mod mem {
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
- ptr::swap_nonoverlapping_one(x, y);
+ crate::ptr::swap_nonoverlapping_one(x, y);
}
}
@@ -116,7 +116,7 @@ mod mem {
}
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
@@ -126,7 +126,7 @@ trait Step {
impl Step for i32 {
fn replace_zero(&mut self) -> Self {
- mem::replace(self, 0)
+ crate::mem::replace(self, 0)
}
}
diff --git a/gcc/testsuite/rust/compile/issue-2330.rs b/gcc/testsuite/rust/compile/issue-2330.rs
index 97c1503..6ab46c7 100644
--- a/gcc/testsuite/rust/compile/issue-2330.rs
+++ b/gcc/testsuite/rust/compile/issue-2330.rs
@@ -95,30 +95,30 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
swap_nonoverlapping_bytes(x, y, len)
}
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
- if mem::size_of::<T>() < 32 {
+ if crate::mem::size_of::<T>() < 32 {
let z = read(x);
- intrinsics::copy_nonoverlapping(y, x, 1);
+ crate::intrinsics::copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
@@ -126,12 +126,12 @@ mod ptr {
}
pub unsafe fn write<T>(dst: *mut T, src: T) {
- intrinsics::move_val_init(&mut *dst, src)
+ crate::intrinsics::move_val_init(&mut *dst, src)
}
pub unsafe fn read<T>(src: *const T) -> T {
- let mut tmp: T = mem::uninitialized();
- intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+ let mut tmp: T = crate::mem::uninitialized();
+ crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
tmp
}
@@ -139,7 +139,7 @@ mod ptr {
struct Block(u64, u64, u64, u64);
struct UnalignedBlock(u64, u64, u64, u64);
- let block_size = mem::size_of::<Block>();
+ let block_size = crate::mem::size_of::<Block>();
// Loop through x & y, copying them `Block` at a time
// The optimizer should unroll the loop fully for most types
@@ -148,31 +148,31 @@ mod ptr {
while i + block_size <= len {
// Create some uninitialized memory as scratch space
// Declaring `t` here avoids aligning the stack when this loop is unused
- let mut t: Block = mem::uninitialized();
+ let mut t: Block = crate::mem::uninitialized();
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
// Swap a block of bytes of x & y, using t as a temporary buffer
// This should be optimized into efficient SIMD operations where available
- intrinsics::copy_nonoverlapping(x, t, block_size);
- intrinsics::copy_nonoverlapping(y, x, block_size);
- intrinsics::copy_nonoverlapping(t, y, block_size);
+ crate::intrinsics::copy_nonoverlapping(x, t, block_size);
+ crate::intrinsics::copy_nonoverlapping(y, x, block_size);
+ crate::intrinsics::copy_nonoverlapping(t, y, block_size);
i += block_size;
}
if i < len {
// Swap any remaining bytes
- let mut t: UnalignedBlock = mem::uninitialized();
+ let mut t: UnalignedBlock = crate::mem::uninitialized();
let rem = len - i;
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
- intrinsics::copy_nonoverlapping(x, t, rem);
- intrinsics::copy_nonoverlapping(y, x, rem);
- intrinsics::copy_nonoverlapping(t, y, rem);
+ crate::intrinsics::copy_nonoverlapping(x, t, rem);
+ crate::intrinsics::copy_nonoverlapping(y, x, rem);
+ crate::intrinsics::copy_nonoverlapping(t, y, rem);
}
}
}
@@ -185,7 +185,7 @@ mod mem {
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
- ptr::swap_nonoverlapping_one(x, y);
+ crate::ptr::swap_nonoverlapping_one(x, y);
}
}
@@ -195,6 +195,6 @@ mod mem {
}
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
diff --git a/gcc/testsuite/rust/compile/issue-2905-2.rs b/gcc/testsuite/rust/compile/issue-2905-2.rs
index 83c54ed..1c9516d 100644
--- a/gcc/testsuite/rust/compile/issue-2905-2.rs
+++ b/gcc/testsuite/rust/compile/issue-2905-2.rs
@@ -17,10 +17,10 @@ pub mod core {
}
pub mod slice {
- use core::marker::PhantomData;
- use core::option::Option;
+ use crate::core::marker::PhantomData;
+ use crate::core::option::Option;
- impl<T> core::iter::IntoIterator for &[T] {
+ impl<T> crate::core::iter::IntoIterator for &[T] {
type Item = &T;
type IntoIter = Weird<T>;
@@ -108,7 +108,7 @@ pub mod core {
}
pub mod iter {
- use option::Option;
+ use crate::core::option::Option;
pub trait IntoIterator {
type Item;
diff --git a/gcc/testsuite/rust/compile/issue-3242.rs b/gcc/testsuite/rust/compile/issue-3242.rs
index 468497a..a4542aea0 100644
--- a/gcc/testsuite/rust/compile/issue-3242.rs
+++ b/gcc/testsuite/rust/compile/issue-3242.rs
@@ -1,5 +1,4 @@
#[lang = "sized"]
-// { dg-skip-if "" { *-*-* } }
pub trait Sized {}
trait Foo<T> {
diff --git a/gcc/testsuite/rust/compile/issue-3541-1.rs b/gcc/testsuite/rust/compile/issue-3541-1.rs
new file mode 100644
index 0000000..6b47b7e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3541-1.rs
@@ -0,0 +1,5 @@
+impl B for u32 {
+ const BAR: i32; // { dg-error "associated constant in .impl." }
+}
+
+trait B {}
diff --git a/gcc/testsuite/rust/compile/issue-3541-2.rs b/gcc/testsuite/rust/compile/issue-3541-2.rs
new file mode 100644
index 0000000..9f17eed
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3541-2.rs
@@ -0,0 +1,3 @@
+trait B {
+ const BAR: i32;
+}
diff --git a/gcc/testsuite/rust/compile/issue-3549.rs b/gcc/testsuite/rust/compile/issue-3549.rs
new file mode 100644
index 0000000..cedbb5a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3549.rs
@@ -0,0 +1,3 @@
+fn main() {
+ r#""#;
+}
diff --git a/gcc/testsuite/rust/compile/issue-3552.rs b/gcc/testsuite/rust/compile/issue-3552.rs
new file mode 100644
index 0000000..9a4451b14b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3552.rs
@@ -0,0 +1,14 @@
+trait Foo {
+ const BAR: u32;
+}
+
+const TRAIT_REF_BAR: u32 = <Foo>::BAR;
+// { dg-error "no default expression on trait constant" "" { target *-*-* } .-1 }
+
+struct GlobalTraitRef;
+
+impl Foo for GlobalTraitRef {
+ const BAR: u32 = TRAIT_REF_BAR;
+}
+
+fn main() {}
diff --git a/gcc/testsuite/rust/compile/issue-3553.rs b/gcc/testsuite/rust/compile/issue-3553.rs
new file mode 100644
index 0000000..546f3c1
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3553.rs
@@ -0,0 +1,18 @@
+trait Foo {
+ fn f(&self) -> isize;
+}
+
+trait Bar: Foo {
+ fn g(&self) -> isize;
+}
+
+struct A {
+ x: isize,
+}
+
+impl Bar for A {
+ // { dg-error "the trait bound .A: Foo. is not satisfied .E0277." "" { target *-*-* } .-1 }
+ fn g(&self) -> isize {
+ self.f()
+ }
+}
diff --git a/gcc/testsuite/rust/compile/issue-3554-1.rs b/gcc/testsuite/rust/compile/issue-3554-1.rs
new file mode 100644
index 0000000..a66be35
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3554-1.rs
@@ -0,0 +1,8 @@
+trait Tr {
+ fn foo();
+
+ fn bar(&self) {
+ self.foo()
+ // { dg-error "no method named .foo. found in the current scope .E0599." "" { target *-*-* } .-1 }
+ }
+}
diff --git a/gcc/testsuite/rust/compile/issue-3554-2.rs b/gcc/testsuite/rust/compile/issue-3554-2.rs
new file mode 100644
index 0000000..e455a8b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3554-2.rs
@@ -0,0 +1,18 @@
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "fn_once"]
+pub trait FnOnce<Args> {
+ #[lang = "fn_once_output"]
+ type Output;
+
+ extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+trait Tr {
+ fn foo();
+
+ fn bar(&self) {
+ (|| self.foo())()
+ // { dg-error "no method named .foo. found in the current scope .E0599." "" { target *-*-* } .-1 }
+ }
+}
diff --git a/gcc/testsuite/rust/compile/issue-3563.rs b/gcc/testsuite/rust/compile/issue-3563.rs
new file mode 100644
index 0000000..46e7624
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3563.rs
@@ -0,0 +1,17 @@
+pub struct AA {
+ pub data: [u8; 10],
+}
+
+impl AA {
+ pub const fn new() -> Self {
+ let mut res: AA = AA { data: [0; 10] };
+ res.data[0] = 5;
+ res
+ }
+}
+
+static mut BB: AA = AA::new();
+
+fn main() {
+ let _ptr = unsafe { &mut BB };
+}
diff --git a/gcc/testsuite/rust/compile/issue-3566-1.rs b/gcc/testsuite/rust/compile/issue-3566-1.rs
new file mode 100644
index 0000000..b7e5be0
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3566-1.rs
@@ -0,0 +1,8 @@
+mod a {
+ pub mod b {
+
+ pub fn f(x: [u8; { 100 }]) -> [u8; { 100 }] {
+ x
+ }
+ }
+}
diff --git a/gcc/testsuite/rust/compile/issue-3566-2.rs b/gcc/testsuite/rust/compile/issue-3566-2.rs
new file mode 100644
index 0000000..3f3ea73
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3566-2.rs
@@ -0,0 +1,22 @@
+// run-pass
+
+#![allow(H8)]
+#![allow(dead_code)]
+
+
+// pretty-expanded FIXME #23616
+
+mod a {
+ pub mod b {
+ pub type t = isize;
+
+ pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
+ //~^ WARN unused variable: `s`
+ //~| WARN unused variable: `z`
+ x
+}
+ }
+}
+
+pub fn main() { //~ ERROR cannot move out
+ }
diff --git a/gcc/testsuite/rust/compile/issue-3567.rs b/gcc/testsuite/rust/compile/issue-3567.rs
new file mode 100644
index 0000000..021d9c2
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3567.rs
@@ -0,0 +1,4 @@
+fn main() {
+ let _: &[i8] = &[i8];
+ // { dg-error "expected value .E0423." "" { target *-*-* } .-1 }
+}
diff --git a/gcc/testsuite/rust/compile/issue-3568.rs b/gcc/testsuite/rust/compile/issue-3568.rs
new file mode 100644
index 0000000..222a174
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3568.rs
@@ -0,0 +1,7 @@
+pub type T = ();
+mod foo {
+ pub use super::T;
+}
+
+pub use foo::super::foo::S as T;
+// { dg-error ".super. can only be used in start position" "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/rust/compile/issue-3588.rs b/gcc/testsuite/rust/compile/issue-3588.rs
new file mode 100644
index 0000000..744d967
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3588.rs
@@ -0,0 +1,5 @@
+const FOO: i32 = if true { [1, 2, 3] } else { [2, 3, 4] }[0];
+
+pub fn test() -> i32 {
+ FOO
+}
diff --git a/gcc/testsuite/rust/compile/issue-3605.rs b/gcc/testsuite/rust/compile/issue-3605.rs
new file mode 100644
index 0000000..05e6e48
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3605.rs
@@ -0,0 +1,5 @@
+enum Foo<'a> {}
+
+enum Bar<'a> {
+ in_band_def_explicit_impl(Foo<'a>),
+}
diff --git a/gcc/testsuite/rust/compile/issue-3606.rs b/gcc/testsuite/rust/compile/issue-3606.rs
new file mode 100644
index 0000000..73b0bd6
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3606.rs
@@ -0,0 +1,6 @@
+// { dg-options "-w" }
+#[repr()]
+pub struct Coord {
+ x: u32,
+ y: u32,
+}
diff --git a/gcc/testsuite/rust/compile/issue-3613.rs b/gcc/testsuite/rust/compile/issue-3613.rs
new file mode 100644
index 0000000..f2e1092
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3613.rs
@@ -0,0 +1,18 @@
+mod m1 {
+ pub enum Baz4 {
+ foo1,
+ foo2,
+ }
+}
+
+fn bar(x: m1::foo) {
+ // { dg-error "unknown reference for resolved name: .foo." "" { target *-*-* } .-1 }
+ match x {
+ m1::foo::foo1 => {}
+ // { dg-error "failed to type resolve root segment" "" { target *-*-* } .-1 }
+ m1::NodePosition::foo2 => {}
+ // { dg-error "failed to type resolve root segment" "" { target *-*-* } .-1 }
+ }
+}
+
+pub fn main() {}
diff --git a/gcc/testsuite/rust/compile/issue-3614.rs b/gcc/testsuite/rust/compile/issue-3614.rs
new file mode 100644
index 0000000..350a7e4
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3614.rs
@@ -0,0 +1,3 @@
+#[repr] // { dg-error "malformed .repr. attribute" }
+
+struct _B {}
diff --git a/gcc/testsuite/rust/compile/issue-3615.rs b/gcc/testsuite/rust/compile/issue-3615.rs
new file mode 100644
index 0000000..e5c5072
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-3615.rs
@@ -0,0 +1,7 @@
+pub trait Trait {
+ pub fn nrvo(init: fn()) -> [u8; 4096] {
+ let mut buf = [0; 4096];
+
+ buf
+ }
+}
diff --git a/gcc/testsuite/rust/compile/iterators1.rs b/gcc/testsuite/rust/compile/iterators1.rs
index 1141758..2ea3d74 100644
--- a/gcc/testsuite/rust/compile/iterators1.rs
+++ b/gcc/testsuite/rust/compile/iterators1.rs
@@ -98,30 +98,30 @@ mod ptr {
#[lang = "const_ptr"]
impl<T> *const T {
pub unsafe fn offset(self, count: isize) -> *const T {
- intrinsics::offset(self, count)
+ crate::intrinsics::offset(self, count)
}
}
#[lang = "mut_ptr"]
impl<T> *mut T {
pub unsafe fn offset(self, count: isize) -> *mut T {
- intrinsics::offset(self, count) as *mut T
+ crate::intrinsics::offset(self, count) as *mut T
}
}
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut u8;
let y = y as *mut u8;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
swap_nonoverlapping_bytes(x, y, len)
}
pub unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
// For types smaller than the block optimization below,
// just swap directly to avoid pessimizing codegen.
- if mem::size_of::<T>() < 32 {
+ if crate::mem::size_of::<T>() < 32 {
let z = read(x);
- intrinsics::copy_nonoverlapping(y, x, 1);
+ crate::intrinsics::copy_nonoverlapping(y, x, 1);
write(y, z);
} else {
swap_nonoverlapping(x, y, 1);
@@ -129,12 +129,12 @@ mod ptr {
}
pub unsafe fn write<T>(dst: *mut T, src: T) {
- intrinsics::move_val_init(&mut *dst, src)
+ crate::intrinsics::move_val_init(&mut *dst, src)
}
pub unsafe fn read<T>(src: *const T) -> T {
- let mut tmp: T = mem::uninitialized();
- intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
+ let mut tmp: T = crate::mem::uninitialized();
+ crate::intrinsics::copy_nonoverlapping(src, &mut tmp, 1);
tmp
}
@@ -142,7 +142,7 @@ mod ptr {
struct Block(u64, u64, u64, u64);
struct UnalignedBlock(u64, u64, u64, u64);
- let block_size = mem::size_of::<Block>();
+ let block_size = crate::mem::size_of::<Block>();
// Loop through x & y, copying them `Block` at a time
// The optimizer should unroll the loop fully for most types
@@ -151,31 +151,31 @@ mod ptr {
while i + block_size <= len {
// Create some uninitialized memory as scratch space
// Declaring `t` here avoids aligning the stack when this loop is unused
- let mut t: Block = mem::uninitialized();
+ let mut t: Block = crate::mem::uninitialized();
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
// Swap a block of bytes of x & y, using t as a temporary buffer
// This should be optimized into efficient SIMD operations where available
- intrinsics::copy_nonoverlapping(x, t, block_size);
- intrinsics::copy_nonoverlapping(y, x, block_size);
- intrinsics::copy_nonoverlapping(t, y, block_size);
+ crate::intrinsics::copy_nonoverlapping(x, t, block_size);
+ crate::intrinsics::copy_nonoverlapping(y, x, block_size);
+ crate::intrinsics::copy_nonoverlapping(t, y, block_size);
i += block_size;
}
if i < len {
// Swap any remaining bytes
- let mut t: UnalignedBlock = mem::uninitialized();
+ let mut t: UnalignedBlock = crate::mem::uninitialized();
let rem = len - i;
let t = &mut t as *mut _ as *mut u8;
let x = x.offset(i as isize);
let y = y.offset(i as isize);
- intrinsics::copy_nonoverlapping(x, t, rem);
- intrinsics::copy_nonoverlapping(y, x, rem);
- intrinsics::copy_nonoverlapping(t, y, rem);
+ crate::intrinsics::copy_nonoverlapping(x, t, rem);
+ crate::intrinsics::copy_nonoverlapping(y, x, rem);
+ crate::intrinsics::copy_nonoverlapping(t, y, rem);
}
}
}
@@ -190,7 +190,7 @@ mod mem {
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
- ptr::swap_nonoverlapping_one(x, y);
+ crate::ptr::swap_nonoverlapping_one(x, y);
}
}
@@ -200,7 +200,7 @@ mod mem {
}
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
@@ -210,30 +210,30 @@ macro_rules! impl_uint {
impl $ty {
pub fn wrapping_add(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_add(self, rhs)
+ crate::intrinsics::wrapping_add(self, rhs)
}
}
pub fn wrapping_sub(self, rhs: Self) -> Self {
unsafe {
- intrinsics::wrapping_sub(self, rhs)
+ crate::intrinsics::wrapping_sub(self, rhs)
}
}
pub fn rotate_left(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_left(self, n as Self)
+ crate::intrinsics::rotate_left(self, n as Self)
}
}
pub fn rotate_right(self, n: u32) -> Self {
unsafe {
- intrinsics::rotate_right(self, n as Self)
+ crate::intrinsics::rotate_right(self, n as Self)
}
}
- pub const fn from_ne_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
- unsafe { mem::transmute(bytes) }
+ pub const fn from_ne_bytes(bytes: [u8; crate::mem::size_of::<Self>()]) -> Self {
+ unsafe { crate::mem::transmute(bytes) }
}
pub fn checked_add(self, rhs: Self) -> Option<Self> {
@@ -246,7 +246,7 @@ macro_rules! impl_uint {
}
pub fn overflowing_add(self, rhs: Self) -> (Self, bool) {
- let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
+ let (a, b) = unsafe { crate::intrinsics::add_with_overflow(self as $ty, rhs as $ty) };
(a as Self, b)
}
}
@@ -362,12 +362,12 @@ macro_rules! step_identical_methods {
() => {
#[inline]
fn replace_one(&mut self) -> Self {
- mem::replace(self, 1)
+ crate::mem::replace(self, 1)
}
#[inline]
fn replace_zero(&mut self) -> Self {
- mem::replace(self, 0)
+ crate::mem::replace(self, 0)
}
#[inline]
@@ -482,7 +482,7 @@ impl<A: Step> Iterator for Range<A> {
// and this won't actually result in an extra check in an optimized build.
match self.start.add_usize(1) {
Option::Some(mut n) => {
- mem::swap(&mut n, &mut self.start);
+ crate::mem::swap(&mut n, &mut self.start);
Option::Some(n)
}
Option::None => Option::None,
diff --git a/gcc/testsuite/rust/compile/macros/mbe/macro43.rs b/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
index fbc36a9..0a7f038 100644
--- a/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
+++ b/gcc/testsuite/rust/compile/macros/mbe/macro43.rs
@@ -1,3 +1,10 @@
+use Option::{None, Some};
+
+enum Option<T> {
+ None,
+ Some(T)
+}
+
macro_rules! nonzero_integers {
( $( $Ty: ident($Int: ty); )+ ) => {
$(
@@ -14,7 +21,7 @@ macro_rules! nonzero_integers {
// not all derive macros are implemented yet, and this test does not test these anyways
// #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(transparent)]
- pub struct $Ty(NonZero<$Int>);
+ pub struct $Ty($Int);
impl $Ty {
/// Create a non-zero without checking the value.
@@ -25,7 +32,7 @@ macro_rules! nonzero_integers {
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub const unsafe fn new_unchecked(n: $Int) -> Self {
- $Ty(NonZero(n))
+ $Ty(n)
}
/// Create a non-zero if the given value is not zero.
@@ -33,7 +40,7 @@ macro_rules! nonzero_integers {
#[inline]
pub fn new(n: $Int) -> Option<Self> {
if n != 0 {
- Some($Ty(NonZero(n)))
+ Some($Ty(n))
} else {
None
}
@@ -43,7 +50,7 @@ macro_rules! nonzero_integers {
#[stable(feature = "nonzero", since = "1.28.0")]
#[inline]
pub fn get(self) -> $Int {
- self.0 .0
+ self.0
}
}
diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude
index fed7bde..19bf6f8 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -1,19 +1,10 @@
canonical_paths1.rs
cfg1.rs
-const_generics_3.rs
-feature_rust_attri0.rs
generics9.rs
-issue-1901.rs
-issue-1981.rs
issue-2043.rs
-issue-2330.rs
issue-2812.rs
-issue-850.rs
-issue-855.rs
issue-3315-2.rs
-iterators1.rs
lookup_err1.rs
-macros/mbe/macro43.rs
macros/mbe/macro6.rs
multiple_bindings1.rs
multiple_bindings2.rs
@@ -22,7 +13,6 @@ privacy8.rs
pub_restricted_1.rs
pub_restricted_2.rs
pub_restricted_3.rs
-sizeof-stray-infer-var-bug.rs
undeclared_label.rs
use_1.rs
while_break_expr.rs
@@ -32,15 +22,12 @@ derive_clone_enum3.rs
derive-debug1.rs
derive-default1.rs
issue-3402-1.rs
-for-loop1.rs
-for-loop2.rs
issue-3403.rs
derive-eq-invalid.rs
derive-hash1.rs
torture/alt_patterns1.rs
-torture/builtin_abort.rs
torture/loop4.rs
torture/loop8.rs
torture/name_resolve1.rs
-torture/uninit-intrinsic-1.rs
+issue-3568.rs
# please don't delete the trailing newline
diff --git a/gcc/testsuite/rust/compile/self_import_namespace.rs b/gcc/testsuite/rust/compile/self_import_namespace.rs
new file mode 100644
index 0000000..2d9b2ed
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_import_namespace.rs
@@ -0,0 +1,14 @@
+// { dg-additional-options "-frust-name-resolution-2.0" }
+
+mod bar {
+ pub mod foo {}
+ pub fn foo() {}
+}
+
+// This only imports the module `foo`. The function `foo` lives in
+// the value namespace and is not imported.
+use bar::foo::{self};
+
+fn main() {
+ foo(); // { dg-error "expected value" }
+}
diff --git a/gcc/testsuite/rust/compile/sizeof-stray-infer-var-bug.rs b/gcc/testsuite/rust/compile/sizeof-stray-infer-var-bug.rs
index 8275691..c46a97d 100644
--- a/gcc/testsuite/rust/compile/sizeof-stray-infer-var-bug.rs
+++ b/gcc/testsuite/rust/compile/sizeof-stray-infer-var-bug.rs
@@ -14,6 +14,6 @@ mod ptr {
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
let x = x as *mut T;
let y = y as *mut T;
- let len = mem::size_of::<T>() * count;
+ let len = crate::mem::size_of::<T>() * count;
}
}
diff --git a/gcc/testsuite/rust/compile/torture/builtin_abort.rs b/gcc/testsuite/rust/compile/torture/builtin_abort.rs
index 3112cdc..919caa4 100644
--- a/gcc/testsuite/rust/compile/torture/builtin_abort.rs
+++ b/gcc/testsuite/rust/compile/torture/builtin_abort.rs
@@ -12,7 +12,7 @@ mod intrinsics {
}
}
-pub fn main () -> i32 {
- abort();
+pub fn main() -> i32 {
+ crate::intrinsics::abort();
0
}
diff --git a/gcc/testsuite/rust/compile/torture/uninit-intrinsic-1.rs b/gcc/testsuite/rust/compile/torture/uninit-intrinsic-1.rs
index fa329c6..af1cb54 100644
--- a/gcc/testsuite/rust/compile/torture/uninit-intrinsic-1.rs
+++ b/gcc/testsuite/rust/compile/torture/uninit-intrinsic-1.rs
@@ -11,7 +11,7 @@ mod intrinsics {
mod mem {
pub unsafe fn uninitialized<T>() -> T {
- intrinsics::uninit()
+ crate::intrinsics::uninit()
}
}
@@ -21,6 +21,6 @@ struct Foo(i32, i32);
impl Foo {
pub fn new() -> Self {
- unsafe { mem::uninitialized::<Foo>() }
+ unsafe { crate::mem::uninitialized::<Foo>() }
}
}