]> git.lizzy.rs Git - rust.git/log
rust.git
21 months agoRevert "fix: in VSCode, correctly resolve relative paths to errors"
Jonas Schievink [Fri, 14 Oct 2022 07:28:44 +0000 (09:28 +0200)]
Revert "fix: in VSCode, correctly resolve relative paths to errors"

21 months agoAuto merge of #13401 - lnicola:opt-tests, r=lnicola
bors [Fri, 14 Oct 2022 07:00:38 +0000 (07:00 +0000)]
Auto merge of #13401 - lnicola:opt-tests, r=lnicola

Run `analysis-stats` on CI, with `opt-level = 1`

We might want to run `analysis-stats` on PRs, and this makes it less unbearable.

21 months agoRun analysis-stats on CI
Laurențiu Nicola [Thu, 13 Oct 2022 09:49:16 +0000 (12:49 +0300)]
Run analysis-stats on CI

21 months agoAvoid format! in favor of to_string
Laurențiu Nicola [Wed, 12 Oct 2022 14:01:54 +0000 (17:01 +0300)]
Avoid format! in favor of to_string

21 months agoSet opt-level = 1 on dev profile
Laurențiu Nicola [Wed, 12 Oct 2022 14:01:27 +0000 (17:01 +0300)]
Set opt-level = 1 on dev profile

21 months agoAuto merge of #13358 - btwotwo:feature/env-vars-autocompletion, r=Veykril
bors [Tue, 11 Oct 2022 18:45:31 +0000 (18:45 +0000)]
Auto merge of #13358 - btwotwo:feature/env-vars-autocompletion, r=Veykril

feat: Autocomplete Cargo-defined env vars in `env!` and `option_env!` (#12448)

Closes #12448

Important to know:

- Variables are taken from https://doc.rust-lang.org/cargo/reference/environment-variables.html and hardcoded as a const array.
- For the sake of simplicity I didn't include the autocompletion of `CARGO_BIN_EXE_<name>` and `OUT_DIR` since it would require information about build.rs and binary name. If somebody knows an easy way of obtaining them I can add those vars as well :)

21 months agoFormatting
btwotwo [Tue, 11 Oct 2022 17:53:22 +0000 (19:53 +0200)]
Formatting

21 months agoFix formatting for cargo vars list
btwotwo [Tue, 11 Oct 2022 17:29:09 +0000 (19:29 +0200)]
Fix formatting for cargo vars list

21 months agoRename `get_outer_macro` to `macro_call_for_string_token`
btwotwo [Tue, 11 Oct 2022 17:28:42 +0000 (19:28 +0200)]
Rename `get_outer_macro` to `macro_call_for_string_token`

21 months agoRemove extra parameter, access Db through semantics
btwotwo [Tue, 11 Oct 2022 17:23:41 +0000 (19:23 +0200)]
Remove extra parameter, access Db through semantics

21 months agoAuto merge of #13382 - lowr:fix/reorder-dyn-bounds-on-render, r=lowr
bors [Tue, 11 Oct 2022 11:44:32 +0000 (11:44 +0000)]
Auto merge of #13382 - lowr:fix/reorder-dyn-bounds-on-render, r=lowr

fix: reorder dyn bounds on render

Fixes #13368

#13192 changed the order of dyn bounds, violating the [contract](https://github.com/rust-lang/rust-analyzer/blob/3a69435af7a1e6273744085cb251adb2b9c30a03/crates/hir-ty/src/display.rs#L896-L901) with `write_bounds_like_dyn_trait()` on render. The projection bounds are expected to come right after the trait bound they are accompanied with.

Although the reordering procedure can be made a bit more efficient, I opted for relying only on the [invariants](https://github.com/rust-lang/rust-analyzer/blob/3a69435af7a1e6273744085cb251adb2b9c30a03/crates/hir-ty/src/lower.rs#L995-L998) currently documented in `lower_dyn_trait()`. It's not the hottest path and dyn bounds tend to be short so I believe it shouldn't hurt performance noticeably.

21 months agofix: reorder dyn bounds on render
Ryo Yoshida [Mon, 10 Oct 2022 10:32:24 +0000 (19:32 +0900)]
fix: reorder dyn bounds on render

21 months agoAuto merge of #13357 - Veykril:minicore, r=Veykril
bors [Mon, 10 Oct 2022 21:43:17 +0000 (21:43 +0000)]
Auto merge of #13357 - Veykril:minicore, r=Veykril

internal: Allow minicore flags specification to be order independent

21 months agoAuto merge of #13329 - Veykril:rustc-proc-macro, r=Veykril
bors [Mon, 10 Oct 2022 21:35:07 +0000 (21:35 +0000)]
Auto merge of #13329 - Veykril:rustc-proc-macro, r=Veykril

Use $crate instead of std for panic builtin_fn_macro

This should be closer to the expected output and gets rid of a few type mismatches in rustc/library

21 months agoAuto merge of #13392 - Veykril:spec-pref, r=Veykril
bors [Mon, 10 Oct 2022 20:49:06 +0000 (20:49 +0000)]
Auto merge of #13392 - Veykril:spec-pref, r=Veykril

Prefer similar tokens when expanding macros speculatively

Should improve completions in proc-macros in some cases

21 months agoPrefer similar tokens when expanding macros speculatively
Lukas Wirth [Mon, 10 Oct 2022 20:47:52 +0000 (22:47 +0200)]
Prefer similar tokens when expanding macros speculatively

21 months agoAuto merge of #13391 - dvdsk:update-manual, r=lnicola
bors [Mon, 10 Oct 2022 17:03:44 +0000 (17:03 +0000)]
Auto merge of #13391 - dvdsk:update-manual, r=lnicola

Update manual now stable can be installed with rustup

this a new PR for #13374 as `bors squash` seemed to have broken `bors`
_______
`rustup` can now install `rust-analyzer` for the stable tool-chain. This commit removes the note that `rustup` can only install for the nightly branch and adjusts the command.

I also added a note on how to find the path to the `rust-analyzer` binary when installed using `rustup`, and suggestions on how to work around it not being placed in `~/.cargo/bin`.

I thought it would be ideal to point everyone to use `rustup run stable rust-analyzer` to start `rust-analyzer`. That would make it trivial to switch to nightly however I could not get this to work in `nvim` therefore I left it as a suggestion at the end.

21 months agoUpdate manual now stable can be installed with rustup
dvdsk [Mon, 10 Oct 2022 17:00:47 +0000 (19:00 +0200)]
Update manual now stable can be installed with rustup

`rustup` can now install `rust-analyzer` for the stable tool-chain. This commit removes the note that `rustup` can only install for the nightly branch and adjusts the command.

I also added a note on how to find the path to the `rust-analyzer` binary when installed using `rustup`, and suggestions on how to work around it not being placed in `~/.cargo/bin`.

I thought it would be ideal to point everyone to use `rustup run stable rust-analyzer` to start `rust-analyzer`. That would make it trivial to switch to nightly however I could not get this to work in `nvim` therefore I left it as a suggestion at the end.

21 months agoAuto merge of #13386 - Veykril:completions-ref, r=Veykril
bors [Mon, 10 Oct 2022 14:05:38 +0000 (14:05 +0000)]
Auto merge of #13386 - Veykril:completions-ref, r=Veykril

Refactor completions expansion

Depends on https://github.com/rust-lang/rust-analyzer/pull/13384
Diff is unfortunately massive as I changed the functions in the analysis module from associated ones to standalone (unfortunately without an extra commit)

21 months agoAuto merge of #13380 - Veykril:cfg-pat-params, r=Veykril
bors [Mon, 10 Oct 2022 13:57:09 +0000 (13:57 +0000)]
Auto merge of #13380 - Veykril:cfg-pat-params, r=Veykril

Honor cfg attributes on params when lowering their patterns

Closes https://github.com/rust-lang/rust-analyzer/issues/13375

21 months agoAuto merge of #13385 - Veykril:progress, r=Veykril
bors [Mon, 10 Oct 2022 13:48:26 +0000 (13:48 +0000)]
Auto merge of #13385 - Veykril:progress, r=Veykril

Don't report build-scripts and proc-macros as metadata progress

Seems somewhat confusing to me, given `metadata` is already the step we do for workspace loading

21 months agoRefactor completions expansion
Lukas Wirth [Mon, 10 Oct 2022 13:45:24 +0000 (15:45 +0200)]
Refactor completions expansion

21 months agoDon't report build-scripts and proc-macros are metadata progress
Lukas Wirth [Mon, 10 Oct 2022 13:41:32 +0000 (15:41 +0200)]
Don't report build-scripts and proc-macros are metadata progress

21 months agoAuto merge of #13384 - Veykril:macro-fallbacks, r=Veykril
bors [Mon, 10 Oct 2022 13:40:09 +0000 (13:40 +0000)]
Auto merge of #13384 - Veykril:macro-fallbacks, r=Veykril

Expand unmatched mbe fragments to reasonable default token trees

Currently we expand unmatched fragments by not replacing them at all, leaving us with `$ident`. This trips up the parser or subsequent macro calls. Instead it makes more sense to replace these with some reasonable default depending on the fragment kind which should make more recursive macro calls work better for completions.

21 months agoExpand unmatched mbe fragments to reasonable default token trees
Lukas Wirth [Mon, 10 Oct 2022 12:25:14 +0000 (14:25 +0200)]
Expand unmatched mbe fragments to reasonable default token trees

Currently we expand unmatched fragments by not replacing them at all,
leaving us with `$ident`. This trips up the parser or subsequent macro
calls. Instead it makes more sense to replace these with some reasonable
default depending on the fragment kind which should make more recursive
macro calls work better for completions.

21 months agoAuto merge of #13333 - feniljain:fix_assists, r=Veykril
bors [Mon, 10 Oct 2022 08:36:18 +0000 (08:36 +0000)]
Auto merge of #13333 - feniljain:fix_assists, r=Veykril

fix(generate_method): correct method indentation inside generated impl and change gen loc

should fix #10619

21 months agoUse $crate instead of std for panic builtin_fn_macro
Lukas Wirth [Sat, 1 Oct 2022 20:51:09 +0000 (22:51 +0200)]
Use $crate instead of std for panic builtin_fn_macro

This should be closer to the expected output and gets rid of a few
type mismatches in rustc/library

21 months agoAuto merge of #13303 - jplatte:convert-named-struct-to-tuple-struct, r=Veykril
bors [Mon, 10 Oct 2022 08:24:37 +0000 (08:24 +0000)]
Auto merge of #13303 - jplatte:convert-named-struct-to-tuple-struct, r=Veykril

Add convert_named_struct_to_tuple_struct assist

Closes #11643, since the assist for converting in the other direction is already there (I based most of the implementation and all of the tests on it).

21 months agoAuto merge of #13367 - matklad:fix-problem-matchers, r=Veykril
bors [Mon, 10 Oct 2022 07:54:55 +0000 (07:54 +0000)]
Auto merge of #13367 - matklad:fix-problem-matchers, r=Veykril

fix: in VSCode, correctly resolve relative paths to errors

VS Code problem matcher are restricted to be static "regexes". You can't create a problem matcher dynamically, and you can't use custom code in lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths relative to the root of the Cargo workspace, but VS Code doesn't necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like this:

    "fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace root. VS Code allows to specify a command inside `${}`. So we can plug custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!

21 months agoHonor cfg attributes on params when lowering their patterns
Lukas Wirth [Mon, 10 Oct 2022 07:47:09 +0000 (09:47 +0200)]
Honor cfg attributes on params when lowering their patterns

21 months agoAuto merge of #13377 - DropDemBits:doc-link-underline-range, r=Veykril
bors [Mon, 10 Oct 2022 07:14:43 +0000 (07:14 +0000)]
Auto merge of #13377 - DropDemBits:doc-link-underline-range, r=Veykril

fix: Underline only the intra-doc link itself instead of the whole doc comment

21 months agoAuto merge of #13376 - DropDemBits:strip-generic-bounds-and-defaults, r=Veykril
bors [Mon, 10 Oct 2022 06:34:58 +0000 (06:34 +0000)]
Auto merge of #13376 - DropDemBits:strip-generic-bounds-and-defaults, r=Veykril

internal: Add `GenericParamList::to_generic_args` and `{TypeParam,ConstParam}::remove_default` APIs

Also fixes `generate_impl` not removing the default const param value, though it seems that no one has encountered or reported that issue yet 😅

This initially started out as refactoring `utils::generate_impl_text_inner` to understand it better (which was the reason for adding `{TypeParam,ConstParam}::remove_default`), but ended up also finding another place that needed `GenericParamList::to_generic_args`, hence its addition in here.

21 months agoUnderline only the intra-doc link instead of the whole doc comment
DropDemBits [Mon, 10 Oct 2022 01:28:21 +0000 (21:28 -0400)]
Underline only the intra-doc link instead of the whole doc comment

21 months agoHave `to_generic_args` return `ast::GenericArgList`
DropDemBits [Mon, 10 Oct 2022 00:45:20 +0000 (20:45 -0400)]
Have `to_generic_args` return `ast::GenericArgList`

21 months agoAdd `{TypeParam, ConstParam}::remove_default`
DropDemBits [Sun, 9 Oct 2022 22:12:08 +0000 (18:12 -0400)]
Add `{TypeParam, ConstParam}::remove_default`

Also includes a drive-by refactor of `utils::generate_impl_text_inner`,
since that's what drove this change

21 months agoAdd `GenericParamList::to_generic_args`
DropDemBits [Sun, 9 Oct 2022 21:58:55 +0000 (17:58 -0400)]
Add `GenericParamList::to_generic_args`

21 months agofix: in VSCode, correctly resolve relative paths to errors
Aleksey Kladov [Sat, 8 Oct 2022 22:18:11 +0000 (23:18 +0100)]
fix: in VSCode, correctly resolve relative paths to errors

VS Code problem matcher are restricted to be static "regexes". You can't
create a problem matcher dynamically, and you can't use custom code in
lieu of problem matcher.

This creates a problem for rust/cargo compiler errors. They use paths
relative to the root of the Cargo workspace, but VS Code doesn't
necessary know where that root is.

Luckily, there's a way out: our current problem matcher is defined like
this:

    "fileLocation": [ "autoDetect", "${workspaceRoot}" ],

That means that relative pahts would be resoleved relative to workspace
root. VS Code allows to specify a command inside `${}`. So we can plug
custom logic there to fetch Cargo's workspace root!

And that's exactly what this PR is doing!

21 months agoAuto merge of #13366 - matklad:xflags, r=lnicola
bors [Sat, 8 Oct 2022 16:46:15 +0000 (16:46 +0000)]
Auto merge of #13366 - matklad:xflags, r=lnicola

internal: :arrow_up: xflags

The main change here should be that flags are not inhereted, so

   $ rust-analyzer analysis-stats . -v -v

would do what it should do

We also no longer Don\'t

21 months agointernal: :arrow_up: xflags
Aleksey Kladov [Sat, 8 Oct 2022 14:35:07 +0000 (15:35 +0100)]
internal: :arrow_up: xflags

The main change here should be that flags are not inhereted, so

   $ rust-analyzer analysis-stats . -v -v

would do what it should do

We also no longer Don\'t

21 months agoAuto merge of #13362 - WaffleLapkin:go_to_def_fix_doc_include_str, r=Veykril
bors [Fri, 7 Oct 2022 09:56:12 +0000 (09:56 +0000)]
Auto merge of #13362 - WaffleLapkin:go_to_def_fix_doc_include_str, r=Veykril

fix: Make go-to-def work for `#[doc = include_str!("path")]`

See the added test, go-to-def on `#[doc = include_str!("path$0")]` should navigate to `path`.

21 months agoFix go-to-def for `#[doc = include_str!("path")]`
Maybe Waffle [Fri, 7 Oct 2022 09:04:41 +0000 (09:04 +0000)]
Fix go-to-def for `#[doc = include_str!("path")]`

21 months agoPass context to env vars completion
btwotwo [Thu, 6 Oct 2022 19:35:12 +0000 (21:35 +0200)]
Pass context to env vars completion

21 months agoRestrict auto-completion for only built-in macros
btwotwo [Thu, 6 Oct 2022 19:35:01 +0000 (21:35 +0200)]
Restrict auto-completion for only built-in macros

21 months agoMake helper method less specific
btwotwo [Thu, 6 Oct 2022 19:34:19 +0000 (21:34 +0200)]
Make helper method less specific

21 months agoFormatting
btwotwo [Thu, 6 Oct 2022 14:53:17 +0000 (16:53 +0200)]
Formatting

21 months agoRemove unnecessary dereference
btwotwo [Thu, 6 Oct 2022 14:42:31 +0000 (16:42 +0200)]
Remove unnecessary dereference

21 months agoUse helper method in is_format_string
btwotwo [Thu, 6 Oct 2022 14:29:23 +0000 (16:29 +0200)]
Use helper method in is_format_string

21 months agoReplace if with option, add detail for each env variable completion
btwotwo [Thu, 6 Oct 2022 14:28:33 +0000 (16:28 +0200)]
Replace if with option, add detail for each env variable completion

21 months agoAdd tests for env var completion
btwotwo [Thu, 6 Oct 2022 14:27:53 +0000 (16:27 +0200)]
Add tests for env var completion

21 months agoAdd const list of cargo-defined env variables with descriptions
btwotwo [Thu, 6 Oct 2022 14:27:27 +0000 (16:27 +0200)]
Add const list of cargo-defined env variables with descriptions

21 months agoAdd helper method to get a macro name from passed string
btwotwo [Thu, 6 Oct 2022 14:26:49 +0000 (16:26 +0200)]
Add helper method to get a macro name from passed string

21 months agoUse expanded version of text for env var completion
btwotwo [Thu, 6 Oct 2022 14:25:12 +0000 (16:25 +0200)]
Use expanded version of text for env var completion

21 months agoAdd stub for cargo environment variables auto completion
btwotwo [Tue, 4 Oct 2022 22:02:03 +0000 (00:02 +0200)]
Add stub for cargo environment variables auto completion

21 months agoAuto merge of #13353 - wildbook:fix_type_inference_panic, r=Veykril
bors [Thu, 6 Oct 2022 12:33:50 +0000 (12:33 +0000)]
Auto merge of #13353 - wildbook:fix_type_inference_panic, r=Veykril

Fix assertion failure in type inference (#13352)

Fixes https://github.com/rust-lang/rust-analyzer/issues/13352

21 months agointernal: Allow minicore flags specification to be order independent
Lukas Wirth [Thu, 6 Oct 2022 12:31:06 +0000 (14:31 +0200)]
internal: Allow minicore flags specification to be order independent

21 months agoAuto merge of #13356 - WaffleLapkin:go_to_def_shadow_include, r=Veykril
bors [Thu, 6 Oct 2022 06:28:31 +0000 (06:28 +0000)]
Auto merge of #13356 - WaffleLapkin:go_to_def_shadow_include, r=Veykril

minor: Fix go-to-def for shadowed `include*!`

Add a check in go-to-def feature, so that we don't assume any macro named `include`/`include_str`/`include_bytes` is the builtin one.

21 months agoFix go-to-def for shadowed `include*!`
Maybe Waffle [Thu, 6 Oct 2022 06:10:28 +0000 (06:10 +0000)]
Fix go-to-def for shadowed `include*!`

21 months agoFix assertion failure in type inference (#13352)
Wildbook [Wed, 5 Oct 2022 15:45:32 +0000 (17:45 +0200)]
Fix assertion failure in type inference (#13352)

21 months agoAuto merge of #13344 - lowr:patch/change-generic-param-order, r=Veykril
bors [Tue, 4 Oct 2022 18:26:43 +0000 (18:26 +0000)]
Auto merge of #13344 - lowr:patch/change-generic-param-order, r=Veykril

fix: use `BoundVar`s from current generic scope

Fixup for #13335, addresses https://github.com/rust-lang/rust-analyzer/pull/13339#issuecomment-1266654607

Before the change in generic parameter order, `BoundVar`s for trait reference didn't change whether you are in an impl's scope or in an associated item's scope. Now that item's generic params come before its parent's, we need to shift their indices when we are in an associated item's scope.

21 months agofix: use `BoundVar`s from current generic scope
Ryo Yoshida [Tue, 4 Oct 2022 15:20:01 +0000 (00:20 +0900)]
fix: use `BoundVar`s from current generic scope

21 months agoAuto merge of #13342 - rust-lang:revert-13328-rustc-proc-macro, r=Veykril
bors [Tue, 4 Oct 2022 06:18:57 +0000 (06:18 +0000)]
Auto merge of #13342 - rust-lang:revert-13328-rustc-proc-macro, r=Veykril

Revert "Add proc-macro dependency to rustc crates"

1. This panics since it indexes into the wrong thing, so fixes https://github.com/rust-lang/rust-analyzer/issues/13340
2. This didn't fix what I thought it would either
Reverts rust-lang/rust-analyzer#13328

21 months agoRevert "Add proc-macro dependency to rustc crates"
Lukas Wirth [Tue, 4 Oct 2022 06:18:01 +0000 (08:18 +0200)]
Revert "Add proc-macro dependency to rustc crates"

22 months agoAuto merge of #13339 - lowr:patch/change-generic-param-order, r=Veykril
bors [Mon, 3 Oct 2022 15:34:32 +0000 (15:34 +0000)]
Auto merge of #13339 - lowr:patch/change-generic-param-order, r=Veykril

fix: treat enum variants as generic item on their own

Fixup for #13335

It turns out I tried to merge two procedures into one utility function without noticing the incompatibility.

This time I *did* run analysis-stats on the four crates and confirmed it doesn't crash and this patch doesn't cause regression.

22 months agofix: treat enum variants as generic item on their own
Ryo Yoshida [Mon, 3 Oct 2022 15:07:34 +0000 (00:07 +0900)]
fix: treat enum variants as generic item on their own

22 months agoAuto merge of #13335 - lowr:patch/change-generic-param-order, r=Veykril
bors [Mon, 3 Oct 2022 12:13:25 +0000 (12:13 +0000)]
Auto merge of #13335 - lowr:patch/change-generic-param-order, r=Veykril

internal: change generic parameter order

tl;dr: This PR changes the `Substitution` for trait items and methods like so:

```rust
trait Trait<TP, const CP: usize> { // note the implicit Self as first parameter
  type Type<TC, const CC: usize>;
  fn f<TC, const CC: usize>() {}
}
impl<TP, const CP: usize> S {
  fn f<TC, const CC: usize>() {}
}
```

- before this PR: `[Self, TP, CP, TC, CC]` for each trait item, `[TP, CP, TC, CC]` for `S::f`
- after this PR: `[TC, CC, Self, TP, CP]` for each trait item, `[TC, CC, TP, CP]` for `S::f`

---

This PR "inverts" the generic parameters/arguments of an item and its parent. This is to fulfill [chalk's expectation](https://github.com/rust-lang/chalk/blob/d875af0ff196dd6430b5f5fd87a640fa5ab59d1e/chalk-solve/src/rust_ir.rs#L498-L502) on the order of generic arguments in `Substitution`s for generic associated types and it's one step forward for GATs support (hopefully). Although chalk doesn't put any constraint for other items, it feels more natural to get everything aligned than special casing GATs.

One complication is that `TyBuilder` now demands its users to pass in parent's `Substitution` upon construction unless it's obvious that the the item has no parent (e.g. an ADT never has parent). All users *should* already know the parent of the item in question, and without this, it cannot be easily reasoned about whether we're pushing the argument for the item or for its parent.

Some additional notes:
f8f5a5ea5788a846013545d63c9b46fd70cc4f7c: This isn't related to the change, but I felt it's nicer.

78977cd86cd17e008f94f8579d6a5aaebe46e69b: There's one major change here other than the generic param order: Default arguments are now bound by the same `Binder` as the item in question rather than a `Binder` limited to parameters they can refer to (i.e. arguments that syntactically appear before them). Now that the order of generic parameters is changed, it would be somewhat complicated to make such `Binder`s as before, and the "full" `Binder`s shouldn't be a problem because we already make sure that the default arguments don't refer to the generic arguments after them with `fallback_bound_vars()`.

7556f74b1691276d12e4cf96eb2df8f74836cdc1: This is split from 4385d3dcd0df7713b3a35f31f11034f0a570adbd to make it easy to revert if it turns out that the GATs with const generics panic is actually not resolved with this PR. cc #11878 #11957

22 months agoAuto merge of #13338 - Veykril:flycheck, r=Veykril
bors [Mon, 3 Oct 2022 12:05:11 +0000 (12:05 +0000)]
Auto merge of #13338 - Veykril:flycheck, r=Veykril

Prioritize restart messages in flycheck

cc https://github.com/rust-lang/rust-analyzer/issues/12936#issuecomment-1264670905

22 months agoPrioritize restart messages in flycheck
Lukas Wirth [Mon, 3 Oct 2022 12:03:54 +0000 (14:03 +0200)]
Prioritize restart messages in flycheck

22 months agoRemove hack
Ryo Yoshida [Sun, 2 Oct 2022 12:13:30 +0000 (21:13 +0900)]
Remove hack

22 months agoAdapt to the new generic parameter/argument order
Ryo Yoshida [Sun, 2 Oct 2022 13:15:57 +0000 (22:15 +0900)]
Adapt to the new generic parameter/argument order

22 months agoChange generic parameter/argument order
Ryo Yoshida [Sun, 2 Oct 2022 12:13:21 +0000 (21:13 +0900)]
Change generic parameter/argument order

This commit "inverts" the order of generic parameters/arguments of an
item and its parent. This is to fulfill chalk's expectation on the
order of `Substitution` for generic associated types and it's one step
forward for their support (hopefully).

Although chalk doesn't put any constraint on the order of `Substitution`
for other items, it feels natural to get everything aligned rather than
special casing GATs.

One complication is that `TyBuilder` now demands its users to pass in
parent's `Substitution` upon construction unless it's obvious that the
the item has no parent (e.g. an ADT never has parent). All users
*should* already know the parent of the item in question, and without
this, it cannot be easily reasoned about whether we're pushing the
argument for the item or for its parent.

Quick comparison of how this commit changes `Substitution`:

```rust
trait Trait<TP, const CP: usize> {
  type Type<TC, const CC: usize> = ();
  fn f<TC, const CC: usize>() {}
}
```

- before this commit: `[Self, TP, CP, TC, CC]` for each trait item
- after this commit: `[TC, CC, Self, TP, CP]` for each trait item

22 months agorefactor: use `cast()` instead of interning `GenericArgData`
Ryo Yoshida [Sun, 2 Oct 2022 09:39:42 +0000 (18:39 +0900)]
refactor: use `cast()` instead of interning `GenericArgData`

22 months agoAuto merge of #13328 - Veykril:rustc-proc-macro, r=Veykril
bors [Sat, 1 Oct 2022 19:29:33 +0000 (19:29 +0000)]
Auto merge of #13328 - Veykril:rustc-proc-macro, r=Veykril

Add proc-macro dependency to rustc crates

22 months agoAdd proc-macro dependency to rustc crates
Lukas Wirth [Sat, 1 Oct 2022 19:29:14 +0000 (21:29 +0200)]
Add proc-macro dependency to rustc crates

22 months agoAuto merge of #13327 - Veykril:proc-macro-srv-config, r=Veykril
bors [Sat, 1 Oct 2022 19:17:36 +0000 (19:17 +0000)]
Auto merge of #13327 - Veykril:proc-macro-srv-config, r=Veykril

Add config for supplying sysroot path

22 months agoAdd config for supplying sysroot path
Lukas Wirth [Sat, 1 Oct 2022 18:47:31 +0000 (20:47 +0200)]
Add config for supplying sysroot path

22 months agoAuto merge of #13326 - Veykril:proc-macro-srv-config, r=Veykril
bors [Sat, 1 Oct 2022 17:51:47 +0000 (17:51 +0000)]
Auto merge of #13326 - Veykril:proc-macro-srv-config, r=Veykril

Do not use the sysroot proc-macro server when a server path is given explicitly

22 months agoDo not use the sysroot proc-macro server when a server path is given explicitly
Lukas Wirth [Sat, 1 Oct 2022 17:50:34 +0000 (19:50 +0200)]
Do not use the sysroot proc-macro server when a server path is given explicitly

22 months agoAuto merge of #13324 - Veykril:trait-impl-completion, r=Veykril
bors [Sat, 1 Oct 2022 13:35:08 +0000 (13:35 +0000)]
Auto merge of #13324 - Veykril:trait-impl-completion, r=Veykril

Fix trait impl item completions using macro file text ranges

Fixes https://github.com/rust-lang/rust-analyzer/issues/13323

22 months agoFix trait impl item completions using macro file text ranges
Lukas Wirth [Sat, 1 Oct 2022 13:34:45 +0000 (15:34 +0200)]
Fix trait impl item completions using macro file text ranges

22 months agoAuto merge of #13321 - Veykril:format-str-args, r=Veykril
bors [Fri, 30 Sep 2022 22:42:40 +0000 (22:42 +0000)]
Auto merge of #13321 - Veykril:format-str-args, r=Veykril

Fix move_format_string_arg being tokentree unaware

Fixes https://github.com/rust-lang/rust-analyzer/issues/13261

22 months agoFix move_format_string_arg being tokentree unaware
Lukas Wirth [Fri, 30 Sep 2022 22:42:16 +0000 (00:42 +0200)]
Fix move_format_string_arg being tokentree unaware

22 months agoAuto merge of #13318 - Veykril:annotations, r=Veykril
bors [Fri, 30 Sep 2022 22:31:05 +0000 (22:31 +0000)]
Auto merge of #13318 - Veykril:annotations, r=Veykril

Fix annotations not resolving when lens location is set to whole item

Fixes https://github.com/rust-lang/rust-analyzer/issues/13310

22 months agoAuto merge of #13320 - Veykril:ty-alias-hover, r=Veykril
bors [Fri, 30 Sep 2022 22:22:24 +0000 (22:22 +0000)]
Auto merge of #13320 - Veykril:ty-alias-hover, r=Veykril

Fix type alias hovers not rendering generic parameters

22 months agoFix type alias hovers not rendering generic parameters
Lukas Wirth [Fri, 30 Sep 2022 22:21:29 +0000 (00:21 +0200)]
Fix type alias hovers not rendering generic parameters

22 months agoFix annotations not resolving when lens location is set to whole item
Lukas Wirth [Fri, 30 Sep 2022 22:03:47 +0000 (00:03 +0200)]
Fix annotations not resolving when lens location is set to whole item

22 months agoAuto merge of #13319 - Veykril:req-retry, r=Veykril
bors [Fri, 30 Sep 2022 22:12:48 +0000 (22:12 +0000)]
Auto merge of #13319 - Veykril:req-retry, r=Veykril

Fix requests not being retried anymore

22 months agoFix requests not being retried anymore
Lukas Wirth [Fri, 30 Sep 2022 22:07:33 +0000 (00:07 +0200)]
Fix requests not being retried anymore

22 months agoAuto merge of #13311 - lowr:fix/for-loop-item-resolution, r=Veykril
bors [Thu, 29 Sep 2022 11:04:47 +0000 (11:04 +0000)]
Auto merge of #13311 - lowr:fix/for-loop-item-resolution, r=Veykril

fix: infer for-loop item type with `IntoIterator` and `Iterator`

Part of #13299

We've been inferring the type of the yielded values in for-loop as `<T as IntoIterator>::Item`. We infer the correct type most of the time when we normalize the projection type, but it turns out not always. We should infer the type as `<<T as IntoIterator>::IntoIter as Iterator>::Item`.

When one specifies `IntoIter` assoc type of `IntoIterator` but not `Item` in generic bounds, we fail to normalize `<T as IntoIterator>::Item` (even though `IntoIter` is defined like so: `type IntoIter: Iterator<Item = Self::Item>` - rustc does *not* normalize projections based on other projection's bound I believe; see [this playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e88e19385094cb98fadbf647b4c2082e)).

Note that this doesn't fully fix # 13299 - given the following code, chalk can normalize `<I as IntoIterator>::IntoIter` to `S`, but cannot normalize `<S as Iterator>::Item` to `i32`.

```rust
struct S;
impl Iterator for S { type Item = i32; /* ... */ }
fn f<I: IntoIterator<IntoIter = S>>(it: I) {
    for elem in it {}
      //^^^^{unknown}
}
```

This is because chalk finds multiple answers that satisfy the query `AliasEq(<S as Iterator>::Item = ?X`: `?X = i32` and `?X = <I as IntoIterator>::Item` - which are supposed to be the same type due to the aforementioned bound on `IntoIter` but chalk is unable to figure it out.

22 months agofix: infer for-loop item type with `IntoIterator` and `Iterator`
Ryo Yoshida [Thu, 29 Sep 2022 09:44:45 +0000 (18:44 +0900)]
fix: infer for-loop item type with `IntoIterator` and `Iterator`

22 months agoUpdate outside test and generated code
Jonas Platte [Tue, 27 Sep 2022 18:40:51 +0000 (20:40 +0200)]
Update outside test and generated code

22 months agoAdd convert_named_struct_to_tuple_struct assist
Jonas Platte [Tue, 27 Sep 2022 15:35:50 +0000 (17:35 +0200)]
Add convert_named_struct_to_tuple_struct assist

22 months agoAuto merge of #13301 - Veykril:empty-assist-source-changes, r=Veykril
bors [Tue, 27 Sep 2022 15:54:54 +0000 (15:54 +0000)]
Auto merge of #13301 - Veykril:empty-assist-source-changes, r=Veykril

Make assist tests panic again on empty source changes

22 months agoMake assist tests panic again on empty source changes
Lukas Wirth [Tue, 27 Sep 2022 15:35:55 +0000 (17:35 +0200)]
Make assist tests panic again on empty source changes

22 months agoAuto merge of #13202 - Veykril:cancelled-retry, r=Veykril
bors [Tue, 27 Sep 2022 15:43:57 +0000 (15:43 +0000)]
Auto merge of #13202 - Veykril:cancelled-retry, r=Veykril

Don't retry requests that have already been cancelled

22 months agoDon't retry requests that have already been cancelled
Lukas Wirth [Wed, 7 Sep 2022 11:52:55 +0000 (13:52 +0200)]
Don't retry requests that have already been cancelled

22 months agoAuto merge of #13272 - oknozor:master, r=Veykril
bors [Tue, 27 Sep 2022 15:10:25 +0000 (15:10 +0000)]
Auto merge of #13272 - oknozor:master, r=Veykril

docs(guide): fix Analysis and AnalysisHost doc links

22 months agoAuto merge of #13280 - alanz:errorcode-requestfailed, r=Veykril
bors [Tue, 27 Sep 2022 15:03:15 +0000 (15:03 +0000)]
Auto merge of #13280 - alanz:errorcode-requestfailed, r=Veykril

Add RequestFailed error code, as per spec 3.17

See https://github.com/microsoft/language-server-protocol/issues/1341

22 months agoAuto merge of #13237 - Veykril:process-changes, r=Veykril
bors [Tue, 27 Sep 2022 14:41:40 +0000 (14:41 +0000)]
Auto merge of #13237 - Veykril:process-changes, r=Veykril

Amalgamate file changes for the same file ids in process_changes

When receiving multiple change events for a single file id where the last change is a delete the server panics, as it tries to access the file contents of a deleted file. This occurs due to the VFS changes and the in memory file contents being updated immediately, while `process_changes` processes the events afterwards in sequence which no longer works as it will only observe the final file contents. By folding these events together, we will no longer try to process these intermediate changes, as they aren't relevant anyways.

Potentially fixes https://github.com/rust-lang/rust-analyzer/issues/13236

22 months agoAmalgamate file changes for the same file ids in process_changes
Lukas Wirth [Thu, 15 Sep 2022 19:19:57 +0000 (21:19 +0200)]
Amalgamate file changes for the same file ids in process_changes

When receiving multiple change events for a single file id where the
last change is a delete the server panics, as it tries to access the
file contents of a deleted file. This occurs due to the VFS changes and
the in memory file contents being updated immediately, while
`process_changes` processes the events afterwards in sequence which no
longer works as it will only observe the final file contents. By
folding these events together, we will no longer try to process these
intermediate changes, as they aren't relevant anyways.

Potentially fixes https://github.com/rust-lang/rust-analyzer/issues/13236

22 months agoAuto merge of #13300 - Veykril:cfg-false, r=Veykril
bors [Tue, 27 Sep 2022 14:11:04 +0000 (14:11 +0000)]
Auto merge of #13300 - Veykril:cfg-false, r=Veykril

Use cfg(any()) instead of cfg(FALSE) for disabling proc-macro test

cc https://github.com/rust-lang/rust-analyzer/pull/13286