@@ -91,9 +91,7 @@ pub(super) fn hints(
91
91
match_ast ! {
92
92
match parent {
93
93
ast:: Fn ( it) => {
94
- let hint_text = format_function_hint( & it, config. max_length?)
95
- . unwrap_or_else( || format!( "fn {}" , it. name( ) . map( |n| n. to_string( ) ) . unwrap_or_default( ) ) ) ;
96
- ( hint_text, it. name( ) . map( name) )
94
+ ( format!( "fn {}" , it. name( ) ?) , it. name( ) . map( name) )
97
95
} ,
98
96
ast:: Static ( it) => ( format!( "static {}" , it. name( ) ?) , it. name( ) . map( name) ) ,
99
97
ast:: Const ( it) => {
@@ -156,47 +154,6 @@ pub(super) fn hints(
156
154
None
157
155
}
158
156
159
- fn format_function_hint ( func : & ast:: Fn , max_length : usize ) -> Option < String > {
160
- let name = func. name ( ) ?;
161
- let name_str = name. to_string ( ) ;
162
-
163
- let params = if let Some ( param_list) = func. param_list ( ) {
164
- let mut param_parts = Vec :: new ( ) ;
165
- let mut total_len = 0 ;
166
- let max_param_len = max_length. saturating_sub ( name_str. len ( ) + 4 ) ;
167
-
168
- for param in param_list. params ( ) {
169
- let param_text = if let Some ( pat) = param. pat ( ) {
170
- if let Some ( ty) = param. ty ( ) { format ! ( "{}: {}" , pat, ty) } else { pat. to_string ( ) }
171
- } else if let Some ( ty) = param. ty ( ) {
172
- format ! ( "_: {}" , ty)
173
- } else {
174
- let param_source = param. syntax ( ) . text ( ) . to_string ( ) ;
175
- if param_source. trim ( ) == "..." { "..." . to_owned ( ) } else { "_" . to_owned ( ) }
176
- } ;
177
-
178
- let param_len = param_text. len ( ) + if param_parts. is_empty ( ) { 0 } else { 2 } ;
179
- if total_len + param_len > max_param_len {
180
- param_parts. push ( "..." . to_owned ( ) ) ;
181
- break ;
182
- }
183
-
184
- total_len += param_len;
185
- param_parts. push ( param_text) ;
186
- }
187
-
188
- if param_parts. is_empty ( ) {
189
- "()" . to_owned ( )
190
- } else {
191
- format ! ( "({})" , param_parts. join( ", " ) )
192
- }
193
- } else {
194
- "()" . to_owned ( )
195
- } ;
196
-
197
- Some ( format ! ( "fn {}{}" , name_str, params) )
198
- }
199
-
200
157
#[ cfg( test) ]
201
158
mod tests {
202
159
use crate :: {
@@ -207,11 +164,7 @@ mod tests {
207
164
#[ test]
208
165
fn hints_closing_brace ( ) {
209
166
check_with_config (
210
- InlayHintsConfig {
211
- closing_brace_hints_min_lines : Some ( 2 ) ,
212
- max_length : Some ( 30 ) ,
213
- ..DISABLED_CONFIG
214
- } ,
167
+ InlayHintsConfig { closing_brace_hints_min_lines : Some ( 2 ) , ..DISABLED_CONFIG } ,
215
168
r#"
216
169
fn a() {}
217
170
@@ -220,17 +173,17 @@ fn f() {
220
173
221
174
fn g() {
222
175
}
223
- //^ fn g()
176
+ //^ fn g
224
177
225
178
fn h<T>(with: T, arguments: u8, ...) {
226
179
}
227
- //^ fn h(with: T, arguments: u8, ...)
180
+ //^ fn h
228
181
229
182
trait Tr {
230
183
fn f();
231
184
fn g() {
232
185
}
233
- //^ fn g()
186
+ //^ fn g
234
187
}
235
188
//^ trait Tr
236
189
impl Tr for () {
@@ -267,19 +220,15 @@ fn f() {
267
220
let v = vec![
268
221
];
269
222
}
270
- //^ fn f()
223
+ //^ fn f
271
224
"# ,
272
225
) ;
273
226
}
274
227
275
228
#[ test]
276
229
fn hints_closing_brace_for_block_expr ( ) {
277
230
check_with_config (
278
- InlayHintsConfig {
279
- closing_brace_hints_min_lines : Some ( 2 ) ,
280
- max_length : Some ( 10 ) ,
281
- ..DISABLED_CONFIG
282
- } ,
231
+ InlayHintsConfig { closing_brace_hints_min_lines : Some ( 2 ) , ..DISABLED_CONFIG } ,
283
232
r#"
284
233
fn test() {
285
234
'end: {
@@ -307,41 +256,8 @@ fn test() {
307
256
//^ 'a
308
257
309
258
}
310
- //^ fn test()
311
- "# ,
312
- ) ;
313
- }
314
-
315
- #[ test]
316
- fn hints_closing_brace_function_parameters ( ) {
317
- check_with_config (
318
- InlayHintsConfig {
319
- closing_brace_hints_min_lines : Some ( 1 ) ,
320
- max_length : Some ( 50 ) ,
321
- ..DISABLED_CONFIG
322
- } ,
323
- r#"
324
- fn simple() {
325
- let v = vec![
326
- ];
327
- }
328
- //^ fn simple()
329
-
330
- fn with_params(x: i32, y: String) {
331
-
332
- }
333
- //^ fn with_params(x: i32, y: String)
334
-
335
- fn long_params(very_long_parameter_name: ComplexType, another: AnotherType) {
336
-
337
- }
338
- //^ fn long_params(...)
339
-
340
- fn many_params(a: i32, b: i32, c: i32, d: i32, e: i32) {
341
-
342
- }
343
- //^ fn many_params(a: i32, b: i32, c: i32, d: i32, ...)
259
+ //^ fn test
344
260
"# ,
345
261
) ;
346
262
}
347
- }
263
+ }
0 commit comments