Rewrite recommended demangling for lifetimes using "De Bruijn level".

This commit is contained in:
Eric Huss 2022-06-10 11:28:30 -07:00
parent 9e0c19d5c2
commit 0e66b0024c

View file

@ -545,14 +545,14 @@ Indices starting from 1 refer (as de Bruijn indices) to a higher-ranked lifetime
> **Recommended Demangling**
>
> A *lifetime* may be displayed like a Rust lifetime using a single quote.
>
> Index 0 should be displayed as `'_`.
>
> Lifetimes starting from 1 may be translated to single lowercase letters starting with `'a`.
> Indices over 25 may consider printing the numeric lifetime index as in `'_123`.
>
> Index 0 should not be displayed for lifetimes in a *[ref-type]*, *[mut-ref-type]*, or *[dyn-trait-type]*.
>
> Nested binders may consider tracking their indices so that lifetime lettering can start back with `'a` within a nested binder.
> A lifetime can be displayed by converting the De Bruijn index to a De Bruijn level
> (level = number of bound lifetimes - index) and selecting a unique name for each level.
> For example, starting with single lowercase letters such as `'a` for level 0.
> Levels over 25 may consider printing the numeric lifetime as in `'_123`.
> See *[binder]* for more on lifetime indexes and ordering.
> Example: