Skip to content

Commit 346368b

Browse files
authored
Merge pull request #3130 from tmiasko/mangling
Update mangling scheme syntax
2 parents 98374c4 + e57408e commit 346368b

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

text/2603-rust-symbol-name-mangling-v0.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ Mangled names conform to the following grammar:
625625
// The <decimal-number> specifies the encoding version.
626626
<symbol-name> = "_R" [<decimal-number>] <path> [<instantiating-crate>]
627627
628-
<path> = "C" <identifier> // crate root
629-
| "M" <impl-path> <type> // <T> (inherent impl)
630-
| "X" <impl-path> <type> <path> // <T as Trait> (trait impl)
631-
| "Y" <type> <path> // <T as Trait> (trait definition)
632-
| "N" <ns> <path> <identifier> // ...::ident (nested path)
633-
| "I" <path> {<generic-arg>} "E" // ...<T, U> (generic args)
628+
<path> = "C" <identifier> // crate root
629+
| "M" <impl-path> <type> // <T> (inherent impl)
630+
| "X" <impl-path> <type> <path> // <T as Trait> (trait impl)
631+
| "Y" <type> <path> // <T as Trait> (trait definition)
632+
| "N" <namespace> <path> <identifier> // ...::ident (nested path)
633+
| "I" <path> {<generic-arg>} "E" // ...<T, U> (generic args)
634634
| <backref>
635635
636636
// Path to an impl (without the Self type or the trait).
@@ -655,10 +655,10 @@ Mangled names conform to the following grammar:
655655
// A-Z are used for special namespaces (e.g. closures), which the demangler
656656
// can show in a special way (e.g. `NC...` as `...::{closure}`), or just
657657
// default to showing the uppercase character.
658-
<ns> = "C" // closure
659-
| "S" // shim
660-
| <A-Z> // other special namespaces
661-
| <a-z> // internal namespaces
658+
<namespace> = "C" // closure
659+
| "S" // shim
660+
| <A-Z> // other special namespaces
661+
| <a-z> // internal namespaces
662662
663663
<generic-arg> = <lifetime>
664664
| <type>
@@ -675,6 +675,7 @@ Mangled names conform to the following grammar:
675675
// innermost lifetimes, e.g. in `for<'a, 'b> fn(for<'c> fn(...))`,
676676
// any <lifetime>s in ... (but not inside more binders) will observe
677677
// the indices 1, 2, and 3 refer to 'c, 'b, and 'a, respectively.
678+
// The number of bound lifetimes is value of <base-62-number> + 1.
678679
<binder> = "G" <base-62-number>
679680
680681
<type> = <basic-type>
@@ -715,22 +716,24 @@ Mangled names conform to the following grammar:
715716
// If the "U" is present then the function is `unsafe`.
716717
// The return type is always present, but demanglers can
717718
// choose to omit the ` -> ()` by special-casing "u".
718-
<fn-sig> := <binder> ["U"] ["K" <abi>] {<type>} "E" <type>
719+
<fn-sig> = [<binder>] ["U"] ["K" <abi>] {<type>} "E" <type>
719720
720721
<abi> = "C"
721722
| <undisambiguated-identifier>
722723
723-
<dyn-bounds> = <binder> {<dyn-trait>} "E"
724+
<dyn-bounds> = [<binder>] {<dyn-trait>} "E"
724725
<dyn-trait> = <path> {<dyn-trait-assoc-binding>}
725726
<dyn-trait-assoc-binding> = "p" <undisambiguated-identifier> <type>
726727
<const> = <type> <const-data>
727-
| <type> "p" // placeholder (e.g. for polymorphic constants), shown as _: T
728+
| "p" // placeholder, shown as _
728729
| <backref>
729730
730-
// The encoding of a constant depends on its type, currently only
731-
// unsigned integers (mainly usize, for arrays) are supported, and they
732-
// use their value, in base 16 (0-9a-f), not their memory representation.
733-
<const-data> = {<hex-digit>} "_"
731+
// The encoding of a constant depends on its type. Integers use their value,
732+
// in base 16 (0-9a-f), not their memory representation. Negative integer
733+
// values are preceded with "n". The bool value false is encoded as `0_`, true
734+
// value as `1_`. The char constants are encoded using their Unicode scalar
735+
// value.
736+
<const-data> = ["n"] {<hex-digit>} "_"
734737
735738
// <base-62-number> uses 0-9-a-z-A-Z as digits, i.e. 'a' is decimal 10 and
736739
// 'Z' is decimal 61.
@@ -748,7 +751,7 @@ Mangled names conform to the following grammar:
748751
### Namespace Tags
749752

750753
Namespaces are identified by an implementation defined single character tag
751-
(the `<ns>` production). Only closures (`C`) and shims (`S`) have a
754+
(the `<namespace>` production). Only closures (`C`) and shims (`S`) have a
752755
specific character assigned to them so that demanglers can reliable
753756
adjust their output accordingly. Other namespace tags have to be omitted
754757
or shown verbatim during demangling.
@@ -1150,3 +1153,6 @@ pub static QUUX: u32 = {
11501153
- Add a recommended resolution for open question around Punycode identifiers.
11511154
- Add a recommended resolution for open question around encoding function parameter types.
11521155
- Allow identifiers to start with a digit.
1156+
- Make `<binder>` optional in `<fn-sig>` and `<dyn-bounds>` productions.
1157+
- Extend `<const-data>` to include `bool` values, `char` values, and negative integer values.
1158+
- Remove type from constant placeholders.

0 commit comments

Comments
 (0)