# Modifying AST, creating new DefIds

**URL:** <https://internals.rust-lang.org/t/modifying-ast-creating-new-defids/20023>\
**Category:** compiler\
**Created:** [December 13, 2023, 2:00pm UTC](https://internals.rust-lang.org/t/modifying-ast-creating-new-defids/20023 "2023-12-13T14:00:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayondomartin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kayondomartin/32/8408_2.png) [@kayondomartin](https://internals.rust-lang.org/u/kayondomartin)\
**Post date:** [December 13, 2023, 2:00pm UTC](https://internals.rust-lang.org/t/modifying-ast-creating-new-defids/20023/1 "2023-12-13T14:00:31Z")

</div>

Hi all, I am working on a project that requires me to wrap some function calls. I tried writing an MIR pass, but was caught by the fact that I am wrapping my function calls with a closure and closures need DefIds. So I decided to modify AST, but I might be doing it wrong. My new closures mess up the crate and it can't be typechecked. I have opened an issue here [Modifying AST · Issue #1837 · rust-lang/rustc-dev-guide · GitHub](https://github.com/rust-lang/rustc-dev-guide/issues/1837) for help, but I figured there are possibly more active compiler devs here. Any help would be very much appreciated.

Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 12, 2024, 2:00pm UTC](https://internals.rust-lang.org/t/modifying-ast-creating-new-defids/20023/2 "2024-03-12T14:00:54Z")

</div>

Closed on March 12, 2024, 2:00pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
