aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-07-30 18:59:06 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:56:04 +0100
commit432cdee6a6e28c52dae6b69079db301b9681485b (patch)
treef0a901ea95676be8e50c051af2df558d3adaeeae /gcc/testsuite/rust/compile
parentf7b2e17682b5139a08f7956226bf7ccbdec88230 (diff)
downloadgcc-432cdee6a6e28c52dae6b69079db301b9681485b.zip
gcc-432cdee6a6e28c52dae6b69079db301b9681485b.tar.gz
gcc-432cdee6a6e28c52dae6b69079db301b9681485b.tar.bz2
gccrs: Fix ICE by adding check for enum candidate's in TypePath resolution
Fixes #2479 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): always resolve the type even when its an a mandatory trait item * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Add check for enum candidates otherwise you get undefined behaviour gcc/testsuite/ChangeLog: * rust/compile/issue-2479.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust/compile')
-rw-r--r--gcc/testsuite/rust/compile/issue-2479.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-2479.rs b/gcc/testsuite/rust/compile/issue-2479.rs
new file mode 100644
index 0000000..4a0d354
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2479.rs
@@ -0,0 +1,22 @@
+#![allow(unused)]
+fn main() {
+enum Dragon {
+ Born,
+}
+
+fn oblivion() -> Dragon::Born {
+// { dg-error "expected type, found variant of Dragon" "" { target *-*-* } .-1 }
+// { dg-error "failed to resolve return type" "" { target *-*-* } .-2 }
+ Dragon::Born
+}
+
+enum Wizard {
+ Gandalf,
+ Saruman,
+}
+
+trait Isengard {
+ fn wizard(_: Wizard::Saruman);
+ // { dg-error "expected type, found variant of Wizard" "" { target *-*-* } .-1 }
+}
+}