]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: 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)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:12 +0000 (15:32 +0100)
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 89e7e39f5bb851a82cdabdb76fa67e3da281c6d4..b2cdc5f52d2a37bcb36d4967487b28166a0f002a 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