From a58441ad1b87b40ddfc175e5d2c3a4d38085ef0d Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 3 Oct 2020 08:37:58 +0300 Subject: [PATCH] Make the tests for complete/incomplete for inlay hints work --- crates/ide/src/inlay_hints.rs | 87 +++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 10 deletions(-) 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; + } +} +"#, ); } }