mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +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.
|
// Replaces a `try` expression with a `match` expression.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
|
// # //- minicore:option
|
||||||
|
// fn handle() {
|
||||||
// let pat = Some(true)$0?;
|
// let pat = Some(true)$0?;
|
||||||
|
// }
|
||||||
// ```
|
// ```
|
||||||
// ->
|
// ->
|
||||||
// ```
|
// ```
|
||||||
|
// fn handle() {
|
||||||
// let pat = match Some(true) {
|
// let pat = match Some(true) {
|
||||||
// Some(it) => it,
|
// Some(it) => it,
|
||||||
// None => return None,
|
// None => return None,
|
||||||
// };
|
// };
|
||||||
|
// }
|
||||||
// ```
|
// ```
|
||||||
pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
pub(crate) fn replace_try_expr_with_match(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
|
||||||
let qm_kw = ctx.find_token_syntax_at_offset(T![?])?;
|
let qm_kw = ctx.find_token_syntax_at_offset(T![?])?;
|
||||||
|
@ -93,7 +98,7 @@ mod tests {
|
||||||
replace_try_expr_with_match,
|
replace_try_expr_with_match,
|
||||||
r#"
|
r#"
|
||||||
fn test() {
|
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(
|
check_doc_test(
|
||||||
"replace_try_expr_with_match",
|
"replace_try_expr_with_match",
|
||||||
r#####"
|
r#####"
|
||||||
let pat = Some(true)$0?;
|
//- minicore:option
|
||||||
|
fn handle() {
|
||||||
|
let pat = Some(true)$0?;
|
||||||
|
}
|
||||||
"#####,
|
"#####,
|
||||||
r#####"
|
r#####"
|
||||||
let pat = match Some(true) {
|
fn handle() {
|
||||||
|
let pat = match Some(true) {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
"#####,
|
"#####,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue