mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 07:48:45 +00:00
Fix inlay-hint tests
This commit is contained in:
parent
199bc82ce8
commit
0ce06088f8
2 changed files with 18 additions and 111 deletions
|
@ -176,15 +176,12 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &hir
|
||||||
mod tests {
|
mod tests {
|
||||||
// This module also contains tests for super::closure_ret
|
// This module also contains tests for super::closure_ret
|
||||||
|
|
||||||
use expect_test::expect;
|
|
||||||
use syntax::{TextRange, TextSize};
|
use syntax::{TextRange, TextSize};
|
||||||
use test_utils::extract_annotations;
|
use test_utils::extract_annotations;
|
||||||
|
|
||||||
use crate::{fixture, inlay_hints::InlayHintsConfig};
|
use crate::{fixture, inlay_hints::InlayHintsConfig};
|
||||||
|
|
||||||
use crate::inlay_hints::tests::{
|
use crate::inlay_hints::tests::{check, check_with_config, DISABLED_CONFIG, TEST_CONFIG};
|
||||||
check, check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
|
|
||||||
};
|
|
||||||
use crate::ClosureReturnTypeHints;
|
use crate::ClosureReturnTypeHints;
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -278,8 +275,7 @@ fn main() {
|
||||||
#[test]
|
#[test]
|
||||||
fn iterator_hint_regression_issue_12674() {
|
fn iterator_hint_regression_issue_12674() {
|
||||||
// Ensure we don't crash while solving the projection type of iterators.
|
// Ensure we don't crash while solving the projection type of iterators.
|
||||||
check_expect(
|
let (analysis, file_id) = fixture::file(
|
||||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
|
||||||
r#"
|
r#"
|
||||||
//- minicore: iterators
|
//- minicore: iterators
|
||||||
struct S<T>(T);
|
struct S<T>(T);
|
||||||
|
@ -305,104 +301,15 @@ fn main(a: SliceIter<'_, Container>) {
|
||||||
.filter_map(|c| Some(c.elements.iter().filter_map(|v| Some(v))))
|
.filter_map(|c| Some(c.elements.iter().filter_map(|v| Some(v))))
|
||||||
.map(|e| e);
|
.map(|e| e);
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
|
||||||
[
|
|
||||||
InlayHint {
|
|
||||||
range: 484..554,
|
|
||||||
kind: Chaining,
|
|
||||||
label: [
|
|
||||||
"impl ",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "Iterator",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
range: 2611..2619,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
"<",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "Item",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
range: 2643..2647,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
" = impl ",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "Iterator",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
range: 2611..2619,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
"<",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "Item",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
range: 2643..2647,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
" = &&str>>",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
InlayHint {
|
|
||||||
range: 484..485,
|
|
||||||
kind: Chaining,
|
|
||||||
label: [
|
|
||||||
"",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "SliceIter",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
range: 289..298,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
"<",
|
|
||||||
InlayHintLabelPart {
|
|
||||||
text: "Container",
|
|
||||||
linked_location: Some(
|
|
||||||
FileRange {
|
|
||||||
file_id: FileId(
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
range: 238..247,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
tooltip: "",
|
|
||||||
},
|
|
||||||
">",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
"#]],
|
|
||||||
);
|
);
|
||||||
|
analysis
|
||||||
|
.inlay_hints(
|
||||||
|
&InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
||||||
|
file_id,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -435,7 +435,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2611..2619,
|
range: 3386..3394,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -448,7 +448,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2643..2647,
|
range: 3418..3422,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -468,7 +468,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2611..2619,
|
range: 3386..3394,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -481,7 +481,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2643..2647,
|
range: 3418..3422,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -501,7 +501,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2611..2619,
|
range: 3386..3394,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
@ -514,7 +514,7 @@ fn main() {
|
||||||
file_id: FileId(
|
file_id: FileId(
|
||||||
1,
|
1,
|
||||||
),
|
),
|
||||||
range: 2643..2647,
|
range: 3418..3422,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltip: "",
|
tooltip: "",
|
||||||
|
|
Loading…
Reference in a new issue