aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-25 11:03:44 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:55:43 +0100
commitc0640954e1a340764368a10f3b7774696e32a8ae (patch)
tree381ce7ebf2db113cbadf9c5854abb3ab8c71c91a /gcc/testsuite/rust/compile
parentf30ba73582e4c53d4936e9c091d60b187a276373 (diff)
downloadgcc-c0640954e1a340764368a10f3b7774696e32a8ae.zip
gcc-c0640954e1a340764368a10f3b7774696e32a8ae.tar.gz
gcc-c0640954e1a340764368a10f3b7774696e32a8ae.tar.bz2
gccrs: resolve: Name resolve trait bounds properly
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): Resolve additional trait bounds. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Error out properly on unresolved type-path instead of crashing. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Exclude additional-trait-bounds2 for different error message. * rust/compile/additional-trait-bounds1.rs: New test. * rust/compile/additional-trait-bounds2.rs: New test. * rust/compile/additional-trait-bounds2nr2.rs: New test.
Diffstat (limited to 'gcc/testsuite/rust/compile')
-rw-r--r--gcc/testsuite/rust/compile/additional-trait-bounds1.rs10
-rw-r--r--gcc/testsuite/rust/compile/additional-trait-bounds2.rs9
-rw-r--r--gcc/testsuite/rust/compile/additional-trait-bounds2nr2.rs11
-rw-r--r--gcc/testsuite/rust/compile/nr2/exclude1
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/additional-trait-bounds1.rs b/gcc/testsuite/rust/compile/additional-trait-bounds1.rs
new file mode 100644
index 0000000..449a72f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/additional-trait-bounds1.rs
@@ -0,0 +1,10 @@
+#![feature(optin_builtin_traits)]
+
+pub unsafe auto trait Send {}
+#[lang = "sync"]
+pub unsafe auto trait Sync {}
+
+trait A {}
+
+impl dyn A + Send {}
+impl dyn A + Send + Sync {}
diff --git a/gcc/testsuite/rust/compile/additional-trait-bounds2.rs b/gcc/testsuite/rust/compile/additional-trait-bounds2.rs
new file mode 100644
index 0000000..843228a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/additional-trait-bounds2.rs
@@ -0,0 +1,9 @@
+#![feature(optin_builtin_traits)]
+
+pub unsafe auto trait Send {}
+#[lang = "sync"]
+pub unsafe auto trait Sync {}
+
+trait A {}
+
+impl dyn A + Send + Sync + NonExist {} // { dg-error "failed to resolve TypePath: NonExist in this scope" }
diff --git a/gcc/testsuite/rust/compile/additional-trait-bounds2nr2.rs b/gcc/testsuite/rust/compile/additional-trait-bounds2nr2.rs
new file mode 100644
index 0000000..6764f6e
--- /dev/null
+++ b/gcc/testsuite/rust/compile/additional-trait-bounds2nr2.rs
@@ -0,0 +1,11 @@
+// { dg-additional-options "-frust-name-resolution-2.0" }
+
+#![feature(optin_builtin_traits)]
+
+pub unsafe auto trait Send {}
+#[lang = "sync"]
+pub unsafe auto trait Sync {}
+
+trait A {}
+
+impl dyn A + Send + Sync + NonExist {} // { dg-error "could not resolve type path .NonExist." }
diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude
index 797e59a..8bdcc8a 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -208,4 +208,5 @@ issue-2905-2.rs
issue-2907.rs
issue-2423.rs
issue-266.rs
+additional-trait-bounds2.rs
# please don't delete the trailing newline