Skip to content

Commit a58441a

Browse files
committed
Make the tests for complete/incomplete for inlay hints work
1 parent 8ca214f commit a58441a

File tree

1 file changed

+77
-10
lines changed

1 file changed

+77
-10
lines changed

crates/ide/src/inlay_hints.rs

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -947,28 +947,95 @@ fn main() {
947947
);
948948
check(
949949
r#"
950+
//- /main.rs crate:main deps:core
951+
pub struct Vec<T> {}
952+
953+
impl<T> Vec<T> {
954+
pub fn new() -> Self { Vec {} }
955+
pub fn push(&mut self, t: T) {}
956+
}
957+
958+
impl<T> IntoIterator for Vec<T> {
959+
type Item=T;
960+
}
961+
950962
fn main() {
951-
let data = &[1i32, 2, 3];
952-
//^^^^ &[i32; _]
953-
for i in
963+
let mut data = Vec::new();
964+
//^^^^^^^^ Vec<&str>
965+
data.push("foo");
966+
for i in
954967
955968
println!("Unit expr");
956-
}"#,
969+
}
970+
971+
//- /core.rs crate:core
972+
#[prelude_import] use iter::*;
973+
mod iter {
974+
trait IntoIterator {
975+
type Item;
976+
}
977+
}
978+
//- /alloc.rs crate:alloc deps:core
979+
mod collections {
980+
struct Vec<T> {}
981+
impl<T> Vec<T> {
982+
fn new() -> Self { Vec {} }
983+
fn push(&mut self, t: T) { }
984+
}
985+
impl<T> IntoIterator for Vec<T> {
986+
type Item=T;
987+
}
988+
}
989+
"#,
957990
);
958991
}
959992

960993
#[test]
961994
fn complete_for_hint() {
962995
check(
963996
r#"
997+
//- /main.rs crate:main deps:core
998+
pub struct Vec<T> {}
999+
1000+
impl<T> Vec<T> {
1001+
pub fn new() -> Self { Vec {} }
1002+
pub fn push(&mut self, t: T) {}
1003+
}
1004+
1005+
impl<T> IntoIterator for Vec<T> {
1006+
type Item=T;
1007+
}
1008+
9641009
fn main() {
965-
let data = &[ 1, 2, 3 ];
966-
//^^^^ &[i32; _]
967-
for i in data.into_iter() {
968-
//^ &i32
969-
println!("{}", i);
1010+
let mut data = Vec::new();
1011+
//^^^^^^^^ Vec<&str>
1012+
data.push("foo");
1013+
for i in data {
1014+
//^ &str
1015+
let z = i;
1016+
//^ &str
9701017
}
971-
}"#,
1018+
}
1019+
1020+
//- /core.rs crate:core
1021+
#[prelude_import] use iter::*;
1022+
mod iter {
1023+
trait IntoIterator {
1024+
type Item;
1025+
}
1026+
}
1027+
//- /alloc.rs crate:alloc deps:core
1028+
mod collections {
1029+
struct Vec<T> {}
1030+
impl<T> Vec<T> {
1031+
fn new() -> Self { Vec {} }
1032+
fn push(&mut self, t: T) { }
1033+
}
1034+
impl<T> IntoIterator for Vec<T> {
1035+
type Item=T;
1036+
}
1037+
}
1038+
"#,
9721039
);
9731040
}
9741041
}

0 commit comments

Comments
 (0)