From c8a36979e6410058ec359ce6abf68077b3237116 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 29 Apr 2024 12:09:19 +0200 Subject: [PATCH] Recommend to never display zero disambiguators when demangling v0 symbol names --- src/doc/rustc/src/symbol-mangling/v0.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustc/src/symbol-mangling/v0.md b/src/doc/rustc/src/symbol-mangling/v0.md index 61f747fac837c..e6709eb9a1a47 100644 --- a/src/doc/rustc/src/symbol-mangling/v0.md +++ b/src/doc/rustc/src/symbol-mangling/v0.md @@ -150,6 +150,15 @@ the *[disambiguator]* is used to make the name unique across the crate graph. > ``` > > Recommended demangling: `mycrate::example` +> +> Note: The compiler may re-use the *crate-root* form to express arbitrary +> unscoped, undisambiguated identifiers, such as for new basic types that have +> not been added to the grammar yet. To achieve that, it will emit a *crate-root* +> without an explicit disambiguator, relying on the fact that such an +> undisambiguated crate name cannot occur in practice. For example, the basic +> type `f128` would be encode as `C4f128`. For this to have the desired effect, +> demanglers are expected to never render zero disambiguators of crate roots. +> I.e. `C4f128` is expected to be displayed as `f128` and not `f128[0]`. ### Path: Inherent impl [inherent-impl]: #path-inherent-impl @@ -539,6 +548,10 @@ This allows disambiguators that are encoded sequentially to use minimal bytes. > **Recommended Demangling** > > The *disambiguator* may or may not be displayed; see recommendations for rules that use *disambiguator*. +> Generally, it is recommended that zero disambiguators are never displayed unless their accompanying +> identifier is empty (like is the case for unnamed items such as closures). +> When rendering a disambiguator, it can be shortened to a length reasonable for the context, +> similar to how git commit hashes are rarely displayed in full. ## Lifetime [lifetime]: #lifetime