Latest Results
Use `DeclEngine::insert_modified` instead of `with_parent` (#7744)
## Description
This PR removes `with_parent` method from the `DeclEngine`. It is an
another prerequisite for removals of duplicates from `DeclEngine` and
for elimination of expensive hashing.
Semantically valid registering of parents is now enforced implicitly
inside of the `insert_modified` method.
The previous API based on `with_parent` suffered from two conceptual
issues:
- The API was allowed for `TraitFn`, `Function`, `Constant`, and `Type`,
but needed only for linking dummy functions to their trait/ABI interface
declarations and for linking monomorphized functions to their original
declarations. In other words, the parent links were never consumed for
`Constant`s and associated `Type`s. Still, they were _sometimes_ added
to declarations, only bloating the `DeclEngine`.
- As mentioned in the above point, _sometimes_ added leads to the second
API issue, the fact that `with_parent` was a separate call that could
easily either be forgotten or called on a declaration for which it was
irrelevant.
The only two cases where we actually need parent links are:
- every dummy function must be linked to its `TraitFn`,
- every modified copy of a `TyFunctionDecl/TyTraitFn` must be linked to
its original.
The other two associated items, constants and associated types are
redirected by entirely different mechanisms:
- A `ConstantExpression` embeds the whole `TyConstantDecl` inline (not a
DeclId reference). Redirection to the impl's constant happens in
`UpdateConstantExpression` via `find_const_decl_from_impl`, which does a
name-based lookup in the implementing impl block's items and overwrites
the embedded decl in place.
- Associated types references live as `TypeInfo::TraitType` in the
`TypeEngine` and are substituted through `TypeSubstMap::find_match`.
The new API enforces the preservation of only the two parent links
listed above by design.
Consequently, the `AssociatedItemDeclId` is renamed to
`FunctionalDeclId`, to match the similar `InterfaceDeclId` grouping of
`Abi` and `Trait` declarations.
## Checklist
- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers. Latest Branches
0%
0%
ironcev/decl-engine-remove-with-parent 0%
xunilrj/improve-constant-propagate © 2026 CodSpeed Technology