Commit graph

22441 commits

Author SHA1 Message Date
Dorian Scheidt
075ab03851 fix: Support generics in extract_function assist
This change attempts to resolve issue #7636: Extract into Function does not
create a generic function with constraints when extracting generic code.

In `FunctionBody::analyze_container`, we now traverse the `ancestors` in search
of `AnyHasGenericParams`, and attach any `GenericParamList`s and `WhereClause`s
we find to the `ContainerInfo`.

Later, in `format_function`, we collect all the `GenericParam`s and
`WherePred`s from the container, and filter them to keep only types matching
`TypeParam`s used within the newly extracted function body or param list. We
can then include the new `GenericParamList` and `WhereClause` in the new
function definition.

This change only impacts `TypeParam`s. `LifetimeParam`s and `ConstParam`s are
out of scope for this change.
2022-07-13 14:54:10 -05:00
bors
794ecd58a3 Auto merge of #12755 - Veykril:server-version, r=lnicola
fix: Set server binary version when distributing
2022-07-13 12:00:16 +00:00
Lukas Wirth
ec51dcbbc7 fix: Set server binary version when distributing 2022-07-13 13:34:04 +02:00
bors
90b509702e Auto merge of #12754 - Veykril:vscode-status, r=Veykril
fix: Fix VSCode status bar tooltip not showing the error messages
2022-07-13 11:29:12 +00:00
Lukas Wirth
def89af1ef fix: Fix VSCode status bar tooltip not showing the error messages 2022-07-13 13:26:23 +02:00
bors
fc47ce53c8 Auto merge of #12696 - hi-rustin:rustin-patch-fix, r=Veykril
Add str_ref_to_string fix

close https://github.com/rust-lang/rust-analyzer/issues/11383
When type mismatch is `&str` -> `String` try to fix it.
2022-07-13 09:57:51 +00:00
bors
84a6bc99ad Auto merge of #12742 - TonalidadeHidrica:fix-obsolete-config-keys, r=Veykril
Fix obsolete config keys

The config keys were drastically reorganized by #12010, but the docs don't reflect the updates, causing inconsistency and confusion.  I checked for such obsolete configuration keys and updated to the new one.  For reproducibility, I attach a small shell script that I used to examine the old keys.  Now the script only detects `cargoExtraArgs` and `overrideCargo`, which originates from other type definition in the code but not from the configuration.

<details><summary>script</summary>

```bash
echo "allowMergingIntoGlobImports
exprFillDefault
importEnforceGranularity
importGranularity
importMergeBehavior
importMergeBehaviour
importGroup
importPrefix
warmup
loadOutDirsFromCheck
runBuildScripts
runBuildScriptsCommand
useRustcWrapperForBuildScripts
enableExperimental
procAttrMacros
breakPoints
exitPoints
yieldPoints
linksInHover
linksInHover
gotoTypeDef
chainingHints
closureReturnTypeHints
hideNamedConstructorHints
parameterHints
reborrowHints
typeHints
lruCapacity
cargoExtraArgs
overrideCargo
rustcSource
enableRangeFormatting
assist\.allowMergingIntoGlobImports
assist\.exprFillDefault
assist\.importEnforceGranularity
assist\.importGranularity
assist\.importMergeBehavior
assist\.importMergeBehaviour
assist\.importGroup
assist\.importPrefix
primeCaches\.enable
cache\.warmup
cargo\.loadOutDirsFromCheck
cargo\.runBuildScripts
cargo\.runBuildScriptsCommand
cargo\.useRustcWrapperForBuildScripts
completion\.snippets
diagnostics\.enableExperimental
experimental\.procAttrMacros
highlighting\.strings
highlightRelated\.breakPoints
highlightRelated\.exitPoints
highlightRelated\.yieldPoints
highlightRelated\.references
hover\.documentation
hover\.linksInHover
hoverActions\.linksInHover
hoverActions\.debug
hoverActions\.enable
hoverActions\.gotoTypeDef
hoverActions\.implementations
hoverActions\.references
hoverActions\.run
inlayHints\.chainingHints
inlayHints\.closureReturnTypeHints
inlayHints\.hideNamedConstructorHints
inlayHints\.parameterHints
inlayHints\.reborrowHints
inlayHints\.typeHints
lruCapacity
runnables\.cargoExtraArgs
runnables\.overrideCargo
rustcSource
rustfmt\.enableRangeFormatting
allFeatures
addCallArgumentSnippets
addCallParenthesis
callInfo\.full
cargo\.allFeatures
checkOnSave\.allFeatures
completion\.addCallArgumentSnippets
completion\.addCallParenthesis" | while read -r pattern
do
  rg '\b'$pattern'\b([^.]|$)' . -g "!crates/rust-analyzer/src/config/patch_old_style.rs" -g "!editors/code/src/config.ts" -g "!a.sh" --no-heading --color=always --line-number
done

exit

excluded
# debug
# enable
# run
# implementations
# references
# documentation
# references
# snippets
# strings
# full
```

</details>
2022-07-13 09:46:26 +00:00
bors
4cbf23c192 Auto merge of #12747 - jonas-schievink:proc-macro-abi-1.63, r=jonas-schievink
fix: Update 1.63 proc macro ABI to match rustc

This updates us to the ABI used by rustc 1.63.0-beta.5, which will likely be the ABI of the next stable Rust release. It should also work on nightly (for now, but future changes won't be supported until the rustc version is bumped).

cc https://github.com/rust-lang/rust-analyzer/issues/12600
2022-07-12 13:29:25 +00:00
Jonas Schievink
ebfbb314c0 Update 1.63 proc macro ABI to match rustc 2022-07-12 15:19:31 +02:00
bors
caf23f2914 Auto merge of #12745 - jonas-schievink:metavar-exprs, r=jonas-schievink
feat: Implement `ignore`  and `index` metavar expression

Part of https://github.com/rust-lang/rust-analyzer/issues/11952

Fixes https://github.com/rust-lang/rust-analyzer/issues/12675
2022-07-11 16:34:49 +00:00
Jonas Schievink
df66eb74ab Implement ignore and index metavar expression 2022-07-11 18:31:42 +02:00
bors
f7bb9327ad Auto merge of #12744 - hi-rustin:rustin-patch-typos, r=lnicola
Fix typos

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-11 13:51:20 +00:00
hi-rustin
d9ab7f21e4 Fix typos
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-11 21:42:05 +08:00
TonalidadeHidrica
e3bde579c4 Fix obsolete completion.snippets config 2022-07-11 17:00:40 +09:00
TonalidadeHidrica
dfcbed09d3 Fix obsolete enableRangeFormatting config 2022-07-11 16:52:35 +09:00
TonalidadeHidrica
f0649f2c19 Fix rustcSource -> rustc_source
This only fixes the comments in the internal source,
     which is not mandatory at all
2022-07-11 16:50:20 +09:00
TonalidadeHidrica
195ceea910 Fix obsolete diagnostics.experimental.enable 2022-07-11 16:37:46 +09:00
TonalidadeHidrica
6e5571608b Fix obsolete loadOutDirsFromCheck configs 2022-07-11 16:36:36 +09:00
TonalidadeHidrica
eaebead296 Fix config keys regarding imports in docs 2022-07-11 15:43:25 +09:00
bors
5342f47f42 Auto merge of #12732 - lnicola:bump-npm, r=lnicola
Bump npm deps
2022-07-09 20:26:32 +00:00
Laurențiu Nicola
cb38145714 Bump transitive npm deps 2022-07-09 23:20:06 +03:00
Laurențiu Nicola
a059e79ccb Bump @vscode/test-electron 2022-07-09 23:17:56 +03:00
Laurențiu Nicola
358d6c6dcc Bump @types/node to 16 2022-07-09 23:17:12 +03:00
Laurențiu Nicola
2c9e39553c Bump typescript and tslib 2022-07-09 23:14:17 +03:00
Laurențiu Nicola
8e889ac3b5 Bump prettier 2022-07-09 23:10:39 +03:00
Laurențiu Nicola
d03ed83863 Bump @typescript-eslint 2022-07-09 23:10:07 +03:00
Laurențiu Nicola
0e38961046 Bump vsce 2022-07-09 23:08:59 +03:00
Laurențiu Nicola
7b1b711ecc Bump eslint 2022-07-09 23:07:31 +03:00
Laurențiu Nicola
1b138b11cf Bump esbuild 2022-07-09 23:06:45 +03:00
Laurențiu Nicola
b43708c930 Bump d3 and d3-graphviz 2022-07-09 23:06:06 +03:00
Laurențiu Nicola
03a62c180e Bump vscode-languageclient 2022-07-09 23:04:14 +03:00
bors
666343b759 Auto merge of #12727 - DorianListens:dscheidt/extract-var-field-name, r=jonas-schievink
fix: Improve suggested names for extracted variables

When extracting a field expression, if RA was unable to resolve the type of the
field, we would previously fall back to using "var_name" as the variable name.

Now, when the `Expr` being extracted matches a `FieldExpr`, we can use the
`NameRef`'s ident token as a fallback option.

fixes #10035
2022-07-09 13:08:57 +00:00
hi-rustin
638abba05c Fix test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-07-09 11:42:19 +08:00
Dorian Scheidt
21062f9201 fix: Improve suggested names for extracted variables
When extracting a field expression, if RA was unable to resolve the type of the
field, we would previously fall back to using "var_name" as the variable name.

Now, when the `Expr` being extracted matches a `FieldExpr`, we can use the
`NameRef`'s ident token as a fallback option.

fixes #10035
2022-07-08 18:35:04 -05:00
bors
2836dd15f7 Auto merge of #12706 - DorianListens:dscheidt/closure-args, r=DorianListens
fix: Extract Function misses locals used in closures

This change fixes #12705.

In `FunctionBody::analyze`, we need to search any `ClosureExpr`s we encounter
for any `NameRef`s, to ensure they aren't missed.
2022-07-08 15:02:02 +00:00
Dorian Scheidt
603b6fcc68 fix: Extract Function misses locals used in closures
This change fixes #12705.

In `FunctionBody::analyze`, we need to search any `ClosureExpr`s we encounter
for any `NameRef`s, to ensure they aren't missed.
2022-07-08 09:52:01 -05:00
bors
c419aa9775 Auto merge of #12719 - davidlattimore:format-args-no-unsafe, r=jonas-schievink
Remove unnecessary unsafe from format_args expansion
2022-07-08 14:10:19 +00:00
bors
7181a39d4c Auto merge of #12676 - DorianListens:dscheidt/extract-fun-trait-impl, r=jonas-schievink
fix: Extract function from trait impl

This change fixes #10036, "Extract to function assist implements nonexistent
trait methods".

When we detect that the extraction is coming from within a trait impl, and that
a `self` param will be necessary, we adjust which `SyntaxNode` to `insert_after`,
and create a new empty `impl` block for the newly extracted function.
2022-07-08 14:01:36 +00:00
bors
df4ed94f2f Auto merge of #12722 - jonas-schievink:update-urls, r=jonas-schievink
internal: Update remaining GitHub URLs

The old links still work, but it seems less confusing to have them point to the right repo
2022-07-08 13:50:20 +00:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
bors
09abd76c6a Auto merge of #12716 - davidlattimore:fix-publish-crate-names, r=lnicola
publish workflow: Fix names for existing crates

Attempting to publish for example ra_ap_text-edit when ra_ap_text_edit
has already been published is rejected by crates.io.
2022-07-08 05:16:43 +00:00
David Lattimore
6f819e30e4 Remove unnecessary unsafe from format_args expansion 2022-07-08 14:56:18 +10:00
David Lattimore
f0af913ab0 publish workflow: Fix names for existing crates
Attempting to publish for example ra_ap_text-edit when ra_ap_text_edit
has already been published is rejected by crates.io.
2022-07-08 12:58:13 +10:00
bors
c296e77767 Auto merge of #12695 - xuhongxu96:fix-12140, r=jonas-schievink
Complete type param/associated type in trait generic arg per arg index

- Fix #12140
- Also fix tidy check does not work for marks in multiline
2022-07-06 23:58:52 +00:00
Hongxu Xu
3248601a03 fix default type param value position 2022-07-07 07:28:55 +08:00
bors
c46570e694 Auto merge of #12704 - jonas-schievink:smol-paths, r=jonas-schievink
internal: Use `SmallVec` to slightly shrink `ModPath` size

Saves like a megabyte on r-a itself.
2022-07-06 17:57:00 +00:00
Jonas Schievink
d2fd137252 Use SmallVec to slightly shrink ModPath size 2022-07-06 19:49:05 +02:00
Hongxu Xu
0360ed53cf check arg_idx >= n_params only if arg_idx >= n_required_params 2022-07-07 00:54:46 +08:00
Hongxu Xu
75fb3de310 Handle generic args per arg index
Add more test cases for generic args
2022-07-07 00:45:22 +08:00
bors
00194ade76 Auto merge of #12702 - lnicola:vscode-schemes, r=lnicola
internal: use different schemes for the custom views

Related to #12699, but doesn't fix it because we still register the providers multiple times.
2022-07-06 15:57:34 +00:00