public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Resolve closure parameters without given type
Date: Sun,  5 Mar 2023 11:43:00 +0000 (GMT)	[thread overview]
Message-ID: <20230305114300.C8818385840A@sourceware.org> (raw)

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 &param : 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" }
 }

                 reply	other threads:[~2023-03-05 11:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230305114300.C8818385840A@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).