diff --git a/gcc/testsuite/rust/compile/not_raw_ref_op.rs b/gcc/testsuite/rust/compile/not_raw_ref_op.rs new file mode 100644 index 000000000000..f55f1846faba --- /dev/null +++ b/gcc/testsuite/rust/compile/not_raw_ref_op.rs @@ -0,0 +1,9 @@ +// { dg-options "-frust-compile-until=lowering" } +pub struct Toto { + u: usize, +} + +pub fn test(raw: Toto) { + // Not raw ref op syntax, raw keyword is weak. + let _c = &raw; +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op.rs b/gcc/testsuite/rust/compile/raw_ref_op.rs new file mode 100644 index 000000000000..a97e58c62b0f --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op.rs @@ -0,0 +1,11 @@ +// { dg-options "-fsyntax-only" } +#![feature(raw_ref_op)] + +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _a = &raw mut toto.u; + let _b = &raw const toto.u; +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs new file mode 100644 index 000000000000..256202b2da6a --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op_feature_gate.rs @@ -0,0 +1,8 @@ +// { dg-options "-frust-compile-until=lowering" } +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _a = &raw mut toto.u; //{ dg-error "raw address of syntax is experimental." "" { target *-*-* } } +} diff --git a/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs new file mode 100644 index 000000000000..90e169f30f6b --- /dev/null +++ b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs @@ -0,0 +1,12 @@ +// { dg-options "-fsyntax-only" } +#![feature(raw_ref_op)] + +pub struct Toto { + u: usize, +} + +pub fn test(mut toto: Toto) { + let _c = &raw toto.u; //{ dg-error "expecting .;. but .identifier. found" "" { target *-*-* } } + //{ dg-excess-errors "Additional errors for parent items" { target *-*-* } } + +}