Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d5faad1

Browse files
committed
Fix inlay-hint tests being invalidated by minicore chanes
1 parent 6ddccc9 commit d5faad1

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

crates/hir/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3403,6 +3403,10 @@ impl Impl {
34033403
db.impl_data(self.id).is_negative
34043404
}
34053405

3406+
pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
3407+
db.impl_data(self.id).is_unique()
3408+
}
3409+
34063410
pub fn module(self, db: &dyn HirDatabase) -> Module {
34073411
self.id.lookup(db.upcast()).container.into()
34083412
}

crates/ide/src/inlay_hints.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ mod tests {
563563
use hir::ClosureStyle;
564564
use itertools::Itertools;
565565
use test_utils::extract_annotations;
566+
use text_edit::{TextRange, TextSize};
566567

567568
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
568569
use crate::DiscriminantHints;
@@ -629,6 +630,22 @@ mod tests {
629630
expect.assert_debug_eq(&inlay_hints)
630631
}
631632

633+
#[track_caller]
634+
pub(super) fn check_expect_clear_loc(
635+
config: InlayHintsConfig,
636+
ra_fixture: &str,
637+
expect: Expect,
638+
) {
639+
let (analysis, file_id) = fixture::file(ra_fixture);
640+
let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
641+
inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
642+
if let Some(loc) = &mut hint.linked_location {
643+
loc.range = TextRange::empty(TextSize::from(0));
644+
}
645+
});
646+
expect.assert_debug_eq(&inlay_hints)
647+
}
648+
632649
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
633650
/// expect test.
634651
#[track_caller]

crates/ide/src/inlay_hints/chaining.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ mod tests {
7878
use expect_test::expect;
7979

8080
use crate::{
81-
inlay_hints::tests::{check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG},
81+
inlay_hints::tests::{
82+
check_expect, check_expect_clear_loc, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
83+
},
8284
InlayHintsConfig,
8385
};
8486

@@ -444,7 +446,7 @@ fn main() {
444446

445447
#[test]
446448
fn shorten_iterator_chaining_hints() {
447-
check_expect(
449+
check_expect_clear_loc(
448450
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
449451
r#"
450452
//- minicore: iterators
@@ -484,7 +486,7 @@ fn main() {
484486
file_id: FileId(
485487
1,
486488
),
487-
range: 10752..10760,
489+
range: 0..0,
488490
},
489491
),
490492
tooltip: "",
@@ -497,7 +499,7 @@ fn main() {
497499
file_id: FileId(
498500
1,
499501
),
500-
range: 10784..10788,
502+
range: 0..0,
501503
},
502504
),
503505
tooltip: "",
@@ -522,7 +524,7 @@ fn main() {
522524
file_id: FileId(
523525
1,
524526
),
525-
range: 10752..10760,
527+
range: 0..0,
526528
},
527529
),
528530
tooltip: "",
@@ -535,7 +537,7 @@ fn main() {
535537
file_id: FileId(
536538
1,
537539
),
538-
range: 10784..10788,
540+
range: 0..0,
539541
},
540542
),
541543
tooltip: "",
@@ -560,7 +562,7 @@ fn main() {
560562
file_id: FileId(
561563
1,
562564
),
563-
range: 10752..10760,
565+
range: 0..0,
564566
},
565567
),
566568
tooltip: "",
@@ -573,7 +575,7 @@ fn main() {
573575
file_id: FileId(
574576
1,
575577
),
576-
range: 10784..10788,
578+
range: 0..0,
577579
},
578580
),
579581
tooltip: "",
@@ -598,7 +600,7 @@ fn main() {
598600
file_id: FileId(
599601
0,
600602
),
601-
range: 24..30,
603+
range: 0..0,
602604
},
603605
),
604606
tooltip: "",

0 commit comments

Comments
 (0)