Skip to content

feat: Add missing SyntaxFactory constructors to unblock assist migrations #21762

@akashchakrabortymsc-cmd

Description

@akashchakrabortymsc-cmd

While working on the assist migration tracking issue #18285, I attempted
to migrate move_bounds.rs and remove_unused_imports.rs to use the
SyntaxEditor API. Both migrations are currently blocked because
SyntaxFactory is missing several constructors and methods that are
still only available in the old edit_in_place / make API.

Missing Methods

move_bounds.rs blocker

  • where_pred() — constructs a WherePred node from a target
    (Either<Lifetime, Type>) and an iterator of TypeBound
  • get_or_create_where_clause() — finds or inserts a WhereClause
    on AST nodes like Fn, Trait, Impl, Enum, Struct, TypeAlias

remove_unused_imports.rs blocker

  • UseTree::remove_recursive() — removes a UseTree node and cleans
    up parent braces, trailing commas, and empty use statements

split_import.rs blocker

  • UseTree::split_prefix() — splits a use path at a given prefix
    into a braced subtree

Proposed Fix

Implement these in:

crates/syntax/src/ast/syntax_factory/constructors.rs

and the relevant SyntaxEditor extension traits.

Before proceeding — is this the right approach, or are these
intentionally deferred? Happy to take this on if it looks good.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions