mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
fix tests
This commit is contained in:
parent
765d7f20f9
commit
1161fa45af
2 changed files with 21 additions and 11 deletions
|
@ -20,14 +20,19 @@ use crate::assist_context::{AssistContext, Assists};
|
|||
// Replaces a `try` expression with a `match` expression.
|
||||
//
|
||||
// ```
|
||||
// let pat = Some(true)$0?;
|
||||
// # //- minicore:option
|
||||
// fn handle() {
|
||||
// let pat = Some(true)$0?;
|
||||
// }
|
||||
// ```
|
||||
// ->
|
||||
// ```
|
||||
// let pat = match Some(true) {
|
||||
// Some(it) => it,
|
||||
// None => return None,
|
||||
// };
|
||||
// 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;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
|
|
@ -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) {
|
||||
Some(it) => it,
|
||||
None => return None,
|
||||
};
|
||||
fn handle() {
|
||||
let pat = match Some(true) {
|
||||
Some(it) => it,
|
||||
None => return None,
|
||||
};
|
||||
}
|
||||
"#####,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue