]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
nr2.0: default-visitor: Conditionally visit type in self parameters.
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 27 Mar 2024 16:20:15 +0000 (17:20 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Thu, 26 Sep 2024 22:48:32 +0000 (22:48 +0000)
This could trigger an assertions as `get_type` on `SelfParam` asserts that
the self param does have a given type, which is not always the case.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Do not
visit self's type if it does not have one.

gcc/rust/resolve/rust-default-resolver.cc

index 1a9d377aa1eae27e00dc4d713ca2d4c5b6c204cd..5183f89be11e4e1d3d694390099b5c022dea7fbc 100644 (file)
@@ -68,7 +68,10 @@ DefaultResolver::visit (AST::Function &function)
        else if (p->is_self ())
          {
            auto &param = static_cast<AST::SelfParam &> (*p);
-           param.get_type ().accept_vis (*this);
+
+           if (param.has_type ())
+             param.get_type ().accept_vis (*this);
+
            param.get_lifetime ().accept_vis (*this);
          }
        else