@@ -74,6 +74,8 @@ pub struct HirFormatter<'a> {
74
74
/// When rendering something that has a concept of "children" (like fields in a struct), this limits
75
75
/// how many should be rendered.
76
76
pub entity_limit : Option < usize > ,
77
+ /// When rendering functions, whether to show the constraint from the container
78
+ show_container_bounds : bool ,
77
79
omit_verbose_types : bool ,
78
80
closure_style : ClosureStyle ,
79
81
display_target : DisplayTarget ,
@@ -101,6 +103,7 @@ pub trait HirDisplay {
101
103
omit_verbose_types : bool ,
102
104
display_target : DisplayTarget ,
103
105
closure_style : ClosureStyle ,
106
+ show_container_bounds : bool ,
104
107
) -> HirDisplayWrapper < ' a , Self >
105
108
where
106
109
Self : Sized ,
@@ -117,6 +120,7 @@ pub trait HirDisplay {
117
120
omit_verbose_types,
118
121
display_target,
119
122
closure_style,
123
+ show_container_bounds,
120
124
}
121
125
}
122
126
@@ -134,6 +138,7 @@ pub trait HirDisplay {
134
138
omit_verbose_types : false ,
135
139
closure_style : ClosureStyle :: ImplFn ,
136
140
display_target : DisplayTarget :: Diagnostics ,
141
+ show_container_bounds : false ,
137
142
}
138
143
}
139
144
@@ -155,6 +160,7 @@ pub trait HirDisplay {
155
160
omit_verbose_types : true ,
156
161
closure_style : ClosureStyle :: ImplFn ,
157
162
display_target : DisplayTarget :: Diagnostics ,
163
+ show_container_bounds : false ,
158
164
}
159
165
}
160
166
@@ -176,6 +182,7 @@ pub trait HirDisplay {
176
182
omit_verbose_types : true ,
177
183
closure_style : ClosureStyle :: ImplFn ,
178
184
display_target : DisplayTarget :: Diagnostics ,
185
+ show_container_bounds : false ,
179
186
}
180
187
}
181
188
@@ -198,6 +205,7 @@ pub trait HirDisplay {
198
205
omit_verbose_types : false ,
199
206
closure_style : ClosureStyle :: ImplFn ,
200
207
display_target : DisplayTarget :: SourceCode { module_id, allow_opaque } ,
208
+ show_container_bounds : false ,
201
209
} ) {
202
210
Ok ( ( ) ) => { }
203
211
Err ( HirDisplayError :: FmtError ) => panic ! ( "Writing to String can't fail!" ) ,
@@ -219,6 +227,29 @@ pub trait HirDisplay {
219
227
omit_verbose_types : false ,
220
228
closure_style : ClosureStyle :: ImplFn ,
221
229
display_target : DisplayTarget :: Test ,
230
+ show_container_bounds : false ,
231
+ }
232
+ }
233
+
234
+ /// Returns a String representation of `self` that shows the constraint from
235
+ /// the container for functions
236
+ fn display_with_container_bounds < ' a > (
237
+ & ' a self ,
238
+ db : & ' a dyn HirDatabase ,
239
+ show_container_bounds : bool ,
240
+ ) -> HirDisplayWrapper < ' a , Self >
241
+ where
242
+ Self : Sized ,
243
+ {
244
+ HirDisplayWrapper {
245
+ db,
246
+ t : self ,
247
+ max_size : None ,
248
+ limited_size : None ,
249
+ omit_verbose_types : false ,
250
+ closure_style : ClosureStyle :: ImplFn ,
251
+ display_target : DisplayTarget :: Diagnostics ,
252
+ show_container_bounds,
222
253
}
223
254
}
224
255
}
@@ -277,6 +308,10 @@ impl HirFormatter<'_> {
277
308
pub fn omit_verbose_types ( & self ) -> bool {
278
309
self . omit_verbose_types
279
310
}
311
+
312
+ pub fn show_container_bounds ( & self ) -> bool {
313
+ self . show_container_bounds
314
+ }
280
315
}
281
316
282
317
#[ derive( Clone , Copy ) ]
@@ -336,6 +371,7 @@ pub struct HirDisplayWrapper<'a, T> {
336
371
omit_verbose_types : bool ,
337
372
closure_style : ClosureStyle ,
338
373
display_target : DisplayTarget ,
374
+ show_container_bounds : bool ,
339
375
}
340
376
341
377
#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
@@ -365,6 +401,7 @@ impl<T: HirDisplay> HirDisplayWrapper<'_, T> {
365
401
omit_verbose_types : self . omit_verbose_types ,
366
402
display_target : self . display_target ,
367
403
closure_style : self . closure_style ,
404
+ show_container_bounds : self . show_container_bounds ,
368
405
} )
369
406
}
370
407
0 commit comments