Commit Graph

23707 Commits

Author SHA1 Message Date
Lukas Wirth
f3ae5e56fb Refactor completions expansion 2022-10-10 15:45:24 +02:00
Lukas Wirth
fd9cd8476b Don't report build-scripts and proc-macros are metadata progress 2022-10-10 15:41:32 +02:00
bors
4ac3f2c24f 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.
2022-10-10 13:40:09 +00:00
Lukas Wirth
78f33c0e96 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.
2022-10-10 14:27:05 +02:00
bors
3a69435af7 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
2022-10-10 08:36:18 +00:00
Lukas Wirth
1574fe0d54 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
2022-10-10 10:33:49 +02:00
bors
dcf1d71bb8 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).
2022-10-10 08:24:37 +00:00
bors
79a3f84002 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!
2022-10-10 07:54:55 +00:00
Lukas Wirth
63ed71bd30 Honor cfg attributes on params when lowering their patterns 2022-10-10 09:47:09 +02:00
bors
05a6bc48b5 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
2022-10-10 07:14:43 +00:00
bors
910c565b17 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.
2022-10-10 06:34:58 +00:00
DropDemBits
a69cccfc0e Underline only the intra-doc link instead of the whole doc comment 2022-10-09 21:29:31 -04:00
DropDemBits
1015a177d4 Have to_generic_args return ast::GenericArgList 2022-10-09 21:03:38 -04:00
DropDemBits
bfe6ec9b77 Add {TypeParam, ConstParam}::remove_default
Also includes a drive-by refactor of `utils::generate_impl_text_inner`,
since that's what drove this change
2022-10-09 18:46:31 -04:00
DropDemBits
75f641799e Add GenericParamList::to_generic_args 2022-10-09 18:44:23 -04:00
Andres Suarez
3a57388d13 update to syn-1.0.102 2022-10-09 13:51:55 -04:00
Aleksey Kladov
5bbfea03cc 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!
2022-10-08 23:25:13 +01:00
Laurențiu Nicola
df7d39b2ed Bump once_cell 2022-10-08 21:25:11 +03:00
bors
61504c8d95 Auto merge of #13366 - matklad:xflags, r=lnicola
internal: ⬆️ 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
2022-10-08 16:46:15 +00:00
Aleksey Kladov
39fa8b5c39 internal: ⬆️ 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
2022-10-08 15:35:07 +01:00
bors
02ae3d5ec6 Auto merge of #2583 - RalfJung:rustup, r=oli-obk
initial josh subtree sync

This demonstrates what a josh-based rustup would look like with my patched josh. To create it I did
```
git fetch http://localhost:8000/rust-lang/rust.git:start=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master
git merge FETCH_HEAD
./rustup-toolchain HEAD && ./miri fmt
git commit -am rustup
```
Unlike the [previous attempt](https://github.com/rust-lang/miri/pull/2554), this does not add a new root commit to the repo.

Once we merge this, we committed to using josh for subtree syncing, and in particular a version of josh that includes https://github.com/josh-project/josh/pull/961 (or something compatible).
2022-10-08 08:53:29 +00:00
bors
8437e4ba58 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`.
2022-10-07 09:56:12 +00:00
Maybe Waffle
1c0ec9f0c8 Fix go-to-def for #[doc = include_str!("path")] 2022-10-07 09:04:41 +00:00
btwotwo
3732d159b2
Pass context to env vars completion 2022-10-06 21:35:12 +02:00
btwotwo
e2d3c1506f
Restrict auto-completion for only built-in macros 2022-10-06 21:35:01 +02:00
btwotwo
f458ea15d6
Make helper method less specific 2022-10-06 21:34:19 +02:00
btwotwo
8a92910f97
Formatting 2022-10-06 16:53:17 +02:00
btwotwo
c660a5ce34
Remove unnecessary dereference 2022-10-06 16:42:31 +02:00
btwotwo
386f46a5a1
Use helper method in is_format_string 2022-10-06 16:32:21 +02:00
btwotwo
55c5014b76
Replace if with option, add detail for each env variable completion 2022-10-06 16:32:21 +02:00
btwotwo
bc7080884c
Add tests for env var completion 2022-10-06 16:32:20 +02:00
btwotwo
ddf68ea7c3
Add const list of cargo-defined env variables with descriptions 2022-10-06 16:32:20 +02:00
btwotwo
08b0c92105
Add helper method to get a macro name from passed string 2022-10-06 16:32:19 +02:00
btwotwo
07621ce096
Use expanded version of text for env var completion 2022-10-06 16:32:19 +02:00
btwotwo
75f4c54d8c
Add stub for cargo environment variables auto completion 2022-10-06 16:32:19 +02:00
bors
a415fb4c4e 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
2022-10-06 12:33:50 +00:00
Lukas Wirth
28c21bc8a8 internal: Allow minicore flags specification to be order independent 2022-10-06 14:31:06 +02:00
bors
f2f3528618 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.
2022-10-06 06:28:31 +00:00
Maybe Waffle
a57ef6b0b1 Fix go-to-def for shadowed include*! 2022-10-06 06:16:39 +00:00
Wildbook
8862fe6ff2 Fix assertion failure in type inference (#13352) 2022-10-05 17:46:56 +02:00
bors
476d043874 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.
2022-10-04 18:26:43 +00:00
Ryo Yoshida
ded3326a64
fix: use BoundVars from current generic scope 2022-10-05 00:49:00 +09:00
bors
b429df2653 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
2022-10-04 06:18:57 +00:00
Lukas Wirth
e0c9e28d1f
Revert "Add proc-macro dependency to rustc crates" 2022-10-04 08:18:01 +02:00
bors
974caaff8f 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.
2022-10-03 15:34:32 +00:00
Ryo Yoshida
e0a161b2e3
fix: treat enum variants as generic item on their own 2022-10-04 00:07:34 +09:00
bors
5bd98e36bc 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](d875af0ff1/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:
- f8f5a5ea57: This isn't related to the change, but I felt it's nicer.

- 78977cd86c: 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()`.

- 7556f74b16: This is split from 4385d3dcd0 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
2022-10-03 12:13:25 +00:00
bors
f087ebe6e7 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
2022-10-03 12:05:11 +00:00
Lukas Wirth
5916803555 Prioritize restart messages in flycheck 2022-10-03 14:03:54 +02:00
Petr Portnov
ed532e5a34 Fix duplicate usage of a article.
This fixes a typo first appearing in #94624
in which test-macro diagnostic uses "a" article twice.

Since I searched sources for " a a " sequences,
I also fixed the same issue in a few source files where I found it.

Signed-off-by: Petr Portnov <gh@progrm-jarvis.ru>
2022-10-02 21:40:39 +03:00