Commit graph

21658 commits

Author SHA1 Message Date
Jonas Schievink
63f87ff047 Deprioritize already-imported names 2022-04-11 18:48:27 +02:00
bors[bot]
b1854ceecf
Merge #11958
11958: Show config deseralization failures on start up r=Veykril a=Veykril

We now also show deserialization errors to the user when starting the server.
This PR also adds a small validation "pass" on the config that we will probably populate over time with more checks.

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11950

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-11 11:12:55 +00:00
Lukas Wirth
b90df7997d Add simplistic config validation 2022-04-11 13:10:43 +02:00
Lukas Wirth
6d7055e322 Show config deseralization failures on start up 2022-04-11 13:05:34 +02:00
bors[bot]
7a564af989
Merge #11935
11935: feat: Switch to LSP inlay hints r=lnicola a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-04-11 09:29:15 +00:00
bors[bot]
b1c9a6ba64
Merge #11957
11957: fix panic on GAT r=flodiebold a=skyzh

Signed-off-by: Alex Chi <iskyzh@gmail.com>

This is still a workaround on GAT panic, and didn't solve the full problem. But at least we won't panic now. False positive is better than panicking and letting VSCode constantly pop out the warning 🤣

This PR is simple -- only apply the https://github.com/rust-analyzer/rust-analyzer/pull/11878 fix on const generics. For normal GATs, just follow the previous approach.

This PR fixes https://github.com/rust-analyzer/rust-analyzer/issues/11939, I've added it as a test case.

This PR didn't fully fix / https://github.com/rust-analyzer/rust-analyzer/issues/11923. But at least it won't panic now -- will only give a type mismatch error.

Not sure if it fixes / https://github.com/rust-analyzer/rust-analyzer/issues/11921, I'll test it later.

cc `@flodiebold` for review, thanks!

Co-authored-by: Alex Chi <iskyzh@gmail.com>
2022-04-11 08:03:50 +00:00
Alex Chi
51d66714ac fix panic on GAT
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2022-04-11 13:52:02 +08:00
bors[bot]
24cf957627
Merge #11951
11951: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-10 18:21:54 +00:00
Lukas Wirth
7f3572fa0d Simplify 2022-04-10 20:02:06 +02:00
bors[bot]
55d7415ba4
Merge #11955
11955: Fix typo in the manual r=lnicola a=okuramasafumi

The -> There

Co-authored-by: OKURA Masafumi <masafumi.o1988@gmail.com>
2022-04-10 16:28:40 +00:00
OKURA Masafumi
afe1155e64
Fix typo in the manual
The -> There
2022-04-11 01:17:39 +09:00
bors[bot]
7720f163ae
Merge #11954
11954: Parse `for<'a>` closure syntax r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11716

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-10 15:59:38 +00:00
Lukas Wirth
d8341c5b92 Parse for<'a> closure syntax 2022-04-10 17:50:14 +02:00
bors[bot]
3b40230a32
Merge #11953
11953: fix: `extract_module` is too eager r=Veykril a=iDawer

Refactored `extract_module`.
Searching for usages and import resolving are done lazily.

Close #11944 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2022-04-10 13:31:33 +00:00
iDawer
6fff2c1798 extract_module: Refactor loops 2022-04-09 22:07:44 +05:00
iDawer
1e71ac286b extract_module: Resolve imports lazily 2022-04-09 16:52:53 +05:00
iDawer
031bdf2472 Refactor extract_module 2022-04-09 16:52:53 +05:00
iDawer
c2d12906b0 Clean up extract_module 2022-04-09 16:52:40 +05:00
bors[bot]
e691ae0ab2
Merge #11946
11946: internal: Revert #11912 as it parses all visited files r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-09 11:41:47 +00:00
Lukas Wirth
295f0c57a5 Revert #11912 as it parses all visited files 2022-04-09 13:41:06 +02:00
bors[bot]
9093941ed0
Merge #11943
11943: fix: Don't create `hir::Local`s from const path patterns r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11941

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-08 23:09:18 +00:00
Lukas Wirth
9050db2e80 fix: Don't create hir::Locals from const path patterns 2022-04-09 01:08:13 +02:00
bors[bot]
e11959a82b
Merge #11942
11942: fix: Check whether a parameter can be converted to a local r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11941
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-08 22:56:57 +00:00
Lukas Wirth
15e7112da3 fix: Check whether a parameter can be converted to a local 2022-04-09 00:55:45 +02:00
bors[bot]
399559e597
Merge #11940
11940: minor: bump lsp-server version r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-08 22:14:48 +00:00
Lukas Wirth
2d445de170 minor: bump lsp-server version 2022-04-09 00:13:47 +02:00
bors[bot]
63acf724fa
Merge #11938
11938: feat: improve assoc. item completion in trait impls r=jonas-schievink a=jonas-schievink

Account for macro-generated items, increase the score of these completions since they're very relevant, and allow them to trigger when the cursor is directly in the assoc. item list without requiring further input.

![screenshot-2022-04-08-18:12:06](https://user-images.githubusercontent.com/1786438/162481277-2a0d2f21-dc20-4452-804d-6370766216b6.png)

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

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-08 18:00:41 +00:00
Jonas Schievink
22b13c8bff Make trait item completions work in a bare impl and score them 2022-04-08 19:56:41 +02:00
Jonas Schievink
cdeb6140bf Account for macros in get_missing_assoc_items 2022-04-08 18:05:34 +02:00
bors[bot]
847c552ab3
Merge #11936
11936: Ignore `Drop` and `Destruct` bounds for now r=flodiebold a=flodiebold

- `T: ~const Drop` has a special meaning in Rust 1.61 that we don't implement. (So ideally, we'd only ignore `~const Drop`, but this should be fine for now.)
- `Destruct` impls are built-in in 1.62 (current nightlies), so until the builtin impls are supported by Chalk, we ignore them as well. Since `Destruct` is implemented for everything in non-const contexts IIUC, this should also work fine.

Fixes #11932.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-04-08 12:34:12 +00:00
Florian Diebold
340f0fc333 Ignore Drop and Destruct bounds for now
- `T: ~const Drop` has a special meaning in Rust 1.61 that we don't implement.
  (So ideally, we'd only ignore `~const Drop`, but this should be fine
  for now.)
- `Destruct` impls are built-in in 1.62 (current nightlies as of 08-04-2022), so until
  the builtin impls are supported by Chalk, we ignore them as well.
  Since `Destruct` is implemented for everything in non-const contexts
  IIUC, this should also work fine.

Fixes #11932.
2022-04-08 14:29:43 +02:00
Laurențiu Nicola
bfa2a08da1 Update for languageclient API changes 2022-04-08 14:24:28 +03:00
Laurențiu Nicola
d3d6267112 Switch to LSP inlay hints 2022-04-08 14:10:24 +03:00
bors[bot]
bc56920757
Merge #11931
11931: fix: flyimport: omit types when completing where-clause r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11918

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-07 18:05:21 +00:00
Jonas Schievink
99d91bc550 flyimport: omit types when completing where-clause 2022-04-07 20:02:33 +02:00
bors[bot]
b8ed4a388c
Merge #11920
11920: Consider types of const generics r=flodiebold a=HKalbasi

fix #11913 

We should emit type_mismatch in const generics, probably after #7434. Currently they will lead to a misleading, time of use type error (like the added test).


Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-04-07 17:08:02 +00:00
bors[bot]
ec871bb8b2
Merge #11930
11930: internal: move function unsafety determination out of the ItemTree r=jonas-schievink a=jonas-schievink

Resolves some FIXMEs.

I've also renamed some FnFlags to be more explicit about what they represent (presence of keywords, not necessarily presence of semantics)

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-07 16:38:42 +00:00
Jonas Schievink
5d8b4c40eb Determine function unsafety semantically 2022-04-07 18:33:03 +02:00
bors[bot]
12f803d1e3
Merge #11925
11925: internal: Add and use `HirFormatter::write_{str,char}` r=Veykril a=lnicola

Saves slightly over 3 KB of `text`, but comparing the total with that from two weeks ago in #11776, this is a losing battle (we're 951 KB larger).

```
   text	   data	    bss	    dec	    hex	filename
24693512	1542704	   4424	26240640	1906680	rust-analyzer-baseline
24690216	1542112	   4424	26236752	1905750	rust-analyzer-pr
```


Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-04-07 14:38:46 +00:00
bors[bot]
c9d1105a68
Merge #11927
11927: internal: Use bitflags for `FnFlags` r=jonas-schievink a=jonas-schievink

Previously we didn't do this because it didn't pull its weight, but now we actually do some bitops

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-07 14:27:08 +00:00
Jonas Schievink
c71c30419c Use bitflags for FnFlags 2022-04-07 16:22:34 +02:00
bors[bot]
82fa6ad245
Merge #11926
11926: fix: Fix panics with `#[cfg]`'d-out `self` parameter r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-07 13:56:14 +00:00
Jonas Schievink
16d0f724b6 use stdx::never 2022-04-07 15:55:44 +02:00
Jonas Schievink
67495b618b Fix panics with #[cfg]'d-out self parameter 2022-04-07 15:47:03 +02:00
Laurențiu Nicola
bd570903b0 Add and use HirFormatter::write_{str,char} 2022-04-07 16:41:07 +03:00
bors[bot]
8765baaf9d
Merge #11924
11924: internal: remove `FnFlags::IS_IN_EXTERN_BLOCK` r=jonas-schievink a=jonas-schievink

This flag was determined purely based on the AST, which cannot work reliably since macros are allowed in `extern` blocks (in which case the function would not have an extern block parent in the AST).

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-07 13:23:50 +00:00
Jonas Schievink
6501e45131 Remove FnFlags::IS_IN_EXTERN_BLOCK 2022-04-07 15:22:11 +02:00
hkalbasi
204a1561b2 consider types of const generics 2022-04-07 05:30:33 +04:30
bors[bot]
134dbc6104
Merge #11919
11919: minor: Remove pointless rebindings r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-06 23:34:05 +00:00
Lukas Wirth
3632d5946f minor: Remove pointless rebindings 2022-04-07 01:29:31 +02:00