// rustToString demangles a Rust symbol. func rustToString(name string, options []Option) (ret string, err error) { … } type rustState … // fail panics with demangleErr, to be caught in rustToString. func (rst *rustState) fail(err string) { … } // advance advances the current string offset. func (rst *rustState) advance(add int) { … } // checkChar requires that the next character in the string be c, // and advances past it. func (rst *rustState) checkChar(c byte) { … } // writeByte writes a byte to the buffer. func (rst *rustState) writeByte(c byte) { … } // writeString writes a string to the buffer. func (rst *rustState) writeString(s string) { … } // symbolName parses: // // <symbol-name> = "_R" [<decimal-number>] <path> [<instantiating-crate>] // <instantiating-crate> = <path> // // We've already skipped the "_R". func (rst *rustState) symbolName() { … } // path parses: // // <path> = "C" <identifier> // crate root // | "M" <impl-path> <type> // <T> (inherent impl) // | "X" <impl-path> <type> <path> // <T as Trait> (trait impl) // | "Y" <type> <path> // <T as Trait> (trait definition) // | "N" <namespace> <path> <identifier> // ...::ident (nested path) // | "I" <path> {<generic-arg>} "E" // ...<T, U> (generic args) // | <backref> // <namespace> = "C" // closure // | "S" // shim // | <A-Z> // other special namespaces // | <a-z> // internal namespaces // // needsSeparator is true if we need to write out :: for a generic; // it is passed as false if we are in the middle of a type. func (rst *rustState) path(needsSeparator bool) { … } // implPath parses: // // <impl-path> = [<disambiguator>] <path> func (rst *rustState) implPath() { … } // identifier parses: // // <identifier> = [<disambiguator>] <undisambiguated-identifier> // // It returns the disambiguator and the identifier. func (rst *rustState) identifier() (int64, string) { … } // disambiguator parses an optional: // // <disambiguator> = "s" <base-62-number> func (rst *rustState) disambiguator() int64 { … } // undisambiguatedIdentifier parses: // // <undisambiguated-identifier> = ["u"] <decimal-number> ["_"] <bytes> func (rst *rustState) undisambiguatedIdentifier() (id string, isPunycode bool) { … } // expandPunycode decodes the Rust version of punycode. // This algorithm is taken from RFC 3492 section 6.2. func (rst *rustState) expandPunycode(s string) string { … } // genericArgs prints a list of generic arguments, without angle brackets. func (rst *rustState) genericArgs() { … } // genericArg parses: // // <generic-arg> = <lifetime> // | <type> // | "K" <const> // forward-compat for const generics // <lifetime> = "L" <base-62-number> func (rst *rustState) genericArg() { … } // binder parses an optional: // // <binder> = "G" <base-62-number> func (rst *rustState) binder() { … } // demangleType parses: // // <type> = <basic-type> // | <path> // named type // | "A" <type> <const> // [T; N] // | "S" <type> // [T] // | "T" {<type>} "E" // (T1, T2, T3, ...) // | "R" [<lifetime>] <type> // &T // | "Q" [<lifetime>] <type> // &mut T // | "P" <type> // *const T // | "O" <type> // *mut T // | "F" <fn-sig> // fn(...) -> ... // | "D" <dyn-bounds> <lifetime> // dyn Trait<Assoc = X> + Send + 'a // | <backref> func (rst *rustState) demangleType() { … } var rustBasicTypes … // basicType parses: // // <basic-type> func (rst *rustState) basicType() { … } // fnSig parses: // // <fn-sig> = [<binder>] ["U"] ["K" <abi>] {<type>} "E" <type> // <abi> = "C" // | <undisambiguated-identifier> func (rst *rustState) fnSig() { … } // dynBounds parses: // // <dyn-bounds> = [<binder>] {<dyn-trait>} "E" func (rst *rustState) dynBounds() { … } // dynTrait parses: // // <dyn-trait> = <path> {<dyn-trait-assoc-binding>} // <dyn-trait-assoc-binding> = "p" <undisambiguated-identifier> <type> func (rst *rustState) dynTrait() { … } // pathStartGenerics is like path but if it sees an I to start generic // arguments it won't close them. It reports whether it started generics. func (rst *rustState) pathStartGenerics() bool { … } // writeLifetime writes out a lifetime binding. func (rst *rustState) writeLifetime(lifetime int64) { … } // demangleConst parses: // // <const> = <type> <const-data> // | "p" // placeholder, shown as _ // | <backref> // <const-data> = ["n"] {<hex-digit>} "_" func (rst *rustState) demangleConst() { … } // base62Number parses: // // <base-62-number> = {<0-9a-zA-Z>} "_" func (rst *rustState) base62Number() int64 { … } // backref parses: // // <backref> = "B" <base-62-number> func (rst *rustState) backref(demangle func()) { … } func (rst *rustState) decimalNumber() int { … } // oldRustToString demangles a Rust symbol using the old demangling. // The second result reports whether this is a valid Rust mangled name. func oldRustToString(name string, options []Option) (string, bool) { … }