diff options
author | Raiki Tamura <tamaron1203@gmail.com> | 2024-08-09 23:56:55 +0900 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:04 +0100 |
commit | 4f58a20d7e27aaa63e21dba072013b496baa94d1 (patch) | |
tree | f24aee86be0a05780d0854a59061242ecf169d55 /gcc/testsuite/rust | |
parent | b7e79e38fe97e9f41008f0a48bd41ffdd7a2895c (diff) | |
download | gcc-4f58a20d7e27aaa63e21dba072013b496baa94d1.zip gcc-4f58a20d7e27aaa63e21dba072013b496baa94d1.tar.gz gcc-4f58a20d7e27aaa63e21dba072013b496baa94d1.tar.bz2 |
gccrs: Add typecheck for path patterns.
gcc/rust/ChangeLog:
* hir/tree/rust-hir.cc (Item::item_kind_string): New function.
* hir/tree/rust-hir.h: New function.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Modify to check all arms in match expressions even if some of them
has errors.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add and fix check for path patterns.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2324-2.rs: Fix error message.
* rust/compile/match9.rs: New test.
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/issue-2324-2.rs | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/match9.rs | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/gcc/testsuite/rust/compile/issue-2324-2.rs b/gcc/testsuite/rust/compile/issue-2324-2.rs index 5ef4014..1530b00 100644 --- a/gcc/testsuite/rust/compile/issue-2324-2.rs +++ b/gcc/testsuite/rust/compile/issue-2324-2.rs @@ -6,7 +6,7 @@ enum State { fn print_on_failure(state: &State) { match *state { State::Succeeded => (), - State::Failed => (), // { dg-error "expected unit struct, unit variant or constant, found tuple variant" } + State::Failed => (), // { dg-error "expected unit struct, unit variant or constant, found struct variant" } _ => () } } diff --git a/gcc/testsuite/rust/compile/match9.rs b/gcc/testsuite/rust/compile/match9.rs new file mode 100644 index 0000000..115d458 --- /dev/null +++ b/gcc/testsuite/rust/compile/match9.rs @@ -0,0 +1,30 @@ +enum E { + A(), + B, +} + +const CONST_E: E = E::A(); + +static static_e: E = E::A(); + +type type_alias = E; + +fn f(e: E) { + match e { + E::A => {} + // { dg-error "expected unit struct, unit variant or constant, found tuple variant .E::A." "" { target *-*-* } .-1 } + E::B => {} + crate::CONST_E => {} + crate::type_alias => {} + // { dg-error "expected unit struct, unit variant or constant, found type alias .crate::type_alias." "" { target *-*-* } .-1 } + crate::E => {} + // { dg-error "expected unit struct, unit variant or constant, found enum .crate::E." "" { target *-*-* } .-1 } + crate::static_e => {} + // { dg-error "expected unit struct, unit variant or constant, found static .crate::static_e." "" { target *-*-* } .-1 } + crate::f => {} + // { dg-error "expected unit struct, unit variant or constant, found function .crate::f." "" { target *-*-* } .-1 } + _ => {} + } +} + +fn main() {} |