rust-analyzer/crates
bors 3b1b58c225 Auto merge of #15662 - rmehri01:fix_panic_with_return_in_match, r=Veykril
fix: panic with wrapping/unwrapping result return type assists

With the `wrap_return_type_in_result` assist, the following code results in a panic (note the lack of a semicolon):

```rust
fn foo(num: i32) -> $0i32 {
    return num
}

=>

thread 'handlers::wrap_return_type_in_result::tests::wrap_return_in_tail_position' panicked at crates/syntax/src/ted.rs:137:41:
called `Option::unwrap()` on a `None` value
```

I think this is because it first walks the body expression to change any `return` expressions and then walks all tail expressions, resulting in the `return num` being changed twice since it is both a `return` and in tail position. This can also happen when a `match` is in tail position and `return` is used in a branch for example. Not really sure how big of an issue this is in practice though since this seems to be the only case that is impacted and can be reduced to just `num` instead of `return num`.

This also occurs with the `unwrap_result_return_type` assist but panics with the following instead:

```
thread 'handlers::unwrap_result_return_type::tests::wrap_return_in_tail_position' panicked at /rustc/3223b0b5e8dadda3f76c3fd1a8d6c5addc09599e/library/alloc/src/string.rs:1766:29:
assertion failed: self.is_char_boundary(n)
```
2023-09-26 14:18:33 +00:00
..
base-db minor: hover_simple refactor 2023-09-24 22:47:29 +02:00
cfg Fix cfg completions not working 2023-09-08 10:49:15 +02:00
flycheck refactor: remove boxing 2023-09-20 23:02:52 +09:00
hir Add unused_variables native diagnostic 2023-09-24 21:29:15 +03:30
hir-def Auto merge of #15652 - Veykril:format_to, r=lnicola 2023-09-22 09:06:06 +00:00
hir-expand Emit builtin#format_args in builtin format_args expander 2023-09-06 18:08:20 +02:00
hir-ty Fix unused_variables in tests 2023-09-24 23:45:36 +03:30
ide Auto merge of #15659 - HKalbasi:unused-var, r=HKalbasi 2023-09-25 06:38:14 +00:00
ide-assists Auto merge of #15662 - rmehri01:fix_panic_with_return_in_match, r=Veykril 2023-09-26 14:18:33 +00:00
ide-completion split detail function 2023-09-23 19:43:19 -03:00
ide-db minor: hover_simple refactor 2023-09-24 22:47:29 +02:00
ide-diagnostics Fix unused_variables in tests 2023-09-24 23:45:36 +03:30
ide-ssr Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra 2023-08-21 12:44:09 +03:00
intern refactor: fix clippy lints 2023-09-15 16:43:21 +09:00
limit Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
load-cargo Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra 2023-07-17 16:49:15 +03:00
mbe Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra 2023-08-21 12:44:09 +03:00
parser Auto merge of #15615 - shogo-nakano-desu:refactor/fix-clippy-lints, r=Veykril 2023-09-22 06:46:29 +00:00
paths Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra 2023-07-17 16:49:15 +03:00
proc-macro-api Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
proc-macro-srv Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
proc-macro-srv-cli Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
proc-macro-test proc-macro-test: Pass target to cargo invocation 2023-08-02 17:57:13 -07:00
profile Merge commit '9b3d03408c66749d56466bb09baf2a7177deb6ce' into sync-from-ra 2023-08-21 12:44:09 +03:00
project-model Auto merge of #15560 - davidbarsky:davidbarsky/use-sysroot-rustc-to-determine-cfgs, r=Veykril 2023-09-08 18:14:25 +00:00
rust-analyzer Auto merge of #15582 - vxpm:master, r=HKalbasi 2023-09-24 07:38:38 +00:00
rustc-dependencies Switch to in-tree rustc dependencies with a cfg flag 2023-09-15 18:10:11 +03:30
sourcegen Merge commit '37f84c101bca43b11027f30ab0c2852f9325bc3d' into sync-from-ra 2023-07-17 16:49:15 +03:00
stdx Various small fixes 2023-09-22 10:13:51 +02:00
syntax Simplify 2023-09-26 12:25:59 +02:00
test-utils Fix unused_variables in tests 2023-09-24 23:45:36 +03:30
text-edit Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-from-ra 2023-06-05 12:04:23 +03:00
toolchain ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
tt Merge commit 'baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d' into sync-from-ra 2023-08-07 12:03:15 +03:00
vfs Ensure resolved hint's file exists 2023-09-02 18:28:36 +03:00
vfs-notify Update notify to 6.1.1 2023-09-04 18:00:12 +02:00