Commit graph

21579 commits

Author SHA1 Message Date
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
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