mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Auto merge of #18294 - Giga-Bowser:master, r=Veykril
Add wrap/unwrap return type in Option I pretty much just copied over the code and tests for wrapping/unwrapping return types in `Result` and then did a bunch of find and replace changes. I handled unwrapping statements returning `None` by just replacing `None` with the unit type, but I'm open to suggestions for more intuitive behavior here.
This commit is contained in:
commit
546da8a5ad
6 changed files with 4718 additions and 2387 deletions
File diff suppressed because it is too large
Load diff
2229
crates/ide-assists/src/handlers/unwrap_return_type.rs
Normal file
2229
crates/ide-assists/src/handlers/unwrap_return_type.rs
Normal file
File diff suppressed because it is too large
Load diff
2457
crates/ide-assists/src/handlers/wrap_return_type.rs
Normal file
2457
crates/ide-assists/src/handlers/wrap_return_type.rs
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -223,9 +223,9 @@ mod handlers {
|
|||
mod unnecessary_async;
|
||||
mod unqualify_method_call;
|
||||
mod unwrap_block;
|
||||
mod unwrap_result_return_type;
|
||||
mod unwrap_return_type;
|
||||
mod unwrap_tuple;
|
||||
mod wrap_return_type_in_result;
|
||||
mod wrap_return_type;
|
||||
mod wrap_unwrap_cfg_attr;
|
||||
|
||||
pub(crate) fn all() -> &'static [Handler] {
|
||||
|
@ -355,10 +355,10 @@ mod handlers {
|
|||
unmerge_use::unmerge_use,
|
||||
unnecessary_async::unnecessary_async,
|
||||
unwrap_block::unwrap_block,
|
||||
unwrap_result_return_type::unwrap_result_return_type,
|
||||
unwrap_return_type::unwrap_return_type,
|
||||
unwrap_tuple::unwrap_tuple,
|
||||
unqualify_method_call::unqualify_method_call,
|
||||
wrap_return_type_in_result::wrap_return_type_in_result,
|
||||
wrap_return_type::wrap_return_type,
|
||||
wrap_unwrap_cfg_attr::wrap_unwrap_cfg_attr,
|
||||
|
||||
// These are manually sorted for better priorities. By default,
|
||||
|
|
|
@ -3264,6 +3264,20 @@ fn foo() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doctest_unwrap_option_return_type() {
|
||||
check_doc_test(
|
||||
"unwrap_option_return_type",
|
||||
r#####"
|
||||
//- minicore: option
|
||||
fn foo() -> Option<i32>$0 { Some(42i32) }
|
||||
"#####,
|
||||
r#####"
|
||||
fn foo() -> i32 { 42i32 }
|
||||
"#####,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doctest_unwrap_result_return_type() {
|
||||
check_doc_test(
|
||||
|
@ -3297,6 +3311,20 @@ fn main() {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doctest_wrap_return_type_in_option() {
|
||||
check_doc_test(
|
||||
"wrap_return_type_in_option",
|
||||
r#####"
|
||||
//- minicore: option
|
||||
fn foo() -> i32$0 { 42i32 }
|
||||
"#####,
|
||||
r#####"
|
||||
fn foo() -> Option<i32> { Some(42i32) }
|
||||
"#####,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doctest_wrap_return_type_in_result() {
|
||||
check_doc_test(
|
||||
|
|
Loading…
Reference in a new issue