]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agominor: bump lsp-server version
Lukas Wirth [Fri, 8 Apr 2022 22:13:47 +0000 (00:13 +0200)]
minor: bump lsp-server version

2 years agoMerge #11920
bors[bot] [Thu, 7 Apr 2022 17:08:02 +0000 (17:08 +0000)]
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>
2 years agoMerge #11930
bors[bot] [Thu, 7 Apr 2022 16:38:42 +0000 (16:38 +0000)]
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>
2 years agoDetermine function unsafety semantically
Jonas Schievink [Thu, 7 Apr 2022 16:33:03 +0000 (18:33 +0200)]
Determine function unsafety semantically

2 years agoMerge #11925
bors[bot] [Thu, 7 Apr 2022 14:38:46 +0000 (14:38 +0000)]
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>
2 years agoMerge #11927
bors[bot] [Thu, 7 Apr 2022 14:27:08 +0000 (14:27 +0000)]
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>
2 years agoUse bitflags for `FnFlags`
Jonas Schievink [Thu, 7 Apr 2022 14:13:37 +0000 (16:13 +0200)]
Use bitflags for `FnFlags`

2 years agoMerge #11926
bors[bot] [Thu, 7 Apr 2022 13:56:14 +0000 (13:56 +0000)]
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>
2 years agouse stdx::never
Jonas Schievink [Thu, 7 Apr 2022 13:55:44 +0000 (15:55 +0200)]
use stdx::never

2 years agoFix panics with `#[cfg]`'d-out `self` parameter
Jonas Schievink [Thu, 7 Apr 2022 13:47:03 +0000 (15:47 +0200)]
Fix panics with `#[cfg]`'d-out `self` parameter

2 years agoAdd and use HirFormatter::write_{str,char}
Laurențiu Nicola [Thu, 7 Apr 2022 13:41:07 +0000 (16:41 +0300)]
Add and use HirFormatter::write_{str,char}

2 years agoMerge #11924
bors[bot] [Thu, 7 Apr 2022 13:23:50 +0000 (13:23 +0000)]
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>
2 years agoRemove `FnFlags::IS_IN_EXTERN_BLOCK`
Jonas Schievink [Thu, 7 Apr 2022 13:22:11 +0000 (15:22 +0200)]
Remove `FnFlags::IS_IN_EXTERN_BLOCK`

2 years agoconsider types of const generics
hkalbasi [Thu, 7 Apr 2022 01:00:33 +0000 (05:30 +0430)]
consider types of const generics

2 years agoMerge #11919
bors[bot] [Wed, 6 Apr 2022 23:34:05 +0000 (23:34 +0000)]
Merge #11919

11919: minor: Remove pointless rebindings r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agominor: Remove pointless rebindings
Lukas Wirth [Wed, 6 Apr 2022 23:29:31 +0000 (01:29 +0200)]
minor: Remove pointless rebindings

2 years agoMerge #11916
bors[bot] [Wed, 6 Apr 2022 18:59:13 +0000 (18:59 +0000)]
Merge #11916

11916: internal: Add more doc-link tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agointernal: Add more doc-link tests
Lukas Wirth [Wed, 6 Apr 2022 18:49:10 +0000 (20:49 +0200)]
internal: Add more doc-link tests

2 years agoMerge #11915
bors[bot] [Wed, 6 Apr 2022 18:27:13 +0000 (18:27 +0000)]
Merge #11915

11915: fix: Attempt to resolve paths in const arguments heuristically in IDE layer r=Veykril a=Veykril

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.

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Attempt to resolve paths in const arguments heuristically
Lukas Wirth [Wed, 6 Apr 2022 18:22:12 +0000 (20:22 +0200)]
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.

2 years agoMerge #11914
bors[bot] [Wed, 6 Apr 2022 17:39:20 +0000 (17:39 +0000)]
Merge #11914

11914: fix: Fix path qualifiers not resolving generic type params when shadowed by trait r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix path qualifiers not resolving generic type params when shadowed by trait
Lukas Wirth [Wed, 6 Apr 2022 17:38:45 +0000 (19:38 +0200)]
fix: Fix path qualifiers not resolving generic type params when shadowed by trait

2 years agoMerge #11912
bors[bot] [Wed, 6 Apr 2022 12:24:58 +0000 (12:24 +0000)]
Merge #11912

11912: Fix `SearchScope::reverse_dependencies` trying to search more files than necessary r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoFix `SearchScope::reverse_dependencies` trying to search more files than necessary
Lukas Wirth [Wed, 6 Apr 2022 12:24:06 +0000 (14:24 +0200)]
Fix `SearchScope::reverse_dependencies` trying to search more files than necessary

2 years agoMerge #11911
bors[bot] [Wed, 6 Apr 2022 12:00:35 +0000 (12:00 +0000)]
Merge #11911

11911: fix: Fix SearchScope using incorrect text ranges for macro-emitted inline modules r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix SearchScope using incorrect text ranges for macro-emitted inline modules
Lukas Wirth [Wed, 6 Apr 2022 11:58:40 +0000 (13:58 +0200)]
fix: Fix SearchScope using incorrect text ranges for macro-emitted inline modules

2 years agoMerge #11905
bors[bot] [Tue, 5 Apr 2022 17:00:56 +0000 (17:00 +0000)]
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>
2 years agoMerge #11891
bors[bot] [Tue, 5 Apr 2022 16:31:18 +0000 (16:31 +0000)]
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>
2 years agoRemove hir_expand macro recursion check
Jonas Schievink [Tue, 5 Apr 2022 15:59:48 +0000 (17:59 +0200)]
Remove hir_expand macro recursion check

2 years agoMerge #11904
bors[bot] [Tue, 5 Apr 2022 15:48:09 +0000 (15:48 +0000)]
Merge #11904

11904: internal: Wrap macros in expr position in `MacroExpr` node r=jonas-schievink a=jonas-schievink

This lets us distinguish them from macros in item position just by looking at the syntax tree.

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

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoWrap macros in expr position in `MacroExpr` node
Jonas Schievink [Tue, 5 Apr 2022 15:42:07 +0000 (17:42 +0200)]
Wrap macros in expr position in `MacroExpr` node

2 years agoUsing `error` instead of `output.stderr` in failure mode.
Cadu [Tue, 5 Apr 2022 14:17:39 +0000 (11:17 -0300)]
Using `error` instead of `output.stderr` in failure mode.

2 years agoMade error output the contents of Cargo's stderr as well.
Cadu [Mon, 4 Apr 2022 22:14:33 +0000 (19:14 -0300)]
Made error output the contents of Cargo's stderr as well.

2 years agowordsmithing.
Cadu [Sun, 3 Apr 2022 17:06:36 +0000 (14:06 -0300)]
wordsmithing.

2 years agoBetter error message hinting about `cargo clippy`
Cadu [Sun, 3 Apr 2022 16:48:10 +0000 (13:48 -0300)]
Better error message hinting about `cargo clippy`

2 years agoMerge #11899
bors[bot] [Mon, 4 Apr 2022 20:08:37 +0000 (20:08 +0000)]
Merge #11899

11899: fix: Skip match check on patterns of unexpected TyKind::FnDef r=Veykril a=iDawer

Match checking does not expect patterns of `TyKind::FnDef` type.
It seems that in _rustc_ match checking is ruled out due to such type errors at the typecheck stage.

Spotted in #11319

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2 years agofix: Skip match check on a pattern of unexpected TyKind::FnDef
iDawer [Mon, 4 Apr 2022 19:05:20 +0000 (00:05 +0500)]
fix: Skip match check on a pattern of unexpected TyKind::FnDef

2 years agoMerge #11896
bors[bot] [Mon, 4 Apr 2022 14:14:26 +0000 (14:14 +0000)]
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>
2 years agofix: Show the path to be created in the unresolved-module fix label
Lukas Wirth [Mon, 4 Apr 2022 13:54:29 +0000 (15:54 +0200)]
fix: Show the path to be created in the unresolved-module fix label

2 years agoMerge #11894
bors[bot] [Mon, 4 Apr 2022 13:06:51 +0000 (13:06 +0000)]
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>
2 years agoUpdate crates/ide_completion/src/render/function.rs
cameron1024 [Mon, 4 Apr 2022 12:33:14 +0000 (13:33 +0100)]
Update crates/ide_completion/src/render/function.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix type error
cameron [Mon, 4 Apr 2022 13:30:49 +0000 (14:30 +0100)]
fix type error

2 years agoremove unwarp on adt name
cameron [Mon, 4 Apr 2022 13:28:15 +0000 (14:28 +0100)]
remove unwarp on adt name

2 years agocomplete pattern args based on type name
cameron [Mon, 4 Apr 2022 12:51:51 +0000 (13:51 +0100)]
complete pattern args based on type name

2 years agoMerge #11865
bors[bot] [Sun, 3 Apr 2022 18:46:45 +0000 (18:46 +0000)]
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>
2 years agoUse check_count! instead of multiple check! in separate scopes
Jonas Bushart [Sun, 3 Apr 2022 18:34:06 +0000 (18:34 +0000)]
Use check_count! instead of multiple check! in separate scopes

Changes are based on the review feedback by Veykril.

2 years agoMerge #11890
bors[bot] [Sun, 3 Apr 2022 15:19:01 +0000 (15:19 +0000)]
Merge #11890

11890: Delete FUNDING.yml r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoDelete FUNDING.yml
Lukas Wirth [Sun, 3 Apr 2022 15:18:41 +0000 (17:18 +0200)]
Delete FUNDING.yml

2 years agoMerge #11887
bors[bot] [Sun, 3 Apr 2022 13:42:15 +0000 (13:42 +0000)]
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>
2 years agofix: Add missing fields diagnostic fix for patterns
Lukas Wirth [Sun, 3 Apr 2022 13:11:04 +0000 (15:11 +0200)]
fix: Add missing fields diagnostic fix for patterns

2 years agoMerge #11699
bors[bot] [Sun, 3 Apr 2022 12:42:52 +0000 (12:42 +0000)]
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>
2 years agofeat: assist to remove unneeded `async`s
Ethiraric [Sun, 13 Mar 2022 20:56:34 +0000 (21:56 +0100)]
feat: assist to remove unneeded `async`s

2 years agoMerge #10802
bors[bot] [Sun, 3 Apr 2022 12:03:46 +0000 (12:03 +0000)]
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>
2 years agoMerge test functions using the same coverage marks to avoid parallelism
Jonas Bushart [Sun, 3 Apr 2022 12:01:11 +0000 (12:01 +0000)]
Merge test functions using the same coverage marks to avoid parallelism

2 years agoMerge #11866
bors[bot] [Sun, 3 Apr 2022 11:49:23 +0000 (11:49 +0000)]
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>
2 years agoMerge #11886
bors[bot] [Sun, 3 Apr 2022 11:13:46 +0000 (11:13 +0000)]
Merge #11886

11886: add test for postfix completion relevance r=matklad a=matklad

Follow up to #11857, add a test and cov-marks

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 years agoadd test for postfix completion relevance
Aleksey Kladov [Sun, 3 Apr 2022 11:09:55 +0000 (12:09 +0100)]
add test for postfix completion relevance

Follow up to #11857, add a test and cov-marks

2 years agoMerge #11821
bors[bot] [Sun, 3 Apr 2022 07:14:14 +0000 (07:14 +0000)]
Merge #11821

11821: minor: Bump npm deps r=lnicola a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11879
bors[bot] [Sun, 3 Apr 2022 07:05:41 +0000 (07:05 +0000)]
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>
2 years agoLoad @hpcc-js/wasm as a script, not worker
Laurențiu Nicola [Sun, 3 Apr 2022 07:05:36 +0000 (10:05 +0300)]
Load @hpcc-js/wasm as a script, not worker

2 years agosuggest infered type in auto complete
hkalbasi [Sat, 2 Apr 2022 11:49:36 +0000 (16:19 +0430)]
suggest infered type in auto complete

2 years agoMerge #11877
bors[bot] [Sat, 2 Apr 2022 22:12:59 +0000 (22:12 +0000)]
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>
2 years agoMerge #11882
bors[bot] [Sat, 2 Apr 2022 14:19:38 +0000 (14:19 +0000)]
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>
2 years agointernal: outline child modules with missing backing file
Lukas Wirth [Sat, 2 Apr 2022 14:14:19 +0000 (16:14 +0200)]
internal: outline child modules with missing backing file

2 years agoMerge #11881
bors[bot] [Sat, 2 Apr 2022 13:40:08 +0000 (13:40 +0000)]
Merge #11881

11881: fix: Don't rely on lang items to find primitive impls r=flodiebold a=flodiebold

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.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agofix: Don't rely on lang items to find primitive impls
Florian Diebold [Sat, 2 Apr 2022 13:32:40 +0000 (15:32 +0200)]
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.

2 years agoMerge #11878
bors[bot] [Sat, 2 Apr 2022 12:41:14 +0000 (12:41 +0000)]
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>
2 years agofix: Paper over GAT panic
Florian Diebold [Sat, 2 Apr 2022 11:04:04 +0000 (13:04 +0200)]
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.

2 years agofix: `merge_imports::recursive_merge` exiting early
iDawer [Sat, 2 Apr 2022 09:18:42 +0000 (14:18 +0500)]
fix: `merge_imports::recursive_merge` exiting early

2 years agoMerge #11875
bors[bot] [Fri, 1 Apr 2022 23:43:28 +0000 (23:43 +0000)]
Merge #11875

11875: internal: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify completion import insertion
Lukas Wirth [Fri, 1 Apr 2022 23:42:21 +0000 (01:42 +0200)]
Simplify completion import insertion

2 years agoCleanup relevance scoring
Lukas Wirth [Fri, 1 Apr 2022 23:19:33 +0000 (01:19 +0200)]
Cleanup relevance scoring

2 years agoMerge #11857
bors[bot] [Fri, 1 Apr 2022 21:42:54 +0000 (21:42 +0000)]
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>
2 years agoMerge #11874
bors[bot] [Fri, 1 Apr 2022 21:30:32 +0000 (21:30 +0000)]
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>
2 years agoenum variant wording
Jake Vossen [Fri, 1 Apr 2022 20:22:49 +0000 (14:22 -0600)]
enum variant wording

2 years agoIntroduce postfix item types
Aleksei Trifonov [Fri, 1 Apr 2022 17:50:27 +0000 (20:50 +0300)]
Introduce postfix item types

2 years agoMerge #11872
bors[bot] [Fri, 1 Apr 2022 17:12:44 +0000 (17:12 +0000)]
Merge #11872

11872: internal: Remove `PathResolution::AssocItem` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agointernal: Remove `PathResolution::AssocItem`
Lukas Wirth [Fri, 1 Apr 2022 16:32:05 +0000 (18:32 +0200)]
internal: Remove `PathResolution::AssocItem`

2 years agoMerge #11796
bors[bot] [Fri, 1 Apr 2022 15:51:29 +0000 (15:51 +0000)]
Merge #11796

11796: minor: Remove sponsors from readme files r=Veykril a=Veykril

No need to merge this now though

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #11870
bors[bot] [Fri, 1 Apr 2022 15:33:01 +0000 (15:33 +0000)]
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>
2 years agoMerge #11871
bors[bot] [Fri, 1 Apr 2022 15:17:03 +0000 (15:17 +0000)]
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>
2 years agointernal: Move rust.ungram into rust-analyzer/crates/syntax
Lukas Wirth [Fri, 1 Apr 2022 15:12:25 +0000 (17:12 +0200)]
internal: Move rust.ungram into rust-analyzer/crates/syntax

2 years agofix: splitting path of a glob import wrongly adds `self`
iDawer [Fri, 1 Apr 2022 14:12:50 +0000 (19:12 +0500)]
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).

2 years agorecover from missing type annotation
hkalbasi [Fri, 1 Apr 2022 12:50:54 +0000 (17:20 +0430)]
recover from missing type annotation

2 years agoMerge #11869
bors[bot] [Fri, 1 Apr 2022 12:40:51 +0000 (12:40 +0000)]
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>
2 years agoCode blocks with tilde also works like code block
Lee Dogeon [Fri, 1 Apr 2022 06:22:32 +0000 (15:22 +0900)]
Code blocks with tilde also works like code block

2 years agoMerge #11867
bors[bot] [Fri, 1 Apr 2022 10:18:15 +0000 (10:18 +0000)]
Merge #11867

11867: create generate is, as, try_into group r=Veykril a=jakevossen5

Fixes #11636

In `generate_enum_projection_method.rs`, the changes to the function are from `cargo fmt`, I made the same change as I did in `generate_enum_is_method.rs`.

Co-authored-by: Jake Vossen <jake@vossen.dev>
2 years agocreate generate is, as, try_into group
Jake Vossen [Fri, 1 Apr 2022 03:19:45 +0000 (21:19 -0600)]
create generate is, as, try_into group

2 years agoAdd test against line number underflow
Felix Maurer [Thu, 31 Mar 2022 21:37:23 +0000 (23:37 +0200)]
Add test against line number underflow

2 years agoPrevent underflow when converting line numbers
Felix Maurer [Thu, 31 Mar 2022 21:00:48 +0000 (23:00 +0200)]
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.

2 years agoFix: Select correct insert position for disabled group import
Jonas Bushart [Thu, 31 Mar 2022 18:15:01 +0000 (18:15 +0000)]
Fix: Select correct insert position for disabled group import

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

2 years agoMerge #11863
bors[bot] [Thu, 31 Mar 2022 14:04:38 +0000 (14:04 +0000)]
Merge #11863

11863: fix: allow varargs in any param position r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/3578 and aligns us with the Rust reference.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoRemove parser restriction on varargs positioning
Jonas Schievink [Thu, 31 Mar 2022 14:03:27 +0000 (16:03 +0200)]
Remove parser restriction on varargs positioning

2 years agoMerge #11827
bors[bot] [Thu, 31 Mar 2022 13:01:10 +0000 (13:01 +0000)]
Merge #11827

11827: internal: Enforce Invariant that Resolver always contains a ModuleScope r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #11861
bors[bot] [Thu, 31 Mar 2022 12:52:11 +0000 (12:52 +0000)]
Merge #11861

11861: internal: Add "view file text" command to debug sync issues r=jonas-schievink a=jonas-schievink

I saw a file sync bug the other day but didn't know how to further debug it. This command might give a clue as to what's wrong and help debug issues like https://github.com/rust-analyzer/rust-analyzer/issues/4829.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoAdd "view file text" command to debug sync issues
Jonas Schievink [Thu, 31 Mar 2022 12:50:33 +0000 (14:50 +0200)]
Add "view file text" command to debug sync issues

2 years agointernal: Enforce Resolver to always have a module scope
Lukas Wirth [Thu, 31 Mar 2022 09:12:08 +0000 (11:12 +0200)]
internal: Enforce Resolver to always have a module scope

2 years agoFix formatting
Aleksei Trifonov [Wed, 30 Mar 2022 23:59:15 +0000 (02:59 +0300)]
Fix formatting

2 years agoLower postfix suggestions in completions list
Aleksei Trifonov [Wed, 30 Mar 2022 23:27:33 +0000 (02:27 +0300)]
Lower postfix suggestions in completions list

2 years agointernal: Refactor FamousDefs builtin crate search
Lukas Wirth [Sat, 26 Mar 2022 20:22:35 +0000 (21:22 +0100)]
internal: Refactor FamousDefs builtin crate search