Skip to content

Commit 3762cc7

Browse files
committed
minor: use minicore
1 parent 90da9fc commit 3762cc7

File tree

4 files changed

+18
-36
lines changed

4 files changed

+18
-36
lines changed

crates/ide_assists/src/handlers/convert_into_to_from.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
1313
// Converts an Into impl to an equivalent From impl.
1414
//
1515
// ```
16-
// # //- /lib.rs crate:core
17-
// # pub mod convert { pub trait Into<T> { pub fn into(self) -> T; } }
18-
// # //- /lib.rs crate:main deps:core
19-
// # use core::convert::Into;
16+
// # //- minicore: from
2017
// impl $0Into<Thing> for usize {
2118
// fn into(self) -> Thing {
2219
// Thing {
@@ -28,7 +25,6 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
2825
// ```
2926
// ->
3027
// ```
31-
// # use core::convert::Into;
3228
// impl From<usize> for Thing {
3329
// fn from(val: usize) -> Self {
3430
// Thing {

crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,20 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
1111
// Converts an Iterator::for_each function into a for loop.
1212
//
1313
// ```
14-
// # //- /lib.rs crate:core
15-
// # pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
16-
// # pub struct SomeIter;
17-
// # impl self::iter::traits::iterator::Iterator for SomeIter {}
18-
// # //- /lib.rs crate:main deps:core
19-
// # use core::SomeIter;
14+
// # //- minicore: iterators
15+
// # use core::iter;
2016
// fn main() {
21-
// let iter = SomeIter;
17+
// let iter = iter::repeat((9, 2));
2218
// iter.for_each$0(|(x, y)| {
2319
// println!("x: {}, y: {}", x, y);
2420
// });
2521
// }
2622
// ```
2723
// ->
2824
// ```
29-
// # use core::SomeIter;
25+
// # use core::iter;
3026
// fn main() {
31-
// let iter = SomeIter;
27+
// let iter = iter::repeat((9, 2));
3228
// for (x, y) in iter {
3329
// println!("x: {}, y: {}", x, y);
3430
// }

crates/ide_assists/src/handlers/replace_unwrap_with_match.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ use ide_db::ty_filter::TryEnum;
2020
// Replaces `unwrap` with a `match` expression. Works for Result and Option.
2121
//
2222
// ```
23-
// enum Result<T, E> { Ok(T), Err(E) }
23+
// # //- minicore: result
2424
// fn main() {
25-
// let x: Result<i32, i32> = Result::Ok(92);
25+
// let x: Result<i32, i32> = Ok(92);
2626
// let y = x.$0unwrap();
2727
// }
2828
// ```
2929
// ->
3030
// ```
31-
// enum Result<T, E> { Ok(T), Err(E) }
3231
// fn main() {
33-
// let x: Result<i32, i32> = Result::Ok(92);
32+
// let x: Result<i32, i32> = Ok(92);
3433
// let y = match x {
3534
// Ok(it) => it,
3635
// $0_ => unreachable!(),

crates/ide_assists/src/tests/generated.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,7 @@ fn doctest_convert_into_to_from() {
209209
check_doc_test(
210210
"convert_into_to_from",
211211
r#####"
212-
//- /lib.rs crate:core
213-
pub mod convert { pub trait Into<T> { pub fn into(self) -> T; } }
214-
//- /lib.rs crate:main deps:core
215-
use core::convert::Into;
212+
//- minicore: from
216213
impl $0Into<Thing> for usize {
217214
fn into(self) -> Thing {
218215
Thing {
@@ -223,7 +220,6 @@ impl $0Into<Thing> for usize {
223220
}
224221
"#####,
225222
r#####"
226-
use core::convert::Into;
227223
impl From<usize> for Thing {
228224
fn from(val: usize) -> Self {
229225
Thing {
@@ -241,23 +237,19 @@ fn doctest_convert_iter_for_each_to_for() {
241237
check_doc_test(
242238
"convert_iter_for_each_to_for",
243239
r#####"
244-
//- /lib.rs crate:core
245-
pub mod iter { pub mod traits { pub mod iterator { pub trait Iterator {} } } }
246-
pub struct SomeIter;
247-
impl self::iter::traits::iterator::Iterator for SomeIter {}
248-
//- /lib.rs crate:main deps:core
249-
use core::SomeIter;
240+
//- minicore: iterators
241+
use core::iter;
250242
fn main() {
251-
let iter = SomeIter;
243+
let iter = iter::repeat((9, 2));
252244
iter.for_each$0(|(x, y)| {
253245
println!("x: {}, y: {}", x, y);
254246
});
255247
}
256248
"#####,
257249
r#####"
258-
use core::SomeIter;
250+
use core::iter;
259251
fn main() {
260-
let iter = SomeIter;
252+
let iter = iter::repeat((9, 2));
261253
for (x, y) in iter {
262254
println!("x: {}, y: {}", x, y);
263255
}
@@ -1519,16 +1511,15 @@ fn doctest_replace_unwrap_with_match() {
15191511
check_doc_test(
15201512
"replace_unwrap_with_match",
15211513
r#####"
1522-
enum Result<T, E> { Ok(T), Err(E) }
1514+
//- minicore: result
15231515
fn main() {
1524-
let x: Result<i32, i32> = Result::Ok(92);
1516+
let x: Result<i32, i32> = Ok(92);
15251517
let y = x.$0unwrap();
15261518
}
15271519
"#####,
15281520
r#####"
1529-
enum Result<T, E> { Ok(T), Err(E) }
15301521
fn main() {
1531-
let x: Result<i32, i32> = Result::Ok(92);
1522+
let x: Result<i32, i32> = Ok(92);
15321523
let y = match x {
15331524
Ok(it) => it,
15341525
$0_ => unreachable!(),

0 commit comments

Comments
 (0)