Skip to main content

ide/inlay_hints/
param_name.rs

1//! Implementation of "param name" inlay hints:
2//! ```no_run
3//! fn max(x: i32, y: i32) -> i32 { x + y }
4//! _ = max(/*x*/4, /*y*/4);
5//! ```
6
7use std::iter::zip;
8
9use either::Either;
10use hir::{EditionedFileId, Semantics};
11use ide_db::{RootDatabase, famous_defs::FamousDefs};
12
13use stdx::to_lower_snake_case;
14use syntax::T;
15use syntax::ast::{self, AstNode, HasArgList, HasName, UnaryOp};
16
17use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind};
18
19pub(super) fn hints(
20    acc: &mut Vec<InlayHint>,
21    FamousDefs(sema, krate): &FamousDefs<'_, '_>,
22    config: &InlayHintsConfig<'_>,
23    file_id: EditionedFileId,
24    expr: ast::Expr,
25) -> Option<()> {
26    if !config.parameter_hints {
27        return None;
28    }
29
30    let (callable, arg_list) = get_callable(sema, &expr)?;
31    let unary_function = callable.n_params() == 1;
32    let function_name = match callable.kind() {
33        hir::CallableKind::Function(function) => Some(function.name(sema.db)),
34        _ => None,
35    };
36    let function_name = function_name.as_ref().map(|it| it.as_str());
37    let hints = callable
38        .params()
39        .into_iter()
40        .zip(arg_list.args_maybe_empty())
41        .filter_map(|(p, arg)| {
42            let arg = arg?;
43            // Only annotate hints for expressions that exist in the original file
44            let range = sema.original_range_opt(arg.syntax())?;
45            if range.file_id != file_id {
46                return None;
47            }
48            let param_name = p.name(sema.db)?;
49            Some((p, param_name, arg, range))
50        })
51        .filter(|(_, param_name, arg, _)| {
52            !should_hide_param_name_hint(
53                sema,
54                unary_function,
55                function_name,
56                param_name.as_str(),
57                arg,
58            )
59        })
60        .map(|(param, param_name, _, hir::FileRange { range, .. })| {
61            let colon = if config.render_colons { ":" } else { "" };
62            let label = InlayHintLabel::simple(
63                format!("{}{colon}", param_name.display(sema.db, krate.edition(sema.db))),
64                None,
65                config.lazy_location_opt(|| {
66                    let source = sema.source(param)?;
67                    let name_syntax = match source.value.as_ref() {
68                        Either::Left(pat) => pat.name(),
69                        Either::Right(param) => match param.pat()? {
70                            ast::Pat::IdentPat(it) => it.name(),
71                            _ => None,
72                        },
73                    }?;
74                    sema.original_range_opt(name_syntax.syntax()).map(|frange| ide_db::FileRange {
75                        file_id: frange.file_id.file_id(sema.db),
76                        range: frange.range,
77                    })
78                }),
79            );
80            InlayHint {
81                range,
82                kind: InlayKind::Parameter,
83                label,
84                text_edit: None,
85                position: InlayHintPosition::Before,
86                pad_left: false,
87                pad_right: true,
88                resolve_parent: Some(expr.syntax().text_range()),
89            }
90        });
91
92    acc.extend(hints);
93
94    // Show hint for the next expected (missing) argument if enabled
95    if config.parameter_hints_for_missing_arguments {
96        let provided_args_count = arg_list.args().count();
97        let params = callable.params();
98        let total_params = params.len();
99
100        if provided_args_count < total_params
101            && let Some(next_param) = params.get(provided_args_count)
102            && let Some(param_name) = next_param.name(sema.db)
103        {
104            // Apply heuristics to hide obvious parameter hints
105            if should_hide_missing_param_hint(unary_function, function_name, param_name.as_str()) {
106                return Some(());
107            }
108
109            // Determine the position for the hint
110            if let Some(hint_range) = missing_arg_hint_position(&arg_list) {
111                let colon = if config.render_colons { ":" } else { "" };
112                let label = InlayHintLabel::simple(
113                    format!("{}{}", param_name.display(sema.db, krate.edition(sema.db)), colon),
114                    None,
115                    config.lazy_location_opt(|| {
116                        let source = sema.source(next_param.clone())?;
117                        let name_syntax = match source.value.as_ref() {
118                            Either::Left(pat) => pat.name(),
119                            Either::Right(param) => match param.pat()? {
120                                ast::Pat::IdentPat(it) => it.name(),
121                                _ => None,
122                            },
123                        }?;
124                        sema.original_range_opt(name_syntax.syntax()).map(|frange| {
125                            ide_db::FileRange {
126                                file_id: frange.file_id.file_id(sema.db),
127                                range: frange.range,
128                            }
129                        })
130                    }),
131                );
132                acc.push(InlayHint {
133                    range: hint_range,
134                    kind: InlayKind::Parameter,
135                    label,
136                    text_edit: None,
137                    position: InlayHintPosition::Before,
138                    pad_left: true,
139                    pad_right: false,
140                    resolve_parent: Some(expr.syntax().text_range()),
141                });
142            }
143        }
144    }
145
146    Some(())
147}
148
149/// Determines the position where the hint for a missing argument should be placed.
150/// Returns the range of the token where the hint should appear.
151fn missing_arg_hint_position(arg_list: &ast::ArgList) -> Option<syntax::TextRange> {
152    // Always place the hint on the closing paren, so it appears before `)`.
153    // This way `foo()` becomes `foo(a)` visually with the hint.
154    arg_list
155        .syntax()
156        .children_with_tokens()
157        .filter_map(|it| it.into_token())
158        .find(|t| t.kind() == T![')'])
159        .map(|t| t.text_range())
160}
161
162fn get_callable<'db>(
163    sema: &Semantics<'db, RootDatabase>,
164    expr: &ast::Expr,
165) -> Option<(hir::Callable<'db>, ast::ArgList)> {
166    match expr {
167        ast::Expr::CallExpr(expr) => {
168            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
169            let expr = descended.as_ref().unwrap_or(expr);
170            sema.type_of_expr(&expr.expr()?)?.original.as_callable(sema.db).zip(expr.arg_list())
171        }
172        ast::Expr::MethodCallExpr(expr) => {
173            let descended = sema.descend_node_into_attributes(expr.clone()).pop();
174            let expr = descended.as_ref().unwrap_or(expr);
175            sema.resolve_method_call_as_callable(expr).zip(expr.arg_list())
176        }
177        _ => None,
178    }
179}
180
181const INSIGNIFICANT_METHOD_NAMES: &[&str] = &["clone", "as_ref", "into"];
182const INSIGNIFICANT_PARAMETER_NAMES: &[&str] =
183    &["predicate", "value", "pat", "rhs", "other", "msg", "op"];
184
185fn should_hide_param_name_hint(
186    sema: &Semantics<'_, RootDatabase>,
187    unary_function: bool,
188    function_name: Option<&str>,
189    param_name: &str,
190    argument: &ast::Expr,
191) -> bool {
192    // These are to be tested in the `parameter_hint_heuristics` test
193    // hide when:
194    // - the parameter name is a suffix of the function's name
195    // - the argument is a qualified constructing or call expression where the qualifier is an ADT
196    // - exact argument<->parameter match(ignoring leading and trailing underscore) or
197    //   parameter is a prefix/suffix of argument with _ splitting it off
198    // - param starts with `ra_fixture`
199    // - param is a well known name in a unary function
200
201    let param_name = param_name.trim_matches('_');
202    if param_name.is_empty() {
203        return true;
204    }
205
206    if param_name.starts_with("ra_fixture") {
207        return true;
208    }
209
210    if unary_function {
211        if let Some(function_name) = function_name
212            && is_param_name_suffix_of_fn_name(param_name, function_name)
213        {
214            return true;
215        }
216        if is_obvious_param(param_name) {
217            return true;
218        }
219    }
220
221    is_argument_expr_similar_to_param_name(sema, argument, param_name)
222}
223
224/// Determines whether to hide the parameter hint for a missing argument.
225/// This is a simplified version of `should_hide_param_name_hint` that doesn't
226/// require an actual argument expression.
227fn should_hide_missing_param_hint(
228    unary_function: bool,
229    function_name: Option<&str>,
230    param_name: &str,
231) -> bool {
232    let param_name = param_name.trim_matches('_');
233    if param_name.is_empty() {
234        return true;
235    }
236
237    if param_name.starts_with("ra_fixture") {
238        return true;
239    }
240
241    if unary_function {
242        if let Some(function_name) = function_name
243            && is_param_name_suffix_of_fn_name(param_name, function_name)
244        {
245            return true;
246        }
247        if is_obvious_param(param_name) {
248            return true;
249        }
250    }
251
252    false
253}
254
255/// Hide the parameter name of a unary function if it is a `_` - prefixed suffix of the function's name, or equal.
256///
257/// `fn strip_suffix(suffix)` will be hidden.
258/// `fn stripsuffix(suffix)` will not be hidden.
259fn is_param_name_suffix_of_fn_name(param_name: &str, fn_name: &str) -> bool {
260    fn_name == param_name
261        || fn_name
262            .len()
263            .checked_sub(param_name.len())
264            .and_then(|at| fn_name.is_char_boundary(at).then(|| fn_name.split_at(at)))
265            .is_some_and(|(prefix, suffix)| {
266                suffix.eq_ignore_ascii_case(param_name) && prefix.ends_with('_')
267            })
268}
269
270fn is_argument_expr_similar_to_param_name(
271    sema: &Semantics<'_, RootDatabase>,
272    argument: &ast::Expr,
273    param_name: &str,
274) -> bool {
275    match get_segment_representation(argument) {
276        Some(Either::Left(argument)) => is_argument_similar_to_param_name(&argument, param_name),
277        Some(Either::Right(path)) => {
278            path.segment()
279                .and_then(|it| it.name_ref())
280                .is_some_and(|name_ref| name_ref.text().eq_ignore_ascii_case(param_name))
281                || is_adt_constructor_similar_to_param_name(sema, &path, param_name)
282        }
283        None => false,
284    }
285}
286
287/// Check whether param_name and argument are the same or
288/// whether param_name is a prefix/suffix of argument(split at `_`).
289pub(super) fn is_argument_similar_to_param_name(
290    argument: &[ast::NameRef],
291    param_name: &str,
292) -> bool {
293    debug_assert!(!argument.is_empty());
294    debug_assert!(!param_name.is_empty());
295    let param_name = param_name.split('_');
296    let argument = argument.iter().flat_map(|it| it.text_non_mutable().split('_'));
297
298    let prefix_match = zip(argument.clone(), param_name.clone())
299        .all(|(arg, param)| arg.eq_ignore_ascii_case(param));
300    let postfix_match = || {
301        zip(argument.rev(), param_name.rev()).all(|(arg, param)| arg.eq_ignore_ascii_case(param))
302    };
303    prefix_match || postfix_match()
304}
305
306pub(super) fn get_segment_representation(
307    expr: &ast::Expr,
308) -> Option<Either<Vec<ast::NameRef>, ast::Path>> {
309    match expr {
310        ast::Expr::MethodCallExpr(method_call_expr) => {
311            let receiver =
312                method_call_expr.receiver().and_then(|expr| get_segment_representation(&expr));
313            let name_ref = method_call_expr.name_ref()?;
314            if INSIGNIFICANT_METHOD_NAMES.contains(&name_ref.text().as_str()) {
315                return receiver;
316            }
317            Some(Either::Left(match receiver {
318                Some(Either::Left(mut left)) => {
319                    left.push(name_ref);
320                    left
321                }
322                Some(Either::Right(_)) | None => vec![name_ref],
323            }))
324        }
325        ast::Expr::FieldExpr(field_expr) => {
326            let expr = field_expr.expr().and_then(|expr| get_segment_representation(&expr));
327            let name_ref = field_expr.name_ref()?;
328            let res = match expr {
329                Some(Either::Left(mut left)) => {
330                    left.push(name_ref);
331                    left
332                }
333                Some(Either::Right(_)) | None => vec![name_ref],
334            };
335            Some(Either::Left(res))
336        }
337        // paths
338        ast::Expr::MacroExpr(macro_expr) => macro_expr.macro_call()?.path().map(Either::Right),
339        ast::Expr::RecordExpr(record_expr) => record_expr.path().map(Either::Right),
340        ast::Expr::PathExpr(path_expr) => {
341            let path = path_expr.path()?;
342            // single segment paths are likely locals
343            Some(match path.as_single_name_ref() {
344                None => Either::Right(path),
345                Some(name_ref) => Either::Left(vec![name_ref]),
346            })
347        }
348        ast::Expr::PrefixExpr(prefix_expr) if prefix_expr.op_kind() == Some(UnaryOp::Not) => None,
349        // recurse
350        ast::Expr::PrefixExpr(prefix_expr) => get_segment_representation(&prefix_expr.expr()?),
351        ast::Expr::RefExpr(ref_expr) => get_segment_representation(&ref_expr.expr()?),
352        ast::Expr::CastExpr(cast_expr) => get_segment_representation(&cast_expr.expr()?),
353        ast::Expr::CallExpr(call_expr) => get_segment_representation(&call_expr.expr()?),
354        ast::Expr::AwaitExpr(await_expr) => get_segment_representation(&await_expr.expr()?),
355        ast::Expr::IndexExpr(index_expr) => get_segment_representation(&index_expr.base()?),
356        ast::Expr::ParenExpr(paren_expr) => get_segment_representation(&paren_expr.expr()?),
357        ast::Expr::TryExpr(try_expr) => get_segment_representation(&try_expr.expr()?),
358        // ast::Expr::ClosureExpr(closure_expr) => todo!(),
359        _ => None,
360    }
361}
362
363fn is_obvious_param(param_name: &str) -> bool {
364    // avoid displaying hints for common functions like map, filter, etc.
365    // or other obvious words used in std
366    param_name.len() == 1 || INSIGNIFICANT_PARAMETER_NAMES.contains(&param_name)
367}
368
369fn is_adt_constructor_similar_to_param_name(
370    sema: &Semantics<'_, RootDatabase>,
371    path: &ast::Path,
372    param_name: &str,
373) -> bool {
374    (|| match sema.resolve_path(path)? {
375        hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
376            Some(to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name)
377        }
378        hir::PathResolution::Def(hir::ModuleDef::Function(_) | hir::ModuleDef::EnumVariant(_)) => {
379            if to_lower_snake_case(&path.segment()?.name_ref()?.text()) == param_name {
380                return Some(true);
381            }
382            let qual = path.qualifier()?;
383            match sema.resolve_path(&qual)? {
384                hir::PathResolution::Def(hir::ModuleDef::Adt(_)) => {
385                    Some(to_lower_snake_case(&qual.segment()?.name_ref()?.text()) == param_name)
386                }
387                _ => None,
388            }
389        }
390        _ => None,
391    })()
392    .unwrap_or(false)
393}
394
395#[cfg(test)]
396mod tests {
397    use crate::{
398        InlayHintsConfig,
399        inlay_hints::tests::{DISABLED_CONFIG, check_with_config},
400    };
401
402    #[track_caller]
403    fn check_params(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
404        check_with_config(
405            InlayHintsConfig { parameter_hints: true, ..DISABLED_CONFIG },
406            ra_fixture,
407        );
408    }
409
410    #[test]
411    fn param_hints_only() {
412        check_params(
413            r#"
414fn foo(a: i32, b: i32) -> i32 { a + b }
415fn main() {
416    let _x = foo(
417        4,
418      //^ a
419        4,
420      //^ b
421    );
422}"#,
423        );
424    }
425
426    #[test]
427    fn param_hints_on_closure() {
428        check_params(
429            r#"
430fn main() {
431    let clo = |a: u8, b: u8| a + b;
432    clo(
433        1,
434      //^ a
435        2,
436      //^ b
437    );
438}
439            "#,
440        );
441    }
442
443    #[test]
444    fn param_name_similar_to_fn_name_still_hints() {
445        check_params(
446            r#"
447fn max(x: i32, y: i32) -> i32 { x + y }
448fn main() {
449    let _x = max(
450        4,
451      //^ x
452        4,
453      //^ y
454    );
455}"#,
456        );
457    }
458
459    #[test]
460    fn param_name_similar_to_fn_name() {
461        check_params(
462            r#"
463fn param_with_underscore(with_underscore: i32) -> i32 { with_underscore }
464fn main() {
465    let _x = param_with_underscore(
466        4,
467    );
468}"#,
469        );
470        check_params(
471            r#"
472fn param_with_underscore(underscore: i32) -> i32 { underscore }
473fn main() {
474    let _x = param_with_underscore(
475        4,
476    );
477}"#,
478        );
479    }
480
481    #[test]
482    fn param_name_same_as_fn_name() {
483        check_params(
484            r#"
485fn foo(foo: i32) -> i32 { foo }
486fn main() {
487    let _x = foo(
488        4,
489    );
490}"#,
491        );
492    }
493
494    #[test]
495    fn never_hide_param_when_multiple_params() {
496        check_params(
497            r#"
498fn foo(foo: i32, bar: i32) -> i32 { bar + baz }
499fn main() {
500    let _x = foo(
501        4,
502      //^ foo
503        8,
504      //^ bar
505    );
506}"#,
507        );
508    }
509
510    #[test]
511    fn param_hints_look_through_as_ref_and_clone() {
512        check_params(
513            r#"
514fn foo(bar: i32, baz: f32) {}
515
516fn main() {
517    let bar = 3;
518    let baz = &"baz";
519    let fez = 1.0;
520    foo(bar.clone(), bar.clone());
521                   //^^^^^^^^^^^ baz
522    foo(bar.as_ref(), bar.as_ref());
523                    //^^^^^^^^^^^^ baz
524}
525"#,
526        );
527    }
528
529    #[test]
530    fn self_param_hints() {
531        check_params(
532            r#"
533struct Foo;
534
535impl Foo {
536    fn foo(self: Self) {}
537    fn bar(self: &Self) {}
538}
539
540fn main() {
541    Foo::foo(Foo);
542           //^^^ self
543    Foo::bar(&Foo);
544           //^^^^ self
545}
546"#,
547        )
548    }
549
550    #[test]
551    fn param_name_hints_show_for_literals() {
552        check_params(
553            r#"pub fn test(a: i32, b: i32) -> [i32; 2] { [a, b] }
554fn main() {
555    test(
556        0xa_b,
557      //^^^^^ a
558        0xa_b,
559      //^^^^^ b
560    );
561}"#,
562        )
563    }
564
565    #[test]
566    fn param_name_hints_show_after_empty_arg() {
567        check_params(
568            r#"pub fn test(a: i32, b: i32, c: i32) {}
569fn main() {
570    test(, 2,);
571         //^ b
572    test(, , 3);
573           //^ c
574}"#,
575        )
576    }
577
578    #[test]
579    fn function_call_parameter_hint() {
580        check_params(
581            r#"
582//- minicore: option
583struct FileId {}
584struct SmolStr {}
585
586struct TextRange {}
587struct SyntaxKind {}
588struct NavigationTarget {}
589
590struct Test {}
591
592impl Test {
593    fn method(&self, mut param: i32) -> i32 { param * 2 }
594
595    fn from_syntax(
596        file_id: FileId,
597        name: SmolStr,
598        focus_range: Option<TextRange>,
599        full_range: TextRange,
600        kind: SyntaxKind,
601        docs: Option<String>,
602    ) -> NavigationTarget {
603        NavigationTarget {}
604    }
605}
606
607fn test_func(mut foo: i32, bar: i32, msg: &str, _: i32, last: i32) -> i32 {
608    foo + bar
609}
610
611fn main() {
612    let not_literal = 1;
613    let _: i32 = test_func(1,    2,      "hello", 3,  not_literal);
614                         //^ foo ^ bar   ^^^^^^^ msg  ^^^^^^^^^^^ last
615    let t: Test = Test {};
616    t.method(123);
617           //^^^ param
618    Test::method(&t,      3456);
619               //^^ self  ^^^^ param
620    Test::from_syntax(
621        FileId {},
622        "impl".into(),
623      //^^^^^^^^^^^^^ name
624        None,
625      //^^^^ focus_range
626        TextRange {},
627      //^^^^^^^^^^^^ full_range
628        SyntaxKind {},
629      //^^^^^^^^^^^^^ kind
630        None,
631      //^^^^ docs
632    );
633}"#,
634        );
635    }
636
637    #[test]
638    fn parameter_hint_heuristics() {
639        check_params(
640            r#"
641fn check(ra_fixture_thing: &str) {}
642
643fn map(f: i32) {}
644fn filter(predicate: i32) {}
645
646fn strip_suffix(suffix: &str) {}
647fn stripsuffix(suffix: &str) {}
648fn same(same: u32) {}
649fn same2(_same2: u32) {}
650
651fn enum_matches_param_name(completion_kind: CompletionKind) {}
652
653fn foo(param: u32) {}
654fn bar(param_eter: u32) {}
655fn baz(a_d_e: u32) {}
656fn far(loop_: u32) {}
657fn faz(r#loop: u32) {}
658
659enum CompletionKind {
660    Keyword,
661}
662
663fn non_ident_pat((a, b): (u32, u32)) {}
664
665fn main() {
666    const PARAM: u32 = 0;
667    foo(PARAM);
668    foo(!PARAM);
669     // ^^^^^^ param
670    check("");
671
672    map(0);
673    filter(0);
674
675    strip_suffix("");
676    stripsuffix("");
677              //^^ suffix
678    same(0);
679    same2(0);
680
681    enum_matches_param_name(CompletionKind::Keyword);
682
683    let param = 0;
684    foo(param);
685    foo(param as _);
686    let param_end = 0;
687    foo(param_end);
688    let start_param = 0;
689    foo(start_param);
690    let param2 = 0;
691    foo(param2);
692      //^^^^^^ param
693
694    macro_rules! param {
695        () => {};
696    };
697    foo(param!());
698
699    let param_eter = 0;
700    bar(param_eter);
701    let param_eter_end = 0;
702    bar(param_eter_end);
703    let start_param_eter = 0;
704    bar(start_param_eter);
705    let param_eter2 = 0;
706    bar(param_eter2);
707      //^^^^^^^^^^^ param_eter
708    let loop_level = 0;
709    far(loop_level);
710    faz(loop_level);
711
712    non_ident_pat((0, 0));
713
714    baz(a.d.e);
715    baz(a.dc.e);
716     // ^^^^^^ a_d_e
717    baz(ac.d.e);
718     // ^^^^^^ a_d_e
719    baz(a.d.ec);
720     // ^^^^^^ a_d_e
721}"#,
722        );
723    }
724
725    #[track_caller]
726    fn check_missing_params(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
727        check_with_config(
728            InlayHintsConfig {
729                parameter_hints: true,
730                parameter_hints_for_missing_arguments: true,
731                ..DISABLED_CONFIG
732            },
733            ra_fixture,
734        );
735    }
736
737    #[test]
738    fn missing_param_hint_empty_call() {
739        // When calling foo() with no args, show hint for first param on the closing paren
740        check_missing_params(
741            r#"
742fn foo(a: i32, b: i32) -> i32 { a + b }
743fn main() {
744    foo();
745      //^ a
746}"#,
747        );
748    }
749
750    #[test]
751    fn missing_param_hint_after_first_arg() {
752        // foo(1,) - show hint for 'a' on '1', and 'b' on the trailing comma
753        check_missing_params(
754            r#"
755fn foo(a: i32, b: i32) -> i32 { a + b }
756fn main() {
757    foo(1,);
758      //^ a
759        //^ b
760}"#,
761        );
762    }
763
764    #[test]
765    fn missing_param_hint_partial_args() {
766        // foo(1, 2,) - show hints for a, b on args, and c on trailing comma
767        check_missing_params(
768            r#"
769fn foo(a: i32, b: i32, c: i32) -> i32 { a + b + c }
770fn main() {
771    foo(1, 2,);
772      //^ a
773         //^ b
774           //^ c
775}"#,
776        );
777    }
778
779    #[test]
780    fn missing_param_hint_method_call() {
781        // S.foo(1,) - show hint for 'a' on '1', and 'b' on trailing comma
782        check_missing_params(
783            r#"
784struct S;
785impl S {
786    fn foo(&self, a: i32, b: i32) -> i32 { a + b }
787}
788fn main() {
789    S.foo(1,);
790        //^ a
791          //^ b
792}"#,
793        );
794    }
795
796    #[test]
797    fn missing_param_hint_no_hint_when_complete() {
798        // When all args provided, no missing hint - just regular param hints
799        check_missing_params(
800            r#"
801fn foo(a: i32, b: i32) -> i32 { a + b }
802fn main() {
803    foo(1, 2);
804      //^ a
805         //^ b
806}"#,
807        );
808    }
809
810    #[test]
811    fn missing_param_hint_respects_heuristics() {
812        // The hint should be hidden if it matches heuristics (e.g., single param unary fn with same name)
813        check_missing_params(
814            r#"
815fn foo(foo: i32) -> i32 { foo }
816fn main() {
817    foo();
818}"#,
819        );
820    }
821}