Unnamed repository; edit this file 'description' to name the repository.
Fix inlay-hint tests being invalidated by minicore chanes
Lukas Wirth 2023-11-15
parent 6ddccc9 · commit d5faad1
-rw-r--r--crates/hir/src/lib.rs4
-rw-r--r--crates/ide/src/inlay_hints.rs17
-rw-r--r--crates/ide/src/inlay_hints/chaining.rs20
3 files changed, 32 insertions, 9 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index dfb0779f10..8d82e88da9 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -3403,6 +3403,10 @@ impl Impl {
db.impl_data(self.id).is_negative
}
+ pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
+ db.impl_data(self.id).is_unique()
+ }
+
pub fn module(self, db: &dyn HirDatabase) -> Module {
self.id.lookup(db.upcast()).container.into()
}
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index a5d070fe76..24f44ca06f 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -563,6 +563,7 @@ mod tests {
use hir::ClosureStyle;
use itertools::Itertools;
use test_utils::extract_annotations;
+ use text_edit::{TextRange, TextSize};
use crate::inlay_hints::{AdjustmentHints, AdjustmentHintsMode};
use crate::DiscriminantHints;
@@ -629,6 +630,22 @@ mod tests {
expect.assert_debug_eq(&inlay_hints)
}
+ #[track_caller]
+ pub(super) fn check_expect_clear_loc(
+ config: InlayHintsConfig,
+ ra_fixture: &str,
+ expect: Expect,
+ ) {
+ let (analysis, file_id) = fixture::file(ra_fixture);
+ let mut inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
+ inlay_hints.iter_mut().flat_map(|hint| &mut hint.label.parts).for_each(|hint| {
+ if let Some(loc) = &mut hint.linked_location {
+ loc.range = TextRange::empty(TextSize::from(0));
+ }
+ });
+ expect.assert_debug_eq(&inlay_hints)
+ }
+
/// Computes inlay hints for the fixture, applies all the provided text edits and then runs
/// expect test.
#[track_caller]
diff --git a/crates/ide/src/inlay_hints/chaining.rs b/crates/ide/src/inlay_hints/chaining.rs
index 4152e60675..c9e9a22378 100644
--- a/crates/ide/src/inlay_hints/chaining.rs
+++ b/crates/ide/src/inlay_hints/chaining.rs
@@ -78,7 +78,9 @@ mod tests {
use expect_test::expect;
use crate::{
- inlay_hints::tests::{check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG},
+ inlay_hints::tests::{
+ check_expect, check_expect_clear_loc, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
+ },
InlayHintsConfig,
};
@@ -444,7 +446,7 @@ fn main() {
#[test]
fn shorten_iterator_chaining_hints() {
- check_expect(
+ check_expect_clear_loc(
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
r#"
//- minicore: iterators
@@ -484,7 +486,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10752..10760,
+ range: 0..0,
},
),
tooltip: "",
@@ -497,7 +499,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10784..10788,
+ range: 0..0,
},
),
tooltip: "",
@@ -522,7 +524,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10752..10760,
+ range: 0..0,
},
),
tooltip: "",
@@ -535,7 +537,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10784..10788,
+ range: 0..0,
},
),
tooltip: "",
@@ -560,7 +562,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10752..10760,
+ range: 0..0,
},
),
tooltip: "",
@@ -573,7 +575,7 @@ fn main() {
file_id: FileId(
1,
),
- range: 10784..10788,
+ range: 0..0,
},
),
tooltip: "",
@@ -598,7 +600,7 @@ fn main() {
file_id: FileId(
0,
),
- range: 24..30,
+ range: 0..0,
},
),
tooltip: "",