Commit Graph

24054 Commits

Author SHA1 Message Date
bors
7449f9fa10 Auto merge of #13894 - lowr:patch/fallback-before-final-obligation-resolution, r=lnicola
Apply fallback before final obligation resolution

Fixes #13249
Fixes #13518

We've been applying fallback to type variables independently even when there are some unresolved obligations that associate them. This PR applies fallback to unresolved scalar type variables before the final attempt of resolving obligations, which enables us to infer more.

Unlike rustc, which has separate storages for each kind of type variables, we currently don't have a way to retrieve only integer/float type variables without folding/visiting every single type we've inferred. I've repurposed `TypeVariableData` as bitflags that also hold the kind of the type variable it's referring to so that we can "reconstruct" scalar type variables from their indices.

This PR increases the number of ??ty for rust-analyzer repo not because we regress and fail to infer the existing code but because we fail to infer the new code. It seems we have problems inferring some functions bitflags produces.
2023-01-07 19:03:34 +00:00
bors
f1a99014b3 Auto merge of #13898 - lnicola:option-env, r=Veykril
fix: Fix option_env expansion
2023-01-06 17:25:36 +00:00
Laurențiu Nicola
9f6567f20c Fix option_env expansion 2023-01-06 16:00:23 +02:00
Ryo Yoshida
d01630c8f3
Apply fallback to scalar type variables before final obligation resolution 2023-01-06 06:07:08 +09:00
Ryo Yoshida
b183612610
Add INTEGER and FLOAT flags for type variables 2023-01-05 23:10:06 +09:00
Ryo Yoshida
1bfc732b78
Store diverging flag for type variables as bitflags 2023-01-05 23:10:00 +09:00
bors
80cabf7260 Auto merge of #13893 - ntBre:master, r=lnicola
Complete record enum variants without parens when snippets are disabled

I didn't realize I only handled this for tuple variants in #13805. This is the same change but for record variants.
2023-01-04 18:38:34 +00:00
Brent Westbrook
150da92b5c return immediately from render_record_lit if snippet_cap is None
this is the record literal version of #13805, which handled the same issue for
tuple literals
2023-01-04 12:55:05 -05:00
bvanjoi
ae73628f6b fix: keep whitespace in extract function handler 2023-01-04 22:10:17 +08:00
Ryo Yoshida
21ea0048cd
fix: unescape inline module names in module resolution 2023-01-04 18:22:01 +09:00
bors
a97c71f92d Auto merge of #13887 - Veykril:rustc-diag-preferred, r=Veykril
Only set machine-applicable rustc diagnostics as preferred

If they aren't machine applicable, then they might not be what the user wants, disrupting the workflow.
Example being:
![image](https://user-images.githubusercontent.com/3757771/210380233-ae25aa04-954e-4634-8dd1-4377cc2bd837.png)
Prior to the PR this the diagnostic quickfix was at the top, but usually isn't what the user wants.
2023-01-03 14:47:18 +00:00
Lukas Wirth
b6bb1e9ae7 Only set machine-applicable rustc diagnostics as preferred 2023-01-03 15:46:08 +01:00
bors
0b14cd9671 Auto merge of #13886 - Veykril:inlay-ligatures, r=Veykril
Use ZWNJ to prevent VSCode from forming ligatures between hints and code

Turns out VSCode still has this issue for native hints as well, cc https://github.com/rust-lang/rust-analyzer/pull/6236
2023-01-03 11:33:17 +00:00
Lukas Wirth
c4d8cf1dad Use ZWNJ to prevent VSCode from forming ligatures between hints and code 2023-01-03 12:32:38 +01:00
bors
5033213fc9 Auto merge of #13885 - Veykril:bin-op-adjust, r=Veykril
Skip lifetime elision on fn pointers and fn trait types

These currently don't work correctly, so it's better to not render them at all there
2023-01-03 10:59:21 +00:00
Lukas Wirth
b996a54cd8 Skip lifetime elision on fn pointers and fn trait types 2023-01-03 11:58:31 +01:00
bors
50801b7d6a Auto merge of #13853 - veber-alex:diag_fix, r=Veykril
Use diagnostic code as link to full message

fixes #13823 by adding a vscode setting that will keeping the existing diagnostic code and use it as a link to the full compiler error message.
While I was there I also fixed `index` to fallback to `rendered.length` to make the previewRustcOutput feature work.
2023-01-03 09:40:20 +00:00
Alex Veber
ddc0147d53 Fix diagnostic code 2023-01-03 08:33:27 +02:00
Donny/강동윤
4f369427b5 increase limit 2023-01-03 13:16:06 +09:00
bors
e75e2f8368 Auto merge of #13882 - Veykril:bin-op-adjust, r=Veykril
Write down adjustments introduced by binary operators
2023-01-02 22:17:11 +00:00
Lukas Wirth
506895fa2f Fix spelling mistake 2023-01-02 23:16:26 +01:00
Lukas Wirth
f51111aacb Write down adjustments introduced by binary operators 2023-01-02 23:16:09 +01:00
Daniel Eades
bb083b8202 remove useless casts 2023-01-02 15:02:54 +00:00
Daniel Eades
aa90d02079 remove useless operations 2023-01-02 15:02:54 +00:00
Daniel Eades
0a0817905e return value directly from if/else block 2023-01-02 15:02:54 +00:00
Daniel Eades
4f8ffd0ba4 remove unnecessary lifetimes that can be elided 2023-01-02 15:02:54 +00:00
Daniel Eades
8615bba105 use 'unwrap_or_default' 2023-01-02 15:02:54 +00:00
Daniel Eades
efd2c20e96 remove useless conversions 2023-01-02 15:02:54 +00:00
Daniel Eades
cc80c5bd07 remove unnecessary lazy evaluations 2023-01-02 15:02:54 +00:00
Daniel Eades
7530d76f00 use pointer args 2023-01-02 14:52:32 +00:00
Daniel Eades
ed128872eb remove needless borrows 2023-01-02 14:52:32 +00:00
Daniel Eades
77051679d7 use inline format args 2023-01-02 14:52:32 +00:00
bors
17cc78f169 Auto merge of #13832 - Veykril:discriminant-hints, r=Veykril
Enum variant discriminants hints

![image](https://user-images.githubusercontent.com/3757771/209320042-eced617a-9a47-4808-ac23-916f469dc90c.png)
2023-01-02 13:20:33 +00:00
bors
790759fb11 Auto merge of #13854 - lowr:fix/mbe-glue-punct, r=Veykril
Support multi-character punct tokens in MBE

Fixes #11497

In the context of MBE, consecutive puncts are parsed as multi-character punct tokens whenever possible. For example, `:::` is parsed as ``[Punct(`::`), Punct(`:`)]`` and shouldn't get matched to patterns like `: : :` or `: ::`.

We have implemented this behavior only for when we match puncts against `tt` fragments, but not when we match puncts literally. This PR extracts the multi-character punct handling procedure into a separate method and extends its support for literal matching.

For good measure, this PR adds support for `<-` token, which is still [considered as one token in rustc](e396186407/compiler/rustc_ast/src/token.rs (L249)) despite the placement syntax having been removed.
2023-01-02 13:07:42 +00:00
bors
e986de0b28 Auto merge of #13877 - lowr:fix/find-path-prefix-shadowed-prelude, r=Veykril
fix: prefix prelude items whose name collides in current scope

Fixes #13873

When we assemble path for prelude items whose name collides with other item in scope, we should always prefix it with module paths.
2023-01-02 12:11:30 +00:00
Ryo Yoshida
cf2fa14db5
fix: prefix prelude items whose name collides in current scope 2023-01-02 20:50:45 +09:00
Laurențiu Nicola
34bc240e94 Package release artifacts as ZIP 2023-01-01 20:45:08 +02:00
bors
643bc02ded Auto merge of #13875 - Veykril:private-field-diag, r=Veykril
Diagnose private assoc item accesses
2023-01-01 12:25:27 +00:00
Lukas Wirth
eee7de0225 Diagnose private assoc item accesses 2023-01-01 13:24:48 +01:00
bors
f31733b1d6 Auto merge of #13871 - lowr:fix/extract-module-merge-multiple-ranges, r=lnicola
fix: merge multiple intersecting ranges

Fixes #13791

In `check_intersection_and_push()`, there may exist two ranges we should merge with the new one. We've been assuming there should be only one range that intersects, which lead to [this assertion](da15d92a32/crates/text-edit/src/lib.rs (L192)) to fail under specific circumstances.
2022-12-31 14:51:27 +00:00
bors
da15d92a32 Auto merge of #13870 - Veykril:private-field-diag, r=Veykril
Diagnose private field accesses
2022-12-31 13:21:53 +00:00
Lukas Wirth
e3d144d17f Diagnose private field accesses 2022-12-31 14:20:59 +01:00
Ryo Yoshida
332dd6ad6e
fix: merge multiple intersecting ranges 2022-12-31 22:08:53 +09:00
bors
f5e7bf2ea5 Auto merge of #13869 - Veykril:exit-points, r=Veykril
Improve exit point highlighting for non-loop loops in tail position
2022-12-31 11:08:54 +00:00
Lukas Wirth
ec125fe46a Improve exit point highlighting for non-loop loops in tail position 2022-12-31 12:08:25 +01:00
bors
dbeee3445d Auto merge of #13867 - Veykril:meth-res-fallback, r=Veykril
Fallback to invisible associated functions and constants if no visible resolutions are found

Still lacking tests, will add those later
Fixes https://github.com/rust-lang/rust-analyzer/issues/13126
2022-12-31 10:53:30 +00:00
Lukas Wirth
1d782a9095 Add test for private method inference fallback 2022-12-31 11:42:44 +01:00
Daniel Eades
b196e5b2f6 fixup 2022-12-31 09:26:58 +00:00
bors
f1c4150c93 Auto merge of #13868 - lowr:patch/unused-known-names-bye, r=Veykril
minor: remove unused known `Name`s

After #13866, known `Name`s for safe intrinsics are no longer used and thus should be removed.
2022-12-31 08:23:22 +00:00
Ryo Yoshida
0430b68398
Remove unused known Names 2022-12-31 16:17:38 +09:00