Skip to content

Conversation

@thedataking
Copy link
Contributor

Support multiple transforms such that we can support different post-processing steps such as:

  • comment transfer
  • assert folding
  • relooper cleanup
  • reformatting of large tables, etc.

Some transforms might also be broken down into a sequence of simpler transforms. A concrete use case is lua which contains license headers and other matter before function definitions which we do not want to pass so the comment transfer transform.

(Replaces PR #1512 as it was automatically closed when I renamed the branch)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the c2rust postprocessing system to support multiple transforms in sequence. The main goal is to enable different post-processing steps (like comment transfer, assert folding, relooper cleanup, etc.) to be applied independently and in configurable order.

Changes:

  • Introduced an abstract base class AbstractTransform to standardize transform implementations
  • Renamed CommentTransfer to CommentsTransform and moved it to a new module structure
  • Added factory function get_transform_by_id to instantiate transforms by name
  • Updated CLI to accept comma-separated list of transforms via --transforms parameter

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
c2rust-postprocess/postprocess/transforms/base.py New abstract base class defining transform interface with apply() and apply_dir() methods
c2rust-postprocess/postprocess/transforms/comments.py Refactored comments transform with renamed classes, added validation, and AbstractTransform inheritance
c2rust-postprocess/postprocess/transforms/init.py New factory function to instantiate transforms by ID
c2rust-postprocess/postprocess/comments/init.py Duplicate/incomplete implementation with critical bugs that appears to be leftover from refactoring
c2rust-postprocess/postprocess/init.py Updated main entry point to support multiple transforms and use factory pattern
c2rust-postprocess/tests/llm-cache/CommentsTransform/*/metadata.toml Updated cache metadata to reflect "CommentsTransform" naming
c2rust-postprocess/tests/llm-cache/CommentsTransform/*/response.txt New cached test responses for quickSort and partition functions
Comments suppressed due to low confidence (3)

c2rust-postprocess/postprocess/transforms/comments.py:69

  • The docstring parameter documentation is missing the colon prefix for reST/Sphinx format. It should be :param rust_fn: and :return: instead of param: and return:.
    c2rust-postprocess/postprocess/transforms/comments.py:242
  • The transfer_comments_dir method calls self.apply with a rust_source_file parameter, but the apply method signature only accepts root_rust_source_file. This mismatch will cause a TypeError at runtime. Either the apply method needs to be updated to accept rust_source_file, or this call needs to be updated to match the apply signature.
    c2rust-postprocess/postprocess/transforms/comments.py:242
  • Keyword argument 'rust_source_file' is not a supported parameter name of method CommentsTransform.apply.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms branch from 828f00c to 79adc8c Compare January 10, 2026 03:35
@immunant immunant deleted a comment from Copilot AI Jan 10, 2026
@immunant immunant deleted a comment from Copilot AI Jan 10, 2026
@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms branch 3 times, most recently from 3c35f8a to ade83ec Compare January 10, 2026 04:05
A later change adds an abstract base class using the `Transform` suffix
so it is more consistent with naming elsewhere in this project to call
the inaugural transform `CommentsTransform`. Updated cache dir
correspondingly.
@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms branch from ade83ec to d21f1eb Compare January 25, 2026 12:13
@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms branch from d21f1eb to 111e4d5 Compare February 1, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants