public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Resolve closure parameters without given type
@ 2023-03-05 11:43 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-05 11:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ae91a0a3f2b44e5b011d3742a71c3c5030558bc8
commit ae91a0a3f2b44e5b011d3742a71c3c5030558bc8
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date: Fri Mar 3 20:05:59 2023 -0500
Resolve closure parameters without given type
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit):
Check for closure parameter without given type.
gcc/testsuite/ChangeLog:
* rust/compile/closure_no_type_anno.rs: Extend test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diff:
---
gcc/rust/resolve/rust-early-name-resolver.cc | 3 ++-
gcc/testsuite/rust/compile/closure_no_type_anno.rs | 9 +++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc
index 10f7626dc7f..69852280630 100644
--- a/gcc/rust/resolve/rust-early-name-resolver.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver.cc
@@ -326,7 +326,8 @@ EarlyNameResolver::visit (AST::ClosureExprInner &expr)
expr.get_definition_expr ()->accept_vis (*this);
for (auto ¶m : expr.get_params ())
- param.get_type ()->accept_vis (*this);
+ if (param.has_type_given ())
+ param.get_type ()->accept_vis (*this);
}
void
diff --git a/gcc/testsuite/rust/compile/closure_no_type_anno.rs b/gcc/testsuite/rust/compile/closure_no_type_anno.rs
index beade7607f0..ff2c8b88a8a 100644
--- a/gcc/testsuite/rust/compile/closure_no_type_anno.rs
+++ b/gcc/testsuite/rust/compile/closure_no_type_anno.rs
@@ -1,5 +1,10 @@
-// { dg-additional-options "-fsyntax-only" }
+#[lang = "fn_once"]
+trait FnOnce<Args> {
+ type Output;
+
+ fn call_once(self, args: Args) -> Self::Output;
+}
pub fn foo() {
- let a = |_| 15;
+ let a = |_| 15; // { dg-error "type annotations needed" }
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-05 11:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-05 11:43 [gcc/devel/rust/master] Resolve closure parameters without given type Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).