From e505752442f849c7d37465f0e0b6aa042644787b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Carlos=20Mour=C3=A3o=20Paes=20de=20Carvalho?= Date: Fri, 12 Mar 2021 08:53:57 -0300 Subject: fix: generated test fixture --- crates/ide_assists/src/tests/generated.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 304b5798f..af513ca22 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -205,6 +205,29 @@ const _: i32 = 0b1010; ) } +#[test] +fn doctest_convert_iter_for_each_to_for() { + check_doc_test( + "convert_iter_for_each_to_for", + r#####" +fn main() { + let vec = vec![(1, 2), (2, 3), (3, 4)]; + x.iter().for_each(|(x, y)| { + println!("x: {}, y: {}", x, y); + }); +} +"#####, + r#####" +fn main() { + let vec = vec![(1, 2), (2, 3), (3, 4)]; + for (x, y) in x.iter() { + println!("x: {}, y: {}", x, y); + } +} +"#####, + ) +} + #[test] fn doctest_convert_to_guarded_return() { check_doc_test( -- cgit v1.2.3 From 6d35c67b6e39fae1efc48405b49d408b86666534 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 12 Mar 2021 15:41:08 +0100 Subject: Fix convert_iter_for_each_to_for doctest --- crates/ide_assists/src/tests/generated.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index af513ca22..3f77edd8d 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -210,17 +210,24 @@ fn doctest_convert_iter_for_each_to_for() { check_doc_test( "convert_iter_for_each_to_for", r#####" +//- /lib.rs crate:core +pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } } +pub struct SomeIter; +impl self::iter::traits::iterator::Iterator for SomeIter {} +//- /lib.rs crate:main deps:core +use core::SomeIter; fn main() { - let vec = vec![(1, 2), (2, 3), (3, 4)]; - x.iter().for_each(|(x, y)| { + let iter = SomeIter; + iter.for_each$0(|(x, y)| { println!("x: {}, y: {}", x, y); }); } "#####, r#####" +use core::SomeIter; fn main() { - let vec = vec![(1, 2), (2, 3), (3, 4)]; - for (x, y) in x.iter() { + let iter = SomeIter; + for (x, y) in iter { println!("x: {}, y: {}", x, y); } } -- cgit v1.2.3