Commit Graph

23300 Commits

Author SHA1 Message Date
btwotwo
3c39668ca4
Remove extra parameter, access Db through semantics 2022-10-11 19:23:41 +02:00
bors
d08f1c3dff 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](3a69435af7/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](3a69435af7/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.
2022-10-11 11:44:32 +00:00
zyctree
34977996c3
Update docs/dev/syntax.md
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2022-10-11 19:37:49 +08:00
Ryo Yoshida
5e43ea96aa
fix: reorder dyn bounds on render 2022-10-11 20:26:11 +09:00
zyctree
11a335d5e8
fix link in syntax.md 2022-10-11 14:05:04 +08:00
bors
5d49951913 Auto merge of #13357 - Veykril:minicore, r=Veykril
internal: Allow minicore flags specification to be order independent
2022-10-10 21:43:17 +00:00
bors
21319d135f 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
2022-10-10 21:35:07 +00:00
bors
99c205c70f 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
2022-10-10 20:49:06 +00:00
Lukas Wirth
c069f1b7d2 Prefer similar tokens when expanding macros speculatively 2022-10-10 22:47:52 +02:00
bors
43c7f3ca3d 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.
2022-10-10 17:03:44 +00:00
dvdsk
76be44eed5
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.
2022-10-10 19:00:47 +02:00
bors
d23537394e 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)
2022-10-10 14:05:38 +00:00
bors
deddad347b 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
2022-10-10 13:57:09 +00:00
bors
ef014aac02 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
2022-10-10 13:48:26 +00:00
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
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
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