aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-06-17 09:30:08 +0100
committerGitHub <[email protected]>2021-06-17 09:30:08 +0100
commitb5830fbf9222b9a83309dc61fe1df480b0c3b153 (patch)
treeb927b06a3f866f6ebac907d7714fa05af7422d4e /crates/ide_assists/src
parent7b4f5c0262bbdf7e9db81734eb9c82dd04eb82cb (diff)
parentc42cdff3d2ed2e30add09dd0d602181b6f83534d (diff)
Merge #9306
9306: internal: minimize minicore r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs78
1 files changed, 25 insertions, 53 deletions
diff --git a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
index 8e571723d..5f2aa016f 100644
--- a/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
+++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs
@@ -186,18 +186,14 @@ fn main() {
186 fn test_for_borrowed() { 186 fn test_for_borrowed() {
187 check_assist( 187 check_assist(
188 replace_for_loop_with_for_each, 188 replace_for_loop_with_for_each,
189 r" 189 r#"
190//- minicore: iterator 190//- minicore: iterators
191struct Iter; 191use core::iter::{Repeat, repeat};
192impl Iterator for Iter {
193 type Item = usize;
194 fn next(&mut self) -> Option<Self::Item> { None }
195}
196 192
197struct S; 193struct S;
198impl S { 194impl S {
199 fn iter(&self) -> Iter { Iter } 195 fn iter(&self) -> Repeat<i32> { repeat(92) }
200 fn iter_mut(&mut self) -> Iter { Iter } 196 fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) }
201} 197}
202 198
203fn main() { 199fn main() {
@@ -206,18 +202,14 @@ fn main() {
206 let a = v * 2; 202 let a = v * 2;
207 } 203 }
208} 204}
209", 205"#,
210 r" 206 r#"
211struct Iter; 207use core::iter::{Repeat, repeat};
212impl Iterator for Iter {
213 type Item = usize;
214 fn next(&mut self) -> Option<Self::Item> { None }
215}
216 208
217struct S; 209struct S;
218impl S { 210impl S {
219 fn iter(&self) -> Iter { Iter } 211 fn iter(&self) -> Repeat<i32> { repeat(92) }
220 fn iter_mut(&mut self) -> Iter { Iter } 212 fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) }
221} 213}
222 214
223fn main() { 215fn main() {
@@ -226,7 +218,7 @@ fn main() {
226 let a = v * 2; 218 let a = v * 2;
227 }); 219 });
228} 220}
229", 221"#,
230 ) 222 )
231 } 223 }
232 224
@@ -259,18 +251,14 @@ fn main() {
259 fn test_for_borrowed_mut() { 251 fn test_for_borrowed_mut() {
260 check_assist( 252 check_assist(
261 replace_for_loop_with_for_each, 253 replace_for_loop_with_for_each,
262 r" 254 r#"
263//- minicore: iterator 255//- minicore: iterators
264struct Iter; 256use core::iter::{Repeat, repeat};
265impl Iterator for Iter {
266 type Item = usize;
267 fn next(&mut self) -> Option<Self::Item> { None }
268}
269 257
270struct S; 258struct S;
271impl S { 259impl S {
272 fn iter(&self) -> Iter { Iter } 260 fn iter(&self) -> Repeat<i32> { repeat(92) }
273 fn iter_mut(&mut self) -> Iter { Iter } 261 fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) }
274} 262}
275 263
276fn main() { 264fn main() {
@@ -279,18 +267,14 @@ fn main() {
279 let a = v * 2; 267 let a = v * 2;
280 } 268 }
281} 269}
282", 270"#,
283 r" 271 r#"
284struct Iter; 272use core::iter::{Repeat, repeat};
285impl Iterator for Iter {
286 type Item = usize;
287 fn next(&mut self) -> Option<Self::Item> { None }
288}
289 273
290struct S; 274struct S;
291impl S { 275impl S {
292 fn iter(&self) -> Iter { Iter } 276 fn iter(&self) -> Repeat<i32> { repeat(92) }
293 fn iter_mut(&mut self) -> Iter { Iter } 277 fn iter_mut(&mut self) -> Repeat<i32> { repeat(92) }
294} 278}
295 279
296fn main() { 280fn main() {
@@ -299,7 +283,7 @@ fn main() {
299 let a = v * 2; 283 let a = v * 2;
300 }); 284 });
301} 285}
302", 286"#,
303 ) 287 )
304 } 288 }
305 289
@@ -332,28 +316,16 @@ fn main() {
332 check_assist( 316 check_assist(
333 replace_for_loop_with_for_each, 317 replace_for_loop_with_for_each,
334 r#" 318 r#"
335//- minicore: iterator 319//- minicore: iterators
336struct Iter;
337impl Iterator for Iter {
338 type Item = usize;
339 fn next(&mut self) -> Option<Self::Item> { None }
340}
341
342fn main() { 320fn main() {
343 for$0 a in Iter.take(1) { 321 for$0 a in core::iter::repeat(92).take(1) {
344 println!("{}", a); 322 println!("{}", a);
345 } 323 }
346} 324}
347"#, 325"#,
348 r#" 326 r#"
349struct Iter;
350impl Iterator for Iter {
351 type Item = usize;
352 fn next(&mut self) -> Option<Self::Item> { None }
353}
354
355fn main() { 327fn main() {
356 Iter.take(1).for_each(|a| { 328 core::iter::repeat(92).take(1).for_each(|a| {
357 println!("{}", a); 329 println!("{}", a);
358 }); 330 });
359} 331}