Make the tests for complete/incomplete for inlay hints work

This commit is contained in:
Igor Aleksanov 2020-10-03 08:37:58 +03:00
parent 8ca214fbfb
commit a58441ad1b

View File

@ -947,13 +947,46 @@ fn main() {
);
check(
r#"
//- /main.rs crate:main deps:core
pub struct Vec<T> {}
impl<T> Vec<T> {
pub fn new() -> Self { Vec {} }
pub fn push(&mut self, t: T) {}
}
impl<T> IntoIterator for Vec<T> {
type Item=T;
}
fn main() {
let data = &[1i32, 2, 3];
//^^^^ &[i32; _]
let mut data = Vec::new();
//^^^^^^^^ Vec<&str>
data.push("foo");
for i in
println!("Unit expr");
}"#,
}
//- /core.rs crate:core
#[prelude_import] use iter::*;
mod iter {
trait IntoIterator {
type Item;
}
}
//- /alloc.rs crate:alloc deps:core
mod collections {
struct Vec<T> {}
impl<T> Vec<T> {
fn new() -> Self { Vec {} }
fn push(&mut self, t: T) { }
}
impl<T> IntoIterator for Vec<T> {
type Item=T;
}
}
"#,
);
}
@ -961,14 +994,48 @@ fn main() {
fn complete_for_hint() {
check(
r#"
fn main() {
let data = &[ 1, 2, 3 ];
//^^^^ &[i32; _]
for i in data.into_iter() {
//^ &i32
println!("{}", i);
//- /main.rs crate:main deps:core
pub struct Vec<T> {}
impl<T> Vec<T> {
pub fn new() -> Self { Vec {} }
pub fn push(&mut self, t: T) {}
}
}"#,
impl<T> IntoIterator for Vec<T> {
type Item=T;
}
fn main() {
let mut data = Vec::new();
//^^^^^^^^ Vec<&str>
data.push("foo");
for i in data {
//^ &str
let z = i;
//^ &str
}
}
//- /core.rs crate:core
#[prelude_import] use iter::*;
mod iter {
trait IntoIterator {
type Item;
}
}
//- /alloc.rs crate:alloc deps:core
mod collections {
struct Vec<T> {}
impl<T> Vec<T> {
fn new() -> Self { Vec {} }
fn push(&mut self, t: T) { }
}
impl<T> IntoIterator for Vec<T> {
type Item=T;
}
}
"#,
);
}
}