Commit graph

16166 commits

Author SHA1 Message Date
Lukas Wirth
8ad4a1d118 Update sysroot crates 2022-11-07 12:01:12 +01:00
bors
25b1d6f3f9 Auto merge of #13435 - DropDemBits:assists-format-args-capture-pt3, r=Veykril
Migrate assists to format args captures, part 3

Continuation of https://github.com/rust-lang/rust-analyzer/pull/13379

Migrates:

- `inline_call`
- `inline_local_variable`
- `introduce_named_lifetime`
- `merge_match_arms`
- `move_from_mod_rs`
- `move_guard`
- `move_module_to_file`
- `move_to_mod_rs`
- `number_representation`
- `qualify_method_call`
- `qualify_path`
- `raw_string`
- `remove_dbg`
- `replace_derive_with_manual_impl`
- `replace_or_with_or_else`
- `replace_turbofish_with_explicit_type`
- `unwrap_tuple`
- `wrap_return_type_in_result`
2022-11-05 12:41:23 +00:00
bors
afe8f6b922 Auto merge of #13379 - DropDemBits:ide-assists-format-args-capture, r=Veykril
internal: Migrate `ide_assists::utils` and `ide_assists::handlers` to use format arg captures (part 1)

This not only serves as making future migration to mutable syntax trees easier, it also finds out what needs to be migrated in the first place.

~~Aside from the first commit, subsequent commits are structured to only deal with one file/handler at a time.~~

This is the first of 3 PRs, migrating:

Utils:

- `gen_trait_fn_body`
- `render_snippet`
- `ReferenceConversion`
  - `convert_type`
  - `getter`

Handlers:

- `add_explicit_type`
- `add_return_type`
- `add_turbo_fish`
- `apply_demorgan`
- `auto_import`
- `convert_comment_block`
- `convert_integer_literal`
- `convert_into_to_from`
- `convert_iter_for_each_to_for`
- `convert_let_else_to_match`
- `convert_tuple_struct_to_named_struct`
- `convert_two_arm_bool_match_to_matches_macro`
- `destructure_tuple_binding`
- `extract_function`
- `extract_module`
- `extract_struct_from_enum_variant`
- `extract_type_alias`
- `extract_variable`
- `fix_visibility`
2022-11-05 12:29:06 +00:00
bors
2c37e7d4af Auto merge of #13549 - Veykril:search-fix, r=Veykril
fix: Fix reference searching only accounting substrings instead of whole identifiers

Fixes https://github.com/rust-lang/rust-analyzer/issues/13498
2022-11-05 12:16:18 +00:00
Lukas Wirth
17619de711 fix: Fix reference searching only accounting substrings instead of whole identifiers 2022-11-05 13:00:02 +01:00
bors
df3877037e Auto merge of #13454 - justinmmott:master, r=flodiebold
Fixed local shadowing the caller's argument issue

fix https://github.com/rust-lang/rust-analyzer/issues/12536
2022-11-05 10:05:52 +00:00
bors
cd2603299c Auto merge of #13546 - Veykril:unsafe-fn-ptr, r=Veykril
Lower unsafety of fn pointer and fn item types
2022-11-04 20:29:16 +00:00
Lukas Wirth
6f09c72b1b Lower unsafety of fn pointer and fn item types 2022-11-04 21:07:15 +01:00
bors
bbcb77ea6f Auto merge of #13456 - emilio:scip-local-symbol, r=Veykril
scip: Generate symbols for local crates.

Consider something like:

```
// a.rs
pub struct Foo { .. } // Foo is "local 1"

fn something() {
    crate:🅱️:Bar::new() // Bar is "local 1", but of "b.rs"
}

// b.rs
pub struct Bar { .. } // "local 1"
```

Without this there's no way to disambiguate whether "local 1" references "Bar" or "Foo".
2022-11-03 13:58:36 +00:00
bors
6c3ab563de Auto merge of #13527 - unexge:use-let-else-stmt-in-convert-to-guarded-return-assist, r=jonas-schievink
Use let-else statements in `Convert to guarded return` assist

Follow up for https://github.com/rust-lang/rust-analyzer/pull/13516, addresses remaining part of https://github.com/rust-lang/rust-analyzer/issues/13254#issuecomment-1250408527
2022-11-02 11:06:54 +00:00
bors
af1f48deab Auto merge of #13359 - feniljain:feat-must-use-option, r=Veykril
feat: add config for inserting must_use in `generate_enum_as_method`

Should fix #13312

Didn't add a test because I was not sure on how to add test for a specific configuration option, tried to look for the usages for other `AssistConfig` variants but couldn't find any in `tests`. If there is a way to test this, do point me towards it.

I tried to extract the formatting string as a common `template_string` and only have if-else for that, but it didn't compile :(

Also it seems these tests are failing:

```
test config::tests::generate_config_documentation ... FAILED
test config::tests::generate_package_json_config ... FAILED
```

Can you also point me to how to correct these 😅  ( I guess there is some command to automatically generate these? )
2022-11-02 10:50:08 +00:00
feniljain
691ce306df
fix: indentation after inserting #must_use
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-11-02 16:09:12 +05:30
bors
12ced8f9db Auto merge of #13517 - feniljain:fix_completions, r=Veykril
fix: make custom expr prefix completions to understand refs

Possible fix of #7929

While reviewing the postfix completion code I saw that while calling `add_custom_postfix_completions` we were doing it under the part where reference was not taken into consideration, but as we are only adding postfix completions with `Expr` scope ( [source](ba28e19b78/crates/ide-completion/src/completions/postfix.rs (L272)) )

I shifted the `add_custom_postfix_completions` call to part where references are considered

I am not sure if this is the correct fix or I am understanding the problem exactly but this small move seemed to have fixed the issue :)
2022-11-02 10:15:18 +00:00
unexge
62a6cdfe46 Use let-else statements in Convert to guarded return assist 2022-11-01 23:02:10 +00:00
bors
c1305fa5d9 Auto merge of #13525 - jonas-schievink:generic-call-signature, r=jonas-schievink
feat: show signature help when calling generic types implementing `FnOnce`

This queries chalk for the `FnOnce` impl of callees and takes argument and return types from there, making generic `Callable`s available to the IDE. This makes signature help work for them, and potentially allows other features to take generic callables into account in the future.
2022-11-01 17:01:07 +00:00
bors
a8e97bcf3c Auto merge of #13508 - koka831:fix/13492, r=jonas-schievink
fix: async trait method for `unnecessary_async`

Fix https://github.com/rust-lang/rust-analyzer/issues/13492
2022-11-01 16:38:40 +00:00
bors
d90cb1e772 Auto merge of #13516 - unexge:add-convert-match-to-let-else-assist, r=jonas-schievink
Add `Convert match to let-else` assist

Closes https://github.com/rust-lang/rust-analyzer/issues/13254
2022-11-01 16:24:15 +00:00
Jonas Schievink
72d5b456e1 Fix doc test 2022-11-01 17:23:32 +01:00
Jonas Schievink
e110c7889a Revert "Record diverging match arms in InferenceResult"
This reverts commit 319611b738.
2022-11-01 17:18:17 +01:00
Jonas Schievink
9f1bb17a1b Import option in the tests 2022-11-01 17:18:13 +01:00
Jonas Schievink
ecad1a9a6e Create Callables for generic types implementing FnOnce 2022-11-01 16:38:19 +01:00
bors
07f6efc4e7 Auto merge of #13523 - lowr:fix/adjust-expectation-for-if, r=lnicola
fix: disregard type variable expectation for if expressions

Fixes #13522

As [the comment](8142d1f606/crates/hir-ty/src/infer.rs (L1087-L1090)) on `Expectation::adjust_for_branches` explains:

> If the expected type is just a type variable, then don't use an expected type. Otherwise, we might write parts of the type when checking the 'then' block which are incompatible with the 'else' branch.

Note that we already use it in match expressions. I've added tests for them too nevertheless.
2022-10-31 15:39:20 +00:00
Ryo Yoshida
db8c7523f8
fix: disregard type variable expectation for if expressions 2022-11-01 00:15:05 +09:00
feniljain
98125b9f95 fix: make custom expr prefix completions to understand refs 2022-10-30 15:02:17 +05:30
unexge
f0a14346ee Update auto generated tests 2022-10-30 00:00:53 +01:00
unexge
48efc9d303 Add Convert match to let-else assist 2022-10-29 23:45:13 +01:00
unexge
319611b738 Record diverging match arms in InferenceResult 2022-10-29 23:44:34 +01:00
koka
cf90e4f32b
Simplify the procedure
fix: remove unused import
2022-10-30 00:59:20 +09:00
koka
4a7f5cac9d
fix: async trait method for unnecessary_async 2022-10-29 01:14:44 +09:00
Ryo Yoshida
e0f09cd007
Document the ordering constraint on Binders and Substitution 2022-10-28 21:24:59 +09:00
Ryo Yoshida
5c794210bf
Replace expect test for GATs with check_types 2022-10-28 21:24:55 +09:00
Ryo Yoshida
5fc18ad6fa
Lower generic arguments for GATs in associated type bindings 2022-10-27 19:19:01 +09:00
Ryo Yoshida
63cba43b48
Collect generic arguments in associated type bindings 2022-10-27 19:18:59 +09:00
Ryo Yoshida
f233ac447f
Lower generic arguments for associated types in paths 2022-10-27 19:18:57 +09:00
Ryo Yoshida
4dd694371a
Display generic arguments for associated types 2022-10-27 19:18:55 +09:00
Ryo Yoshida
1fe10bff1d
refactor: remove obsolete code 2022-10-27 19:18:51 +09:00
bors
0340b51ff7 Auto merge of #13484 - lnicola:position-encoding, r=lnicola
Switch to upstream `positionEncoding`

Closes #13481

This drops support for the custom extension, but that's probably fine.

Draft because it's not tested yet.
2022-10-26 18:12:47 +00:00
bors
feefbe7918 Auto merge of #13475 - lowr:fix/lookup-impl-method-trait-ref, r=flodiebold
fix: Test all generic args for trait when finding matching impl

Addresses https://github.com/rust-lang/rust-analyzer/pull/13463#issuecomment-1287816680

When finding matching impl for a trait method, we've been testing the unifiability of self type. However, there can be multiple impl of a trait for the same type with different generic arguments for the trait. This patch takes it into account and tests the unifiability of all type arguments for the trait (the first being the self type) thus enables rust-analyzer to find the correct impl even in such cases.
2022-10-26 12:06:26 +00:00
Ryo Yoshida
67f1d8fe2c
Test all generic args for trait when finding matching impl 2022-10-25 23:28:40 +09:00
Laurențiu Nicola
e93a2bff67 Pin lsp-types 2022-10-25 15:03:35 +03:00
Laurențiu Nicola
956b96a19d Switch to upstream positionEncoding 2022-10-25 14:43:26 +03:00
feniljain
4bf9b9b003 refactor: remove repetitive string interpolation and doc changes 2022-10-24 21:12:31 +05:30
Ryo Yoshida
15d4383053
Let InferenceTable::unify() relate Zip values 2022-10-24 23:28:53 +09:00
bors
53b6d69e93 Auto merge of #13478 - Veykril:fix-flycheck, r=Veykril
fix: Fix standard flycheck command not being executed in the workspace it is being invoked for

Fixes https://github.com/rust-lang/rust-analyzer/issues/13477
2022-10-24 14:08:45 +00:00
Lukas Wirth
fbae83acd0 fix: Fix standard flycheck command not being executed in the workspace it is being invoked for 2022-10-24 16:07:42 +02:00
Lukas Wirth
6a00e14c7a fix: Don't respond with an error when requesting a shutdown while starting 2022-10-24 14:56:58 +02:00
Ryo Yoshida
6afd0f57eb
Refactor: unwrap Option once in the beginning of closure 2022-10-24 21:30:31 +09:00
feniljain
c4bdb8e516 feat: add config for inserting must_use in generate_enum_as_method 2022-10-24 13:18:24 +05:30
Lukas Wirth
859f5594ac Handle multiple projects sharing dependency correctly in once strategy 2022-10-23 18:01:35 +02:00
Lukas Wirth
0f8904ec9c Implement invocation location config 2022-10-22 23:33:03 +02:00