From bc2331a565d8005b91495df627f3fa72870770cc Mon Sep 17 00:00:00 2001 From: Muhammad Mahad Date: Thu, 15 Aug 2024 16:44:55 +0000 Subject: gccrs: Attempted to access a nonexistent field [E0609] gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add error code and update error message gcc/testsuite/ChangeLog: * rust/compile/nonexistent-field.rs: New test. Signed-off-by: Muhammad Mahad --- gcc/testsuite/rust/compile/nonexistent-field.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 gcc/testsuite/rust/compile/nonexistent-field.rs (limited to 'gcc/testsuite/rust/compile') diff --git a/gcc/testsuite/rust/compile/nonexistent-field.rs b/gcc/testsuite/rust/compile/nonexistent-field.rs new file mode 100644 index 0000000..e20c49d --- /dev/null +++ b/gcc/testsuite/rust/compile/nonexistent-field.rs @@ -0,0 +1,14 @@ +#![allow(unused)] +fn main() { + struct StructWithFields { + x: u32, + } + + let s = StructWithFields { x: 0 }; + s.foo; + // { dg-error "no field .foo. on type .StructWithFields.StructWithFields .x.u32... .E0609." "" { target *-*-* } .-1 } + + let numbers = (1, 2, 3); + numbers.3; + // { dg-error "no field .3. on type .., , .. .E0609." "" { target *-*-* } .-1 } +} -- cgit v1.1