From 78d6b88f211cc9faf88815ce7fb1a91546cfce15 Mon Sep 17 00:00:00 2001 From: Jade Date: Fri, 14 May 2021 00:59:30 -0700 Subject: Add more tests, refactor array lengths/consteval work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #2922: add unknown length as a condition for a type having unknown. Incorporate reviews: * Extract some of the const evaluation workings into functions * Add fixmes on the hacks * Add tests for impls on specific array lengths (these work!!! 😁) * Add tests for const generics (indeed we don't support it yet) --- .../ide_assists/src/handlers/add_explicit_type.rs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/ide_assists/src') diff --git a/crates/ide_assists/src/handlers/add_explicit_type.rs b/crates/ide_assists/src/handlers/add_explicit_type.rs index 62db31952..36589203d 100644 --- a/crates/ide_assists/src/handlers/add_explicit_type.rs +++ b/crates/ide_assists/src/handlers/add_explicit_type.rs @@ -198,6 +198,34 @@ fn main() { ) } + /// https://github.com/rust-analyzer/rust-analyzer/issues/2922 + #[test] + fn regression_issue_2922() { + check_assist( + add_explicit_type, + r#" +fn main() { + let $0v = [0.0; 2]; +} +"#, + r#" +fn main() { + let v: [f64; 2] = [0.0; 2]; +} +"#, + ); + // note: this may break later if we add more consteval. it just needs to be something that our + // consteval engine doesn't understand + check_assist_not_applicable( + add_explicit_type, + r#" +fn main() { + let $0l = [0.0; 2+2]; +} +"#, + ); + } + #[test] fn default_generics_should_not_be_added() { check_assist( -- cgit v1.2.3