diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2024-08-15 16:44:55 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:03 +0100 |
commit | bc2331a565d8005b91495df627f3fa72870770cc (patch) | |
tree | b30f7f4098018db011dab9457f7c0a25c68056b7 /gcc/testsuite/rust/compile | |
parent | 5c2ecc630d95077e533d6cac6bf6c4e0f16ba623 (diff) | |
download | gcc-bc2331a565d8005b91495df627f3fa72870770cc.zip gcc-bc2331a565d8005b91495df627f3fa72870770cc.tar.gz gcc-bc2331a565d8005b91495df627f3fa72870770cc.tar.bz2 |
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 <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust/compile')
-rw-r--r-- | gcc/testsuite/rust/compile/nonexistent-field.rs | 14 |
1 files changed, 14 insertions, 0 deletions
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 ..<integer>, <integer>, <integer>.. .E0609." "" { target *-*-* } .-1 } +} |