minor: use minicore
This commit is contained in:
parent
89a0e58393
commit
181184a350
@ -262,9 +262,7 @@ fn special_case_option() {
|
||||
check_assist(
|
||||
replace_if_let_with_match,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
//- minicore: option
|
||||
fn foo(x: Option<i32>) {
|
||||
$0if let Some(x) = x {
|
||||
println!("{}", x)
|
||||
@ -272,18 +270,15 @@ fn foo(x: Option<i32>) {
|
||||
println!("none")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
fn foo(x: Option<i32>) {
|
||||
match x {
|
||||
Some(x) => println!("{}", x),
|
||||
None => println!("none"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -292,9 +287,7 @@ fn special_case_inverted_option() {
|
||||
check_assist(
|
||||
replace_if_let_with_match,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
//- minicore: option
|
||||
fn foo(x: Option<i32>) {
|
||||
$0if let None = x {
|
||||
println!("none")
|
||||
@ -302,18 +295,15 @@ fn foo(x: Option<i32>) {
|
||||
println!("some")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
fn foo(x: Option<i32>) {
|
||||
match x {
|
||||
None => println!("none"),
|
||||
Some(_) => println!("some"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -322,9 +312,7 @@ fn special_case_result() {
|
||||
check_assist(
|
||||
replace_if_let_with_match,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
//- minicore: result
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
$0if let Ok(x) = x {
|
||||
println!("{}", x)
|
||||
@ -332,18 +320,15 @@ fn foo(x: Result<i32, ()>) {
|
||||
println!("none")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
match x {
|
||||
Ok(x) => println!("{}", x),
|
||||
Err(_) => println!("none"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -352,9 +337,7 @@ fn special_case_inverted_result() {
|
||||
check_assist(
|
||||
replace_if_let_with_match,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
//- minicore: result
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
$0if let Err(x) = x {
|
||||
println!("{}", x)
|
||||
@ -362,18 +345,15 @@ fn foo(x: Result<i32, ()>) {
|
||||
println!("ok")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
match x {
|
||||
Err(x) => println!("{}", x),
|
||||
Ok(_) => println!("ok"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -488,20 +468,15 @@ fn special_case_option_match_to_if_let() {
|
||||
check_assist(
|
||||
replace_match_with_if_let,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
//- minicore: option
|
||||
fn foo(x: Option<i32>) {
|
||||
$0match x {
|
||||
Some(x) => println!("{}", x),
|
||||
None => println!("none"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
|
||||
fn foo(x: Option<i32>) {
|
||||
if let Some(x) = x {
|
||||
println!("{}", x)
|
||||
@ -509,7 +484,7 @@ fn foo(x: Option<i32>) {
|
||||
println!("none")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -518,20 +493,15 @@ fn special_case_result_match_to_if_let() {
|
||||
check_assist(
|
||||
replace_match_with_if_let,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
//- minicore: result
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
$0match x {
|
||||
Ok(x) => println!("{}", x),
|
||||
Err(_) => println!("none"),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
r#"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
use Result::*;
|
||||
|
||||
fn foo(x: Result<i32, ()>) {
|
||||
if let Ok(x) = x {
|
||||
println!("{}", x)
|
||||
@ -539,7 +509,7 @@ fn foo(x: Result<i32, ()>) {
|
||||
println!("none")
|
||||
}
|
||||
}
|
||||
"#,
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -97,25 +97,24 @@ mod tests {
|
||||
fn test_replace_result_unwrap_with_match() {
|
||||
check_assist(
|
||||
replace_unwrap_with_match,
|
||||
r"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
r#"
|
||||
//- minicore: result
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x: Result<i32, i32> = Result::Ok(92);
|
||||
let x: Result<i32, i32> = Ok(92);
|
||||
let y = i(x).$0unwrap();
|
||||
}
|
||||
",
|
||||
r"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
"#,
|
||||
r#"
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x: Result<i32, i32> = Result::Ok(92);
|
||||
let x: Result<i32, i32> = Ok(92);
|
||||
let y = match i(x) {
|
||||
Ok(it) => it,
|
||||
$0_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
",
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
@ -123,25 +122,24 @@ fn main() {
|
||||
fn test_replace_option_unwrap_with_match() {
|
||||
check_assist(
|
||||
replace_unwrap_with_match,
|
||||
r"
|
||||
enum Option<T> { Some(T), None }
|
||||
r#"
|
||||
//- minicore: option
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x = Option::Some(92);
|
||||
let x = Some(92);
|
||||
let y = i(x).$0unwrap();
|
||||
}
|
||||
",
|
||||
r"
|
||||
enum Option<T> { Some(T), None }
|
||||
"#,
|
||||
r#"
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x = Option::Some(92);
|
||||
let x = Some(92);
|
||||
let y = match i(x) {
|
||||
Some(it) => it,
|
||||
$0_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
",
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
@ -149,25 +147,24 @@ fn main() {
|
||||
fn test_replace_result_unwrap_with_match_chaining() {
|
||||
check_assist(
|
||||
replace_unwrap_with_match,
|
||||
r"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
r#"
|
||||
//- minicore: result
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x: Result<i32, i32> = Result::Ok(92);
|
||||
let x: Result<i32, i32> = Ok(92);
|
||||
let y = i(x).$0unwrap().count_zeroes();
|
||||
}
|
||||
",
|
||||
r"
|
||||
enum Result<T, E> { Ok(T), Err(E) }
|
||||
"#,
|
||||
r#"
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x: Result<i32, i32> = Result::Ok(92);
|
||||
let x: Result<i32, i32> = Ok(92);
|
||||
let y = match i(x) {
|
||||
Ok(it) => it,
|
||||
$0_ => unreachable!(),
|
||||
}.count_zeroes();
|
||||
}
|
||||
",
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
@ -175,14 +172,14 @@ fn main() {
|
||||
fn replace_unwrap_with_match_target() {
|
||||
check_assist_target(
|
||||
replace_unwrap_with_match,
|
||||
r"
|
||||
enum Option<T> { Some(T), None }
|
||||
r#"
|
||||
//- minicore: option
|
||||
fn i<T>(a: T) -> T { a }
|
||||
fn main() {
|
||||
let x = Option::Some(92);
|
||||
let x = Some(92);
|
||||
let y = i(x).$0unwrap();
|
||||
}
|
||||
",
|
||||
"#,
|
||||
r"i(x).unwrap()",
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user