|
3 | 3 | //! Tests live in [`bind_pat`][super::bind_pat] module. |
4 | 4 | use ide_db::famous_defs::FamousDefs; |
5 | 5 | use span::EditionedFileId; |
6 | | -use stdx::TupleExt; |
| 6 | +use stdx::{never, TupleExt}; |
7 | 7 | use syntax::ast::{self, AstNode}; |
8 | 8 | use text_edit::{TextRange, TextSize}; |
9 | 9 |
|
@@ -63,17 +63,21 @@ pub(super) fn hints( |
63 | 63 | // force cache the source file, otherwise sema lookup will potentially panic |
64 | 64 | _ = sema.parse_or_expand(source.file()); |
65 | 65 |
|
| 66 | + let label = format!( |
| 67 | + "{}{}", |
| 68 | + match capture.kind() { |
| 69 | + hir::CaptureKind::SharedRef => "&", |
| 70 | + hir::CaptureKind::UniqueSharedRef => "&unique ", |
| 71 | + hir::CaptureKind::MutableRef => "&mut ", |
| 72 | + hir::CaptureKind::Move => "", |
| 73 | + }, |
| 74 | + capture.display_place(sema.db) |
| 75 | + ); |
| 76 | + if never!(label.is_empty()) { |
| 77 | + continue; |
| 78 | + } |
66 | 79 | let label = InlayHintLabel::simple( |
67 | | - format!( |
68 | | - "{}{}", |
69 | | - match capture.kind() { |
70 | | - hir::CaptureKind::SharedRef => "&", |
71 | | - hir::CaptureKind::UniqueSharedRef => "&unique ", |
72 | | - hir::CaptureKind::MutableRef => "&mut ", |
73 | | - hir::CaptureKind::Move => "", |
74 | | - }, |
75 | | - capture.display_place(sema.db) |
76 | | - ), |
| 80 | + label, |
77 | 81 | None, |
78 | 82 | source.name().and_then(|name| { |
79 | 83 | name.syntax().original_file_range_opt(sema.db).map(TupleExt::head).map(Into::into) |
|
0 commit comments