https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106072

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The code definitely has a check for nullptr on pattern:
```
  // parse pattern (which is required)
  std::unique_ptr<AST::Pattern> pattern = parse_pattern ();
  if (pattern == nullptr)
    {
      // not necessarily an error
      return AST::ClosureParam::create_error ();
    }

  // parse optional type of param
  std::unique_ptr<AST::Type> type = nullptr;
  if (lexer.peek_token ()->get_id () == COLON)
    {
      lexer.skip_token ();

      // parse type, which is now required
      type = parse_type ();
      if (type == nullptr)
        {
          Error error (lexer.peek_token ()->get_locus (),
                       "failed to parse type in closure parameter");
          add_error (std::move (error));

          // skip somewhere?
          return AST::ClosureParam::create_error ();
        }
    }

  return AST::ClosureParam (std::move (pattern), pattern->get_locus (),
                            std::move (type), std::move (outer_attrs));
```
Easy workaround is to add right before AST::CLosureParam:
rust_assert (pattern);

That should enforce the compiler to figure out that the load from pattern
unique_ptr is non-null.

Reply via email to