@@ -306,19 +306,20 @@ fn write_type_arg_str(arg: &TypeArg, f: &mut std::fmt::Formatter<'_>) -> std::fm
306306 }
307307}
308308
309- /// We do our best to generate unique names. Our strategy is to pick out '$' as
309+ /// Produce a mangled name for a monomorphized instance of a function.
310+ ///
311+ /// Best effort to generate unique names. The strategy is to pick out '$' as
310312/// a special character.
311313///
312- /// We:
313- /// - construct a new name of the form `{func_name}$$arg0$arg1$arg2` etc
314- /// - replace any existing `$` in the function name or type args string
315- /// representation with `r"\$"`
316- /// - We depend on the `Display` impl of `Type` to generate the string
317- /// representation of a `TypeArg::Type`. For other constructors we do the
318- /// simple obvious thing.
319- /// - For all TypeArg Constructors we choose a short prefix (e.g. `t` for type)
320- /// and use "t({arg})" as the string representation of that arg.
321- fn mangle_name ( name : & str , type_args : impl AsRef < [ TypeArg ] > ) -> String {
314+ /// - New name of the form `{func_name}$$arg0$arg1$arg2` constructed.
315+ /// - Existing `$` in the function name or type args string
316+ /// representation replaced with `r"\$"`.
317+ /// - `Display` impl of `Type` used to generate the string
318+ /// representation of a `TypeArg::Type`. Other TypeArgs use `Display`
319+ /// of inner type.
320+ /// - For all TypeArg Constructors a short prefix (e.g. `t` for type)
321+ /// is used as "t({arg})" for the string representation of that arg.
322+ pub fn mangle_name ( name : & str , type_args : impl AsRef < [ TypeArg ] > ) -> String {
322323 let name = escape_dollar ( name) ;
323324 format ! ( "${name}${}" , TypeArgsList ( type_args. as_ref( ) ) )
324325}
0 commit comments