fix tests

This commit is contained in:
crauzer 2021-10-06 20:45:18 +02:00
parent 765d7f20f9
commit 1161fa45af
2 changed files with 21 additions and 11 deletions

View file

@ -20,14 +20,19 @@ use crate::assist_context::{AssistContext, Assists};
// Replaces a `try` expression with a `match` expression.
//
// ```
// # //- minicore:option
// fn handle() {
// let pat = Some(true)$0?;
// }
// ```
// ->
// ```
// fn handle() {
// let pat = match Some(true) {
// Some(it) => it,
// None => return None,
// };
// }
// ```
pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
let qm_kw = ctx.find_token_syntax_at_offset(T![?])?;
@ -93,7 +98,7 @@ mod tests {
replace_try_expr_with_match,
r#"
fn test() {
let pat = 25$0;
let pat: u32 = 25$0;
}
"#,
);

View file

@ -1725,13 +1725,18 @@ fn doctest_replace_try_expr_with_match() {
check_doc_test(
"replace_try_expr_with_match",
r#####"
let pat = Some(true)$0?;
//- minicore:option
fn handle() {
let pat = Some(true)$0?;
}
"#####,
r#####"
let pat = match Some(true) {
fn handle() {
let pat = match Some(true) {
Some(it) => it,
None => return None,
};
};
}
"#####,
)
}