Commit graph

14757 commits

Author SHA1 Message Date
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
Lee Dogeon
e3f32d13e1 Code blocks with tilde also works like code block 2022-04-01 20:29:32 +09:00
Jake Vossen
bccf013010 create generate is, as, try_into group 2022-03-31 21:22:08 -06:00
Felix Maurer
feb8ccacba Add test against line number underflow 2022-03-31 23:37:23 +02:00
Felix Maurer
a98ffe4268 Prevent underflow when converting line numbers
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.
2022-03-31 23:00:48 +02:00
Jonas Schievink
42ecf406e8 Remove parser restriction on varargs positioning 2022-03-31 16:03:27 +02:00
bors[bot]
9b000b544b
Merge #11827
11827: internal: Enforce Invariant that Resolver always contains a ModuleScope r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-31 13:01:10 +00:00
Jonas Schievink
ec2d023383 Add "view file text" command to debug sync issues 2022-03-31 14:50:33 +02:00
Lukas Wirth
75689f2ad8 internal: Enforce Resolver to always have a module scope 2022-03-31 11:12:08 +02:00
Aleksei Trifonov
41d8369d1c Fix formatting 2022-03-31 02:59:15 +03:00
Aleksei Trifonov
0d1f4f9b27 Lower postfix suggestions in completions list 2022-03-31 02:27:33 +03:00
Lukas Wirth
ef92453dfe internal: Refactor FamousDefs builtin crate search 2022-03-30 22:23:54 +02:00
Manas
1be8b2ff98 Type mismatch when last expression is noreturn asm
When last expression in a function body is noreturn asm, then analyzer
complains about the type mismatch by highlighting entire body. This
fixes it by introducing loop {} in the expanded code.
2022-03-30 19:07:02 +05:30
Gibson Fahnestock
6b38c2d75e
docs(auto_import): change by_self -> self and by_crate -> crate
Keep things consistent with the package.json , which uses `self` and
`crate` instead of `by_self` and `by_crate`. Both names are in fact
allowed as aliases, but we should be consistent so that people reading
the docs and using a schema do not see red squiggles.
2022-03-30 12:33:07 +01:00
Florian Diebold
ea1d0bccef Fix divergence detection for bare match arms
Fixes #11814 and #11837.
2022-03-29 21:56:49 +02:00
Florian Diebold
0c4bdd2f32 Fix duplicate type mismatches with blocks
E.g. when there's a type mismatch on the return value of a function. To
fix this, we have to return the expected type as the type of the block
when there's a mismatch. That meant some IDE code that expected
otherwise had to be adapted, in particular the "add return type" assist.
For the "wrap in Ok/Some" quickfix, this sadly means it usually can't be applied
in all branches of an if expression at the same time anymore, because
there's a type mismatch for each branch that has the wrong type.
2022-03-29 18:06:52 +02:00
bors[bot]
89d495eb30
Merge #11840
11840: Fix another const generic panic r=flodiebold a=HKalbasi

fix #11835

If I change `dyn` to `impl` in the test, it will infer the type as `IntoIterator::Item<impl Iterator<Item = [Ar<u8, 7>; 9]> + ?Sized>` instead of `[Ar<u8, 7>; 9]`. Maybe it needs some action?

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-03-29 10:55:17 +00:00
hkalbasi
4fe0545bb6 fix regression_11688_3 2022-03-29 11:03:55 +04:30
Florian Diebold
c2a31bfbb8 Remove legacy_const_generics_indices from CallableSig
I want to remove CallableSig anyway, and it's not needed anymore.
2022-03-27 19:21:09 +02:00
Florian Diebold
2be7e26d7d Move mismatched-arg-count diagnostic to inference 2022-03-27 19:21:09 +02:00
Florian Diebold
9a427839fa fix: Disable ref_match for qualified paths as well
I.e. don't suggest `Foo::&foo()`.

CC #8058.
2022-03-27 12:50:55 +02:00
Laurențiu Nicola
85f797f59c Bump chalk 2022-03-27 10:11:02 +03:00
bors[bot]
4d05d29fad
Merge #11825
11825: fix: Don't complete `Drop::drop` for qualified paths r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-26 18:49:41 +00:00
Laurențiu Nicola
03cb7d9448 Revert "Emit #[must_use] in Generate new assist"
This reverts commit 7e05e10495.
2022-03-26 20:39:36 +02:00
Lukas Wirth
0ae795136d Sort runnable test results to make them deterministic 2022-03-26 19:38:20 +01:00
Lukas Wirth
9b046d1051 fix: Don't complete Drop::drop for qualified paths 2022-03-26 18:46:49 +01:00