Commit graph

14984 commits

Author SHA1 Message Date
Jonas Schievink
dd4a92176c Prefer core/alloc over std if no_std is conditional 2022-04-20 14:07:40 +02:00
rainy-me
a58f7acc97 fix: improve parameter completion 2022-04-20 17:56:20 +09:00
Jonas Schievink
c6ffffccbd Allows triggering commands after an assist edit 2022-04-19 18:45:48 +02:00
Lukas Wirth
f8c32df7cd minor: Document completion context some more 2022-04-18 16:54:13 +02:00
bors
e0d41bc2a1 Auto merge of #12021 - Veykril:completion-ctx, r=Veykril
internal: Add a `NameContext` to `CompletionContext`, move out some ImmediateLocation variants

Continues the completion rewrite I started some time ago
(will merge tomorrow after stable since our completion tests still let a lot through)
2022-04-18 14:00:56 +00:00
XFFXFF
fedd0245d1 derive completions take existing derives into count 2022-04-18 21:34:36 +08:00
Edwin Cheng
72fcc66835 More visibility for switch workspaces and its states 2022-04-18 14:26:00 +08:00
Lukas Wirth
ff667c7228 internal: Add a NameContext to CompletionContext, move out some ImmediateLocation variants 2022-04-17 21:53:58 +02:00
Laurențiu Nicola
117f902d55 Bump deps 2022-04-17 19:36:08 +03:00
bors
a45a63e577 Auto merge of #12013 - XFFXFF:associated_const_equality, r=Veykril
fix: support `associated_const_equality` in parser

This pr fixes #11965.  The parser now allows eq constraints on associated constants.

I've added tests for `HasCount<Count = {N}>` and `HasCount<Count = 0>`
2022-04-17 13:05:47 +00:00
XFFXFF
6580d75308 update parser to support associated const equality 2022-04-17 20:26:06 +08:00
Lukas Wirth
3de9a42810 Disable rustfmt for expand_macro on wasm platforms 2022-04-17 14:00:19 +02:00
Lukas Wirth
895a16265c Fix macro patterns not getting formatted properly 2022-04-17 13:46:00 +02:00
Lukas Wirth
e2f1a9a558 feat: Attempt to format expand_macro output with rustfmt if possible 2022-04-17 13:33:39 +02:00
XFFXFF
bdecd9374e update grammer to support associated const equality 2022-04-17 12:03:52 +08:00
bors
53afd2a707 Auto merge of #12011 - iDawer:completion_detail.impl_trait, r=Veykril
fix: Show `impl Trait` in argument positon in completion details

Follow up for #11991

`hir`: Use `db.callable_item_signature` query more.
2022-04-16 21:13:07 +00:00
iDawer
d26deb5b9f Show impl Trait in argument positon in completion details
`hir`: Use `db.callable_item_signature` query more.
2022-04-16 19:18:42 +05:00
Aleksey Kladov
3f4235d59b internal: more visibility into why things happen 2022-04-16 13:17:27 +01:00
Lukas Wirth
6f037da8cb fix: Fix proc-macro change check being inverted 2022-04-16 12:36:31 +02:00
iDawer
c53412046f minor: address nit 2022-04-16 13:54:24 +05:00
iDawer
03c5dd1252 extract_function: use appropriate return type for async fns 2022-04-16 13:54:24 +05:00
iDawer
9d787e1bfe Add hir::Function::async_ret_type method
Adjust completion detail for `async fn` return types
2022-04-16 13:53:22 +05:00
iDawer
f972adc201 fix: comletion detail shows {unknown} for impl Trait in return position 2022-04-16 13:41:10 +05:00
bors
1c22537b3b Auto merge of #12005 - Veykril:hir-ty-simplify, r=Veykril
internal: Remove frequent `Arc<Body>` clones in type checking

bors r+
2022-04-15 20:23:15 +00:00
Lukas Wirth
e5bf60fee2 minor: Remove frequent Arc<Body> clones in type checking 2022-04-15 21:44:47 +02:00
Lukas Wirth
f82d230081 Simplify 2022-04-15 21:25:44 +02:00
bors
e10284a10c Auto merge of #12003 - Veykril:hir-ty-simplify, r=Veykril
internal: Remove duplicated crate id field from hir::Type
2022-04-15 18:25:02 +00:00
Lukas Wirth
17691ee974 Slightly optimize Resolver::krate 2022-04-15 20:17:50 +02:00
Lukas Wirth
4b4a34327e Remove duplicated crate id field from hir::Type 2022-04-15 20:14:35 +02:00
bors
20e6065a7a Auto merge of #12002 - Veykril:proc-macro-change-panic, r=Veykril
fix: Fix source root panic in global state when checking out older git revs

Fixes https://github.com/rust-lang/rust-analyzer/issues/11357
2022-04-15 18:02:40 +00:00
Lukas Wirth
f540d1c2aa fix: Fix source root panic in global state when checking out older git revs 2022-04-15 20:02:15 +02:00
bors
a912f2a9f6 Auto merge of #12001 - Veykril:refs, r=Veykril
fix: Do reference search on all downmapped tokens with the same kind only

cc https://github.com/rust-lang/rust-analyzer/issues/11668
2022-04-15 17:43:24 +00:00
Lukas Wirth
58660dee2a fix: Do reference search on all downmapped tokens with the same kind only 2022-04-15 19:42:48 +02:00
bors
5e41205e9c Auto merge of #12000 - Veykril:hlmac, r=Veykril
fix: Tag `macro_rules` macro bang with `MacroBang` tag

cc https://github.com/rust-lang/rust-analyzer/issues/11996
2022-04-15 17:19:33 +00:00
Lukas Wirth
be27efabfa fix: Tag macro_rules macro bang with MacroBang tag 2022-04-15 19:16:18 +02:00
Jonas Schievink
1fd232cd69 Enable ADT keyword completions in block expression 2022-04-14 18:39:27 +02:00
Jonas Schievink
d764e134d5 Fallback to primitive when path doesn't resolve 2022-04-14 15:51:38 +02:00
bors
63573d47aa Auto merge of #11971 - jonas-schievink:on-type-fmt-assignments, r=jonas-schievink
feat: Add trailing `;` when typing `=` in assignment

![Peek 2022-04-12 19-41](https://user-images.githubusercontent.com/1786438/163022079-1ed114ef-7c75-490f-a8ed-731a13f0b44d.gif)

This does have a false positive to keep in mind, it will add a trailing `;` in the following snippet too, which is probably not desired:

```rust
fn is_zero(i: i32) -> bool {
    i $0 0
}
```

However, that function is unlikely to be written from the "inside out" like that, so it might be acceptable. Typically `=` is only inserted last when the author realizes that an existing expression should be assigned to some variable.
2022-04-14 12:36:17 +00:00
Jonas Schievink
fbded178fa Improve ItemTree pretty print output 2022-04-14 14:24:27 +02:00
Jonas Schievink
f96fd40104 add docs 2022-04-14 13:23:19 +02:00
Jonas Schievink
72dcfe6cc6 reenable test 2022-04-14 13:02:20 +02:00
Jonas Schievink
f5403aef96 simplify 2022-04-14 13:00:08 +02:00
bors
5620d25972 Auto merge of #11985 - Veykril:config-valid, r=Veykril
minor: Simplify config.rs a bit
2022-04-14 10:16:58 +00:00
Lukas Wirth
d7785a8fab minor: Cleanup config.rs a bit 2022-04-14 12:16:38 +02:00
bors
13f36e7397 Auto merge of #11960 - Veykril:config-valid, r=Veykril
internal: Show more project building errors to the user

Should help out with https://github.com/rust-analyzer/rust-analyzer/issues/9720
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11223
2022-04-14 09:36:08 +00:00
Lukas Wirth
b23b276310 internal: Show more project building errors to the user 2022-04-14 11:31:01 +02:00
Alex Touchet
940ec0967a Update repo URL 2022-04-13 16:54:24 -07:00
bors
15844bf48c Auto merge of #11956 - fee1-dead:master, r=flodiebold
feat: allow customizing the command for running build scripts

I have tested this locally and it fixed #9201 with some small changes on the compiler side with suggestions from https://github.com/rust-analyzer/rust-analyzer/issues/9201#issuecomment-1019554086.

I have also added an environment variable `IS_RA_BUILDSCRIPT_CHECK` for crates to detect that it is a check for buildscripts, and allows defaulting to bogus values for expected environment variables.
2022-04-13 22:53:31 +00:00
Deadbeef
8b60bf6764 Update CI for Rust bors 2022-04-13 16:55:10 +02:00
Jonas Schievink
99e9e52fbc Remove trailing ; when turning assignment into == comparison 2022-04-13 16:01:09 +02:00
Jonas Schievink
b9dd7db817 Add more no-op tests 2022-04-13 15:47:33 +02:00
Deadbeef
73a033e77c
feat: allow customizing the command for running build scripts 2022-04-13 23:45:51 +10:00
Jonas Schievink
cde2a1de36 Add trailing ; when typing = in assignment 2022-04-12 19:39:19 +02:00
Laurențiu Nicola
5901eddb02 Bump chalk 2022-04-12 20:10:10 +03:00
Jonas Schievink
a182156517 Add trailing ; when completing assoc const/type 2022-04-12 18:28:43 +02:00
bors[bot]
a64a70ebff
Merge #11967
11967: fix: Fix trait impl completions not triggering after `fn`/`const`/`type` r=jonas-schievink a=jonas-schievink

![screenshot-2022-04-12-17:13:01](https://user-images.githubusercontent.com/1786438/162996087-56540f5e-a6be-4111-a4a5-8de21f483a5e.png)

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11467
cc https://github.com/rust-analyzer/rust-analyzer/issues/11860

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-12 16:03:12 +00:00
Jonas Schievink
3328a0a11b Fix trait impl completions' lookup_by text 2022-04-12 17:17:31 +02:00
bors[bot]
49847a25ae
Merge #11883
11883: fix(ide): move moudle directory when rename r=rainy-me a=rainy-me

fix: #10992

Added `FileSystemEdit::MoveDir` variant for move dirs. Original implemented as recursively move child mod files but had many issues like

1. left empty dir after rename file
2. only affect rust file
3. not performant

so changed to current version

Co-authored-by: rainy-me <github@yue.coffee>
2022-04-12 15:17:00 +00:00
rainy-me
3dd581b97d fix: move dir on rename mod 2022-04-12 23:01:53 +09:00
Jonas Schievink
e66037f139 simplify 2022-04-12 15:34:12 +02:00
bors[bot]
faaec86ff0
Merge #11964
11964: internal: Show more project building errors to the user r=Veykril a=Veykril

Something very fishy is going on with the `rustc_workspace` handling, which caused this bug to only manifest in the `std` library but not other library crate... So there is either a bug there or just the fact that we seem to add duplicate dependencies (I think this is what we are doing with this right?) might be tripping something up somewhere.

cc https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Rust-analyzer.20use.20inside.20stdlib

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-11 22:21:57 +00:00
Lukas Wirth
24af94b474 fix: Unset test feature in rustc source crates 2022-04-12 00:19:40 +02:00
Jonas Schievink
63f87ff047 Deprioritize already-imported names 2022-04-11 18:48:27 +02: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
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]
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
Lukas Wirth
295f0c57a5 Revert #11912 as it parses all visited files 2022-04-09 13:41:06 +02:00
Lukas Wirth
9050db2e80 fix: Don't create hir::Locals from const path patterns 2022-04-09 01:08:13 +02: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
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
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
d3d6267112 Switch to LSP inlay hints 2022-04-08 14:10:24 +03: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
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
Jonas Schievink
c71c30419c Use bitflags for FnFlags 2022-04-07 16:22:34 +02: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
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
Lukas Wirth
3632d5946f minor: Remove pointless rebindings 2022-04-07 01:29:31 +02:00
Lukas Wirth
96b641e95e internal: Add more doc-link tests 2022-04-06 20:58:46 +02:00
Lukas Wirth
4a1423337f fix: Attempt to resolve paths in const arguments heuristically
While we don't support const args in type inference yet, we can at least
make use of the fallback path resolution to resolve paths in const args
in the IDE layer to enable some features for them.
2022-04-06 20:24:24 +02:00
Lukas Wirth
7959c24876 fix: Fix path qualifiers not resolving generic type params when shadowed by trait 2022-04-06 19:38:45 +02:00
Lukas Wirth
4e6390bb12 Fix SearchScope::reverse_dependencies trying to search more files than necessary 2022-04-06 14:24:06 +02:00
Lukas Wirth
d9f6cee100 fix: Fix SearchScope using incorrect text ranges for macro-emitted inline modules 2022-04-06 13:58:40 +02:00
bors[bot]
2366d8e05f
Merge #11905
11905: internal: Remove hir_expand macro recursion check r=jonas-schievink a=jonas-schievink

This check is insufficient to ensure finite macro nesting, and so all callers already have their own recursion limit, which makes this check redundant.

...at least I hope it's redundant. Would be great if someone could double-check this.

Originally, this check was added in https://github.com/rust-analyzer/rust-analyzer/pull/3671

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-04-05 17:00:56 +00:00
bors[bot]
ee6becc5dd
Merge #11891
11891: Better error message on Flycheck Error message (from: unactionable error message if we are using `clippy` as the checker) r=Veykril a=flipbit03

I have commented on this [S-unactionable issue](https://github.com/rust-analyzer/rust-analyzer/issues/6589) that the Flycheck error message should maybe provide a hint about what tool it actually runs. Searching on some places on the Internet I've found multiple people, including myself, losing copious amounts of time on the same issue. So I've decided to make this very small PR :-)

From an user experience standpoint, the current error message is unhelpful to the end user, because the end user does not know exactly what it needs to check/fix (outdated, broken, or missing `cargo clippy`). In my own case, `cargo clippy` was actually missing altogether (developing off `rust:1.59.0-bullseye` official Docker image).

Thanks in advance!




Co-authored-by: Cadu <cadu.coelho@gmail.com>
2022-04-05 16:31:18 +00:00
Jonas Schievink
9de54570d6 Remove hir_expand macro recursion check 2022-04-05 17:59:48 +02:00
Jonas Schievink
872b7b9660 Wrap macros in expr position in MacroExpr node 2022-04-05 17:43:34 +02:00
Cadu
84cf6ad091 Using error instead of output.stderr in failure mode. 2022-04-05 11:17:39 -03:00
Cadu
ca9718aa42 Made error output the contents of Cargo's stderr as well. 2022-04-04 19:15:20 -03:00
Cadu
8e5c57f050 wordsmithing. 2022-04-04 19:15:20 -03:00
Cadu
635270d4ad Better error message hinting about cargo clippy 2022-04-04 19:15:20 -03:00
iDawer
86665e50c2 fix: Skip match check on a pattern of unexpected TyKind::FnDef 2022-04-05 00:05:20 +05:00
bors[bot]
bf6303df37
Merge #11896
11896: fix: Show the path to be created in the unresolved-module fix label r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-04 14:14:26 +00:00
Lukas Wirth
3a847eacc8 fix: Show the path to be created in the unresolved-module fix label 2022-04-04 16:04:09 +02:00
bors[bot]
f5c069c9d9
Merge #11894
11894: complete pattern args based on type name r=Veykril a=cameron1024

Addresses #11892 

Changes function argument completion to cover a case like this:
```rust
struct Foo { bar: i32 }

fn qux(Foo { bar }: Foo) {
  println!("{bar}");
}
```
When completing the function call for `qux`, instead of expanding to `qux(_)`, it will now expand to `qux(foo)` (based on the snake-cased version of the name of the ADT)

Non ADTs are unaffected


Co-authored-by: cameron <cameron.studdstreet@gmail.com>
Co-authored-by: cameron1024 <cameron.studdstreet@gmail.com>
2022-04-04 13:06:51 +00:00
cameron1024
37d2a8243f
Update crates/ide_completion/src/render/function.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-04 13:33:14 +01:00
cameron
bb1c3a20b5 fix type error 2022-04-04 14:30:49 +01:00
cameron
2137bdfca3 remove unwarp on adt name 2022-04-04 14:28:15 +01:00
cameron
c735b979ed complete pattern args based on type name 2022-04-04 13:51:51 +01:00
bors[bot]
46d7ee68f2
Merge #11865
11865: Fix: Select correct insert position for disabled group import r=jonasbb a=jonasbb

The logic for importing with and without `group_imports` differed
significantly when no previous group existed. This lead to the problem
of using the wrong position when importing inside a module (#11585) or
when inner attributes are involved.
The existing code for grouped imports is better and takes these things
into account.

This PR changes the flow to use the pre-existing code for adding a new
import group even for the non-grouped import settings.
Some coverage markers are updated and the `group` is removed, since they
are now invoked in both cases (grouping and no grouping).

Tests are updated and two tests (empty module and inner attribute) are
added.

Fixes #11585

Co-authored-by: Jonas Bushart <jonas@bushart.org>
2022-04-03 18:46:45 +00:00
Jonas Bushart
156f9074e1 Use check_count! instead of multiple check! in separate scopes
Changes are based on the review feedback by Veykril.
2022-04-03 18:34:06 +00:00
bors[bot]
65eaabc200
Merge #11887
11887: fix: Add missing fields diagnostic fix for patterns r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-03 13:42:15 +00:00
Lukas Wirth
dd3f7664fd fix: Add missing fields diagnostic fix for patterns 2022-04-03 15:18:05 +02:00
bors[bot]
63d2df1e36
Merge #11699
11699: feat: assist to remove unneeded `async`s r=Ethiraric a=Ethiraric

This should fix #11392 

This PR adds a quickfix on functions marked with `async` that suggests, if and only if no `await` expression in find in the body of the function (it relies on `SyntaxNode::descendants()` to recursively traverse blocks), to remove the `async` keyword.

The lint is made so that it triggers only if the cursor is not in the body of the function, so that it does not pollute the quickfix list.

It does not trigger a diagnostic. I don't know if this repository is the place to implement those (`clippy`?). If it is, I would very much like pointers on where to start looking.

If there are test cases I haven't thought about, please do suggest.

Co-authored-by: Ethiraric <ethiraric@gmail.com>
2022-04-03 12:42:52 +00:00
Ethiraric
520557d45c feat: assist to remove unneeded asyncs 2022-04-03 14:34:08 +02:00
bors[bot]
bc0825d135
Merge #10802
10802: Allow clients to configure the global workspace search limit r=Veykril a=knutwalker

Playing around with [helix](https://helix-editor.com) I realized that the global worksapce symbol search works different compared to vs-code.
Helix requires all possible symbols in one query and does no subsequent refinement searched.
This PR adds a configuration option to override the default search limit with the default being the currently hardocded value.
Helix users can increment this limit for their instance with a config like

```toml
[[language]]
name = "rust"
language-server = { command = "rust-analyzer" }
[language.config]
workspace = { symbol = { search = { limit = 65536 }}}
```

Other editors are not affected by this change.


Co-authored-by: Paul Horn <dev@knutwalker.engineer>
2022-04-03 12:03:46 +00:00
Jonas Bushart
0cc079f3e9 Merge test functions using the same coverage marks to avoid parallelism 2022-04-03 12:01:11 +00:00
bors[bot]
5b5ca0bd17
Merge #11866
11866: fix: Prevent underflow in range conversion  r=Veykril a=skyfmmf

Previously, when line numbers of Rust spans were converted to LSP ranges, they could underflow resulting in very large line numbers. As an underflow is always wrong, prevent it and use 0 instead.

This was noticed when opening an empty file in `src/bin/` of a library crate. In this case rustc produces a span with `"line_start": 0, "line_end": 0` resulting in the underflow.

Co-authored-by: Felix Maurer <felix@felix-maurer.de>
2022-04-03 11:49:23 +00:00
Aleksey Kladov
a8f460209d add test for postfix completion relevance
Follow up to #11857, add a test and cov-marks
2022-04-03 12:13:26 +01:00
bors[bot]
4204e35563
Merge #11879
11879: Suggest infered type in auto complete r=HKalbasi a=HKalbasi

fix #11855

It doesn't work for return types and consts (so their tests are failing) because I can't find their body node in the original file. (Are these original and fake file documented somewhere?)

Also it currently needs to type first character of the type (or manual ctrl+space) to open the auto complete panel, is it possible to open it automatically on typing `:` and `->`?


Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-04-03 07:05:41 +00:00
hkalbasi
003a6b74e4 suggest infered type in auto complete 2022-04-03 11:17:33 +04:30
bors[bot]
ba9aed19c7
Merge #11877
11877: fix: splitting path of a glob import wrongly adds `self` r=Veykril a=iDawer

Close  #11703 

`ast::UseTree::split_prefix` handles globs now.
Removed an extra branch for globs in `ide_db::imports::merge_imports::recursive_merge` (superseeded by split_prefix).

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2022-04-02 22:12:59 +00:00
bors[bot]
d312b4519a
Merge #11882
11882: internal: Record outline child modules with missing backing file in def map r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-02 14:19:38 +00:00
Lukas Wirth
1da2d82f58 internal: outline child modules with missing backing file 2022-04-02 16:17:54 +02:00
Florian Diebold
b898808a35 fix: Don't rely on lang items to find primitive impls
rustc has removed the use of lang items to mark the primitive impls, so
just look through the crate graph for them (this should be fine
performance-wise since we cache the crates that contain these impls).

Fixes #11876.
2022-04-02 15:32:40 +02:00
bors[bot]
5fe366c649
Merge #11878
11878: fix: Paper over GAT panic r=flodiebold a=flodiebold

TIL that Chalk expects the arguments to a generic associated type to come *before* the ones for the parent trait, not *after* as we have been doing with all other nested generics. Fixing this requires a larger refactoring, so for now this just papers over the problem by completely ignoring parameters of associated types.

Fixes #11769.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-04-02 12:41:14 +00:00
Florian Diebold
019f48673a fix: Paper over GAT panic
TIL that Chalk expects the arguments to a generic associated type to
come *before* the ones for the parent trait, not *after* as we have been
doing with all other nested generics. Fixing this requires a larger
refactoring, so for now this just papers over the problem by completely
ignoring parameters of associated types.

Fixes #11769.
2022-04-02 13:14:42 +02:00
iDawer
c8c21aabff fix: merge_imports::recursive_merge exiting early 2022-04-02 14:18:42 +05:00
Lukas Wirth
f610e2c2ed Simplify completion import insertion 2022-04-02 01:42:21 +02:00
Lukas Wirth
28251e486c Cleanup relevance scoring 2022-04-02 01:19:33 +02:00
bors[bot]
a9ae0b0855
Merge #11857
11857: Lower postfix suggestions in completions list r=Veykril a=avrong

Fixes #11850

Adds a parameter for postfix suggestions in `CompletionRelevance`, and basing on it, decreases relevance score of such items in completion list

Co-authored-by: Aleksei Trifonov <avrong@avrong.me>
2022-04-01 21:42:54 +00:00
bors[bot]
0e02522b1b
Merge #11874
11874: minor: enum variant wording r=Veykril a=jakevossen5

As discussed on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/generate.20_.20for.20.22an.20enum.20variant.22



Co-authored-by: Jake Vossen <jake@vossen.dev>
2022-04-01 21:30:32 +00:00
Jake Vossen
93a8fcf7a8 enum variant wording 2022-04-01 14:22:49 -06:00
Aleksei Trifonov
eda4046a05 Introduce postfix item types 2022-04-01 20:50:27 +03:00
bors[bot]
ce8e028e9b
Merge #11872
11872: internal: Remove `PathResolution::AssocItem` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-01 17:12:44 +00:00
Lukas Wirth
c290e68ff9 internal: Remove PathResolution::AssocItem 2022-04-01 18:32:05 +02:00
bors[bot]
f8a21e4c70
Merge #11870
11870: Recover from missing type annotation r=Veykril a=HKalbasi

We were missing the init expression in case of `let x: = 2`, which breaks type inference of that variable (previously x were `{unknown}`, now it is `i32`).


Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-04-01 15:33:01 +00:00
bors[bot]
b337a49d21
Merge #11871
11871: internal: Move `rust.ungram` into `rust-analyzer/crates/syntax` r=Veykril a=Veykril

This makes updating the grammar a lot simpler for us. Though removing it from ungrammar can't be done without bumping it to 2.0 so I'll leave it in there for the time being.
cc https://github.com/rust-analyzer/ungrammar/pull/47

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-01 15:17:03 +00:00
Lukas Wirth
0d1d1dc3d9 internal: Move rust.ungram into rust-analyzer/crates/syntax 2022-04-01 17:12:33 +02:00
iDawer
b4c608896c fix: splitting path of a glob import wrongly adds self
`ast::UseTree::split_prefix` handles globs now.
Removed an extra branch for globs in `ide_db::imports::merge_imports::recursive_merge` (superseeded by split_prefix).
2022-04-01 19:12:50 +05:00
hkalbasi
049f0a6d2c recover from missing type annotation 2022-04-01 17:20:54 +04:30
bors[bot]
50225fe630
Merge #11869
11869: fix: code blocks with tilde also works like code block r=Veykril a=moreal

The `rustdoc` uses the `pulldown_cmark` package to parse *doc_comment* and the package also treat triple `~` characters also as code block fences. So when we run `cargo doc`, they will be placed also.

<img width="965" alt="image" src="https://user-images.githubusercontent.com/26626194/161208072-5a09a209-57fc-4a52-b190-b0a9be9ffcd6.png">

But `rust-analyzer` doesn't support it so it doesn't have any injected code highlights and any `Run doctest` hint. This pull request tries to allow also them. 🙇🏻‍♂️ 

Before:

<img width="224" alt="image" src="https://user-images.githubusercontent.com/26626194/161207405-b1d6cfda-82b1-4f60-8e42-c51d0ed98f38.png">

After:

<img width="161" alt="image" src="https://user-images.githubusercontent.com/26626194/161207693-8e39997c-9ca6-4e69-8c65-e9b70899f7db.png">


Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
2022-04-01 12:40:51 +00:00