Try โ€‚โ€‰HackMD

GSoC syncup: Rewrite Rust lints to operate on frontend's HIR

Rolling agenda.

Proposal

2025-07-07

Progress

  • Implementing ReadonlyChecker on HIR

Questions

  • I don't have any question to ask.

2025-06-30

Progress

  • Implementing ReadonlyChecker on HIR

Strategy

  • Find AssignmentExpr
  • Get left operand of it (that is assignee expression)
  • Check if it is mutable or not

Example Code

void
ReadonlyChecker::visit (AssignmentExpr &expr)
{
  Expr &lhs = expr.get_lhs ();
  switch (lhs.get_expression_type ())
    {
    case Expr::ExprType::Path:
      {
	// QualifiedPathInExpression or PathInExpression
	// readonly check for local variables and static variables
    
        std::unique_ptr<Path> path = static_cast<Path>(*lhs);
    
        switch (path.get_path_type()) {
            case Path::PathType::QualifiedPathInExpression: {}
            case Path::PathType::PathInExpression: {}
        }
    
    
      }
    case Expr::ExprType::FieldAccess:
      {
	// readonly check for field access
      }

    case Expr::ExprType::ArrayIndex:
      {
	// readonly check for array index access
      }
    case Expr::ExprType::Operator:
      {
	// readonly check for dereferences
      }
    case Expr::ExprType::Tuple:
      {
	// readonly check for tuples of expressions
      }
    default:
      rust_error_at (expr.get_locus (),
		     "cannot assign to expression of type %s",
		     lhs.get_expression_type ());
    }
}

Question

  • Both QualifiedPathInExpression and PathInExpression has Expr::ExprType::Path. How can we distinguish between these two types of nodes?

2025-06-23

Progress

Questions

2025-06-16

Progress

Questions

  • Should I visit inner or outer attributes?
    • attributes are belongs to AST, so I don't think this should be visited
  • Should I visit StructBase nodes?
    • this type of node doesn't have accept_vis function, but Default AST vistor visits StructBase nodes.

2025-06-09

Progress

Questions

These template functions can also be quite helpful for you:

  template <typename T> void visit (T &node) { node.accept_vis (*this); }

  template <typename T> void visit (std::unique_ptr<T> &node)
  {
    node->accept_vis (*this);
  }

Actions:

  • Ryutaro to continue DefaultHIRVisitor implementation for next week

2025-06-01

  • Introduction

Actions:

  • Ryutaro to write down questions if you have any :D
  • Arthur to setup a groupchat for PE and Ryutaro