Commit Graph

21517 Commits

Author SHA1 Message Date
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
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
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
bors[bot]
5ac07a89ef
Merge #11916
11916: internal: Add more doc-link tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-06 18:59:13 +00:00
Lukas Wirth
96b641e95e internal: Add more doc-link tests 2022-04-06 20:58:46 +02:00
bors[bot]
ec56c7ef97
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>
2022-04-06 18:27:13 +00: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
bors[bot]
f4e4a3a896
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>
2022-04-06 17:39:20 +00: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
bors[bot]
a852758bd6
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>
2022-04-06 12:24:58 +00:00
Lukas Wirth
4e6390bb12 Fix SearchScope::reverse_dependencies trying to search more files than necessary 2022-04-06 14:24:06 +02:00
bors[bot]
fa06e3d0f9
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>
2022-04-06 12:00:35 +00: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
bors[bot]
b5eaf56666
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>
2022-04-05 15:48:09 +00: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
bors[bot]
5a6918f1c4
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>
2022-04-04 20:08:37 +00: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]
79a0fee082
Merge #11890
11890: Delete FUNDING.yml r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-04-03 15:19:01 +00:00
Lukas Wirth
da32f73c10
Delete FUNDING.yml 2022-04-03 17:18:41 +02: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
bors[bot]
f6bf7a3e41
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>
2022-04-03 11:13:46 +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