I'm currently slowly but steadily converting more types into the hir equivalents and I just hit a huge bottleneck: I need to provide
html/format.rs functions, which is a disaster from a lifetime perspective. Should we maybe try to simplify it? The
display_fn call doesn't need to be called everywhere I think for example, instead I'm thinking about providing another method alongisde
fmt::Formatter parameter. What do you think?
PS: the PR I'm working on is: https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rustdoc-const-ty?expand=1
The goal was to reduce the size of the
struct Const and do some conversion on demand instead of ahead of time like now.
Regarding the lifetimes, since
TyCtxt is invariant in its lifetime param, you should be using a free distinct lifetime parameter for it, one so that
'tcx : 'a, where
'a is the lifetime for the other params (otherwise I imagine you will not be able to call the functions defined in
Then, on the
impl return type, you write
-> impl Display + 'a + Captures<'tcx> (c.f. https://doc.rust-lang.org/stable/nightly-rustc/rustc_data_structures/captures/trait.Captures.html)
(The reason for needing that is that
-> impl … desugaring is currently a bit dumb, and only introduces parameters (for the existential type) for each parameter used in that
impl … (instead of defining an existential type parameter for each parameter in scope).
That is, instead of doing:
// generic parameters that were in scope when you wrote `-> impl …` // vv vvvv type ImplDisplay<'a, 'tcx> = impl Display + 'a;
so that the
'tcx-invariantly-infected closure can match this definition,
currently, if you don't write that
Captures<'tcx> hack, it does:
type ImplDisplay<'a> = impl Display + 'a;
It's worth a try, thanks for the suggestion!
Last updated: Oct 11 2021 at 22:34 UTC