After some discussion with @cramertj, I wanted to write up a rough idea for how to represent impl Trait
in the HIR etc. The key idea is to move towards a place where we represent the abstract type
that an impl Trait
conceptually desugars to as a distinct "item" in the HIR.
Today, for each usage of impl Trait
, we create a def-id, which basically represents the abstract type
behind the impl Trait
. However, in the HIR itself, we continue to mirror the syntax, so for example the variant for ImplTrait
includes the bounds listed inline. This is not I think what we really want.
The refactoring then is to do the following:
hir::Crate
a "abstract type" vector sort of like the list of bodies.hir::AbstractType
struct that contains the following:
ImplTrait
variant of hir::Ty
with to include a "list of substs" in some form (and not have bounds)impl trait
, we create and push a hir::AbstractType
:
ast::Ty
into the hir::AbstractType
hir::ImplTrait(DefId, [T, 'a])
where the "substs" are references to all the lifetimse/types in scope (I'm not entirely sure how best to represent and synthesize those?)RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4