diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 60dc74d4178..b1fe3383636 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -947,13 +947,46 @@ fn main() { ); check( r#" +//- /main.rs crate:main deps:core +pub struct Vec {} + +impl Vec { + pub fn new() -> Self { Vec {} } + pub fn push(&mut self, t: T) {} +} + +impl IntoIterator for Vec { + type Item=T; +} + fn main() { - let data = &[1i32, 2, 3]; - //^^^^ &[i32; _] - for i in + 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 {} + impl Vec { + fn new() -> Self { Vec {} } + fn push(&mut self, t: T) { } + } + impl IntoIterator for Vec { + type Item=T; + } +} +"#, ); } @@ -961,14 +994,48 @@ fn main() { fn complete_for_hint() { check( r#" +//- /main.rs crate:main deps:core +pub struct Vec {} + +impl Vec { + pub fn new() -> Self { Vec {} } + pub fn push(&mut self, t: T) {} +} + +impl IntoIterator for Vec { + type Item=T; +} + fn main() { - let data = &[ 1, 2, 3 ]; - //^^^^ &[i32; _] - for i in data.into_iter() { - //^ &i32 - println!("{}", i); + 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 {} + impl Vec { + fn new() -> Self { Vec {} } + fn push(&mut self, t: T) { } + } + impl IntoIterator for Vec { + type Item=T; + } +} +"#, ); } }