@@ -132,13 +132,16 @@ pub(crate) struct RenderType {
132
132
133
133
impl RenderType {
134
134
pub fn write_to_string ( & self , string : & mut String ) {
135
- if self . generics . is_some ( ) || self . bindings . is_some ( ) {
136
- string. push ( '{' ) ;
135
+ fn write_optional_id ( id : Option < RenderTypeId > , string : & mut String ) {
137
136
// 0 is a sentinel, everything else is one-indexed
138
- match self . id {
137
+ match id {
139
138
Some ( id) => id. write_to_string ( string) ,
140
139
None => string. push ( '`' ) ,
141
140
}
141
+ }
142
+ if self . generics . is_some ( ) || self . bindings . is_some ( ) {
143
+ string. push ( '{' ) ;
144
+ write_optional_id ( self . id , string) ;
142
145
string. push ( '{' ) ;
143
146
for generic in & self . generics . as_ref ( ) . map ( Vec :: as_slice) . unwrap_or_default ( ) [ ..] {
144
147
generic. write_to_string ( string) ;
@@ -153,18 +156,13 @@ impl RenderType {
153
156
for constraint in & binding. 1 [ ..] {
154
157
constraint. write_to_string ( string) ;
155
158
}
156
- string. push ( '}' ) ;
157
- string. push ( '}' ) ;
159
+ string. push_str ( "}}" ) ;
158
160
}
159
161
string. push ( '}' ) ;
160
162
}
161
163
string. push ( '}' ) ;
162
164
} else {
163
- // 0 is a sentinel, everything else is one-indexed
164
- match self . id {
165
- Some ( id) => id. write_to_string ( string) ,
166
- None => string. push ( '`' ) ,
167
- }
165
+ write_optional_id ( self . id , string) ;
168
166
}
169
167
}
170
168
}
@@ -191,6 +189,7 @@ impl RenderTypeId {
191
189
// zig-zag notation
192
190
let value: u32 = ( id << 1 ) | ( if sign { 1 } else { 0 } ) ;
193
191
// encode
192
+ // Documented in https://rust-lang.github.io/rustc-dev-guide/rustdoc-internals/search.html
194
193
let mut shift: u32 = 28 ;
195
194
let mut mask: u32 = 0xF0_00_00_00 ;
196
195
while shift < 32 {
0 commit comments