From 3762cc7465e485948b426857b265f274688dedea Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 18 Jun 2021 23:56:15 +0300 Subject: minor: use minicore --- .../src/handlers/convert_into_to_from.rs | 6 +---- .../src/handlers/convert_iter_for_each_to_for.rs | 14 ++++------- .../src/handlers/replace_unwrap_with_match.rs | 7 +++--- crates/ide_assists/src/tests/generated.rs | 27 ++++++++-------------- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/crates/ide_assists/src/handlers/convert_into_to_from.rs b/crates/ide_assists/src/handlers/convert_into_to_from.rs index 79a0c4879..2d8b936cd 100644 --- a/crates/ide_assists/src/handlers/convert_into_to_from.rs +++ b/crates/ide_assists/src/handlers/convert_into_to_from.rs @@ -13,10 +13,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // Converts an Into impl to an equivalent From impl. // // ``` -// # //- /lib.rs crate:core -// # pub mod convert { pub trait Into { pub fn into(self) -> T; } } -// # //- /lib.rs crate:main deps:core -// # use core::convert::Into; +// # //- minicore: from // impl $0Into for usize { // fn into(self) -> Thing { // Thing { @@ -28,7 +25,6 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // ``` // -> // ``` -// # use core::convert::Into; // impl From for Thing { // fn from(val: usize) -> Self { // Thing { diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs index 7fd73d4c7..70754adf9 100644 --- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs +++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs @@ -11,14 +11,10 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // Converts an Iterator::for_each function into a for loop. // // ``` -// # //- /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; +// # //- minicore: iterators +// # use core::iter; // fn main() { -// let iter = SomeIter; +// let iter = iter::repeat((9, 2)); // iter.for_each$0(|(x, y)| { // println!("x: {}, y: {}", x, y); // }); @@ -26,9 +22,9 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // ``` // -> // ``` -// # use core::SomeIter; +// # use core::iter; // fn main() { -// let iter = SomeIter; +// let iter = iter::repeat((9, 2)); // for (x, y) in iter { // println!("x: {}, y: {}", x, y); // } diff --git a/crates/ide_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ide_assists/src/handlers/replace_unwrap_with_match.rs index 7e57353c6..f39c48d8f 100644 --- a/crates/ide_assists/src/handlers/replace_unwrap_with_match.rs +++ b/crates/ide_assists/src/handlers/replace_unwrap_with_match.rs @@ -20,17 +20,16 @@ use ide_db::ty_filter::TryEnum; // Replaces `unwrap` with a `match` expression. Works for Result and Option. // // ``` -// enum Result { Ok(T), Err(E) } +// # //- minicore: result // fn main() { -// let x: Result = Result::Ok(92); +// let x: Result = Ok(92); // let y = x.$0unwrap(); // } // ``` // -> // ``` -// enum Result { Ok(T), Err(E) } // fn main() { -// let x: Result = Result::Ok(92); +// let x: Result = Ok(92); // let y = match x { // Ok(it) => it, // $0_ => unreachable!(), diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index de5d9e55a..1509c3c63 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -209,10 +209,7 @@ fn doctest_convert_into_to_from() { check_doc_test( "convert_into_to_from", r#####" -//- /lib.rs crate:core -pub mod convert { pub trait Into { pub fn into(self) -> T; } } -//- /lib.rs crate:main deps:core -use core::convert::Into; +//- minicore: from impl $0Into for usize { fn into(self) -> Thing { Thing { @@ -223,7 +220,6 @@ impl $0Into for usize { } "#####, r#####" -use core::convert::Into; impl From for Thing { fn from(val: usize) -> Self { Thing { @@ -241,23 +237,19 @@ 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; +//- minicore: iterators +use core::iter; fn main() { - let iter = SomeIter; + let iter = iter::repeat((9, 2)); iter.for_each$0(|(x, y)| { println!("x: {}, y: {}", x, y); }); } "#####, r#####" -use core::SomeIter; +use core::iter; fn main() { - let iter = SomeIter; + let iter = iter::repeat((9, 2)); for (x, y) in iter { println!("x: {}, y: {}", x, y); } @@ -1519,16 +1511,15 @@ fn doctest_replace_unwrap_with_match() { check_doc_test( "replace_unwrap_with_match", r#####" -enum Result { Ok(T), Err(E) } +//- minicore: result fn main() { - let x: Result = Result::Ok(92); + let x: Result = Ok(92); let y = x.$0unwrap(); } "#####, r#####" -enum Result { Ok(T), Err(E) } fn main() { - let x: Result = Result::Ok(92); + let x: Result = Ok(92); let y = match x { Ok(it) => it, $0_ => unreachable!(), -- cgit v1.2.3