aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/issue-2037.rs
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2023-03-24 22:17:36 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:21:14 +0100
commita64474937c5114b3ef31bc4f5111526665b7dde1 (patch)
tree20a966088b94a2d105421913bb983b7990dbdb52 /gcc/testsuite/rust/compile/issue-2037.rs
parenta2232ff6171ab727fe994c40621831ca409987ae (diff)
downloadgcc-a64474937c5114b3ef31bc4f5111526665b7dde1.zip
gcc-a64474937c5114b3ef31bc4f5111526665b7dde1.tar.gz
gcc-a64474937c5114b3ef31bc4f5111526665b7dde1.tar.bz2
gccrs: Fix ICE on parsing trait object missing dyn keyword
Trait objects are not required to use the 'dyn' keyword though it is depreciated in later editions/version of Rustc. This patch handles the case when we query the type for an HIR::Item which happens to be an HIR::Trait and return a trait object or error. Fixes #2037 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): return a TraitObject gcc/testsuite/ChangeLog: * rust/compile/issue-2037.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/testsuite/rust/compile/issue-2037.rs')
-rw-r--r--gcc/testsuite/rust/compile/issue-2037.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-2037.rs b/gcc/testsuite/rust/compile/issue-2037.rs
new file mode 100644
index 0000000..ec27a0d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-2037.rs
@@ -0,0 +1,13 @@
+trait Foo {
+ fn bar(&mut self, other: &mut Foo);
+}
+
+struct Baz;
+
+impl Foo for Baz {
+ fn bar(&mut self, other: &Foo) {}
+ // { dg-error "expected" "" { target *-*-* } .-1 }
+ // { dg-error "method .bar. has an incompatible type for trait .Foo." "" { target *-*-* } .-2 }
+}
+
+fn main() {}