@@ -74,6 +74,8 @@ pub struct HirFormatter<'a> {
7474 /// When rendering something that has a concept of "children" (like fields in a struct), this limits
7575 /// how many should be rendered.
7676 pub entity_limit : Option < usize > ,
77+ /// When rendering functions, whether to show the constraint from the container
78+ show_container_bounds : bool ,
7779 omit_verbose_types : bool ,
7880 closure_style : ClosureStyle ,
7981 display_target : DisplayTarget ,
@@ -101,6 +103,7 @@ pub trait HirDisplay {
101103 omit_verbose_types : bool ,
102104 display_target : DisplayTarget ,
103105 closure_style : ClosureStyle ,
106+ show_container_bounds : bool ,
104107 ) -> HirDisplayWrapper < ' a , Self >
105108 where
106109 Self : Sized ,
@@ -117,6 +120,7 @@ pub trait HirDisplay {
117120 omit_verbose_types,
118121 display_target,
119122 closure_style,
123+ show_container_bounds,
120124 }
121125 }
122126
@@ -134,6 +138,7 @@ pub trait HirDisplay {
134138 omit_verbose_types : false ,
135139 closure_style : ClosureStyle :: ImplFn ,
136140 display_target : DisplayTarget :: Diagnostics ,
141+ show_container_bounds : false ,
137142 }
138143 }
139144
@@ -155,6 +160,7 @@ pub trait HirDisplay {
155160 omit_verbose_types : true ,
156161 closure_style : ClosureStyle :: ImplFn ,
157162 display_target : DisplayTarget :: Diagnostics ,
163+ show_container_bounds : false ,
158164 }
159165 }
160166
@@ -176,6 +182,7 @@ pub trait HirDisplay {
176182 omit_verbose_types : true ,
177183 closure_style : ClosureStyle :: ImplFn ,
178184 display_target : DisplayTarget :: Diagnostics ,
185+ show_container_bounds : false ,
179186 }
180187 }
181188
@@ -198,6 +205,7 @@ pub trait HirDisplay {
198205 omit_verbose_types : false ,
199206 closure_style : ClosureStyle :: ImplFn ,
200207 display_target : DisplayTarget :: SourceCode { module_id, allow_opaque } ,
208+ show_container_bounds : false ,
201209 } ) {
202210 Ok ( ( ) ) => { }
203211 Err ( HirDisplayError :: FmtError ) => panic ! ( "Writing to String can't fail!" ) ,
@@ -219,6 +227,29 @@ pub trait HirDisplay {
219227 omit_verbose_types : false ,
220228 closure_style : ClosureStyle :: ImplFn ,
221229 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,
222253 }
223254 }
224255}
@@ -277,6 +308,10 @@ impl HirFormatter<'_> {
277308 pub fn omit_verbose_types ( & self ) -> bool {
278309 self . omit_verbose_types
279310 }
311+
312+ pub fn show_container_bounds ( & self ) -> bool {
313+ self . show_container_bounds
314+ }
280315}
281316
282317#[ derive( Clone , Copy ) ]
@@ -336,6 +371,7 @@ pub struct HirDisplayWrapper<'a, T> {
336371 omit_verbose_types : bool ,
337372 closure_style : ClosureStyle ,
338373 display_target : DisplayTarget ,
374+ show_container_bounds : bool ,
339375}
340376
341377#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
@@ -365,6 +401,7 @@ impl<T: HirDisplay> HirDisplayWrapper<'_, T> {
365401 omit_verbose_types : self . omit_verbose_types ,
366402 display_target : self . display_target ,
367403 closure_style : self . closure_style ,
404+ show_container_bounds : self . show_container_bounds ,
368405 } )
369406 }
370407
0 commit comments