Commit Graph

19764 Commits

Author SHA1 Message Date
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
bors[bot]
fe7c516084
Merge #10602
10602: Add qualify method call assist r=Veykril a=qepasa

This adds `qualify_method_call` assist that allows to replace a method (or trait) call that resolves with its fully qualified path.

For example, for stuct method:
```rust
struct Foo;
impl Foo {
    fn foo(&self) {}
}
```
```
let foo = Foo {};
foo.fo$0o();
```

becomes
```rust
let foo = Foo {};
Foo::foo(&foo);
```

for a trait method:

```rust
struct Foo;
trait FooTrait {
    fn foo(&self) {}
}
impl FooTrait for Foo {
    fn foo(&self) {}
}
```
following call:
```rust
let foo = Foo {};
foo.fo$0o();
```

becomes:
```rust
let foo = Foo {};
FooTrait::foo(&foo);
```

fixes #10453 

Co-authored-by: Paweł Palenica <pawelpalenica11@gmail.com>
2021-10-23 08:34:51 +00:00
bors[bot]
a75353e8ac
Merge #9939
9939: feat: Adding extract_module assist r=Veykril a=feniljain

Should solve https://github.com/rust-analyzer/rust-analyzer/issues/9591

Co-authored-by: vi_mi <fenil.jain2018@vitstudent.ac.in>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 09:29:16 +00:00
vi_mi
3e73a46660 fix: making tests compatible with new trimmed sel_range 2021-10-22 09:16:56 +00:00
bors[bot]
dc5afb1573
Merge #10608
10608: Amend the instruction for rustup. r=lnicola a=jhscheer

The current instruction for installation via rustup are misleading.

Co-authored-by: Jan Scheer <jhscheer@users.noreply.github.com>
2021-10-22 07:18:05 +00:00
Paweł Palenica
bfc86f64c3 apply code review suggestions 2021-10-21 23:42:14 -07:00
bors[bot]
bbbb0e5f9a
Merge #10610
10610: minor: Use array `IntoIter` r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-22 06:24:17 +00:00
Laurențiu Nicola
ca44b6892e Use array IntoIter 2021-10-22 09:23:29 +03:00
Jan Scheer
1bfedc3591
Amend the instruction for rustup.
The current instruction for installation via rustup are misleading.
2021-10-21 23:04:43 +02:00
bors[bot]
56fbf5d7b2
Merge #10607
10607: Migrate to edition 2021 r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-21 18:19:22 +00:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02:00
bors[bot]
6aeeb4ef33
Merge #10603
10603: fix: Don't resolve attributes to non attribute macros r=Veykril a=Veykril

Also changes `const`s to `static`s for `Limit`s as we have interior mutability in those(though only used with a certain feature flag enabled).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-21 10:39:26 +00:00
Lukas Wirth
ea2a2c52fc Don't resolve attributes to non attribute macros 2021-10-21 12:22:40 +02:00
Paweł Palenica
91988f46b7 Add generated docs 2021-10-20 23:54:22 -07:00
Paweł Palenica
c2fd0c48a6 cleanup qualify_path 2021-10-20 23:39:25 -07:00
Paweł Palenica
b3d92052ce Remove comment 2021-10-20 23:38:28 -07:00
Paweł Palenica
9f31f59fdf Cleanup - remove unnecessary pub 2021-10-20 23:37:31 -07:00
Paweł Palenica
c8820d342f Run cargo fmt 2021-10-20 23:35:14 -07:00
Paweł Palenica
bb00b09d22 Add qualify method call assist 2021-10-20 23:28:30 -07:00
bors[bot]
6877240fdf
Merge #10563
10563: feat: Make "Generate getter" assist use semantic info r=agluszak a=agluszak

This PR makes "Generate getter" assist use semantic info instead of dealing with types encoded as strings.
Getters for types which are:
- `Copy` no longer return references
- `AsRef<str>` (i.e. `String`) return `&str` (instead of `&String`)
- `AsRef<[T]>` (i.e. `Vec<T>`) return `&[T]` (instead of `&Vec<T>`)
- `AsRef<T>` (i.e. `Box<T>`) return `&T` (instead of `&Box<T>`)
- `Option<T>` return `Option<&T>` (instead of `&Option<T>`)
- `Result<T, E>` return `Result<&T, &E>` (instead of `&Result<T, E>`)

String, Vec, Box and Option were previously handled as special cases.

Closes #10295


Co-authored-by: Andrzej Głuszak <gluszak.andrzej@gmail.com>
2021-10-20 21:02:46 +00:00
bors[bot]
11326a6847
Merge #10387
10387: Move `IdxRange` into la-arena r=Veykril a=arzg

Currently, `IdxRange` (named `IdRange`) is located in `hir_def::item_tree`, when really it isn’t specific to `hir_def` and could become part of la-arena. The rename from `IdRange` to `IdxRange` is to maintain consistency with the naming convention used throughout la-arena (`Idx` instead of `Id`, `RawIdx` instead of `RawId`). This PR also adds a few new APIs to la-arena on top of `IdxRange` for convenience, namely:

- indexing into an `Arena` by an `IdxRange` and getting a slice of values back
- creating an `IdxRange` from an inclusive range

Currently this PR also exposes a new `Arena::next_idx` method to make constructing inclusive`IdxRange`s using `IdxRange::new` easier; however, it would in my opinion be better to remove this as it allows for easy creation of out-of-bounds `Idx`s, when `IdxRange::new_inclusive` mostly covers the same use-case while being less error-prone.

I decided to bump the la-arena version to 0.3.0 from 0.2.0 because adding a new `Index` impl for `Arena` turned out to be a breaking change: I had to add a type hint in `crates/hir_def/src/body/scope.rs` when one wasn’t necessary before, since rustc couldn’t work out the type of a closure parameter now that there are multiple `Index` impls. I’m not sure whether this is the right decision, though. 

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-20 20:54:36 +00:00
Andrzej Głuszak
88e2f07826 Fixes 2021-10-20 22:35:31 +02:00
Andrzej Głuszak
a2242dcf1b Fixes 2021-10-20 21:35:35 +02:00
bors[bot]
d1cdfa800c
Merge #10600
10600: minor: Make some functions non-generic r=Veykril a=lnicola

This reduces `text` size by 10192 bytes (0.064% 😢), with no apparent change in performance.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-10-20 18:05:31 +00:00
Laurențiu Nicola
24eca25d8a Make some functions non-generic 2021-10-20 20:20:17 +03:00
bors[bot]
c2e36291f3
Merge #10598
10598: minor: Remove obsolete test module r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-20 15:03:36 +00:00
Lukas Wirth
96fbef606a Remove obsolete test module 2021-10-20 17:03:09 +02:00
bors[bot]
25a498bfc7
Merge #10597
10597: fix: Fix standard library doclinks not going to the correct page r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-20 14:46:28 +00:00
Lukas Wirth
8ed86fc25d Fix standard library doclinks not going to the correct page 2021-10-20 16:36:01 +02:00
bors[bot]
c73aa7a214
Merge #10594
10594: fix: Generate and complete rustdoc lints r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10572, https://github.com/rust-analyzer/rust-analyzer/issues/8349
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-20 12:05:54 +00:00
Lukas Wirth
bed6eae304 Fix qualified lint completions ignoring the qualifier value 2021-10-20 14:03:41 +02:00
Lukas Wirth
6c9b8d7ce5 Generate rustdoc lints 2021-10-20 13:48:05 +02:00
bors[bot]
5051717856
Merge #10589
10589: Fix: expand into {} if the glob import is unused r=lnicola a=rainy-me

close #10524 

I think the second `expand into {}` behavior is genuinely better. (maybe this should been labeled with good first issue xd)

Co-authored-by: rainy-me <github@yue.coffee>
2021-10-19 14:53:00 +00:00
rainy-me
1ea2c72386 Fix: remove extra newline 2021-10-19 23:46:43 +09:00
rainy-me
adb3729b91 Fix: expand glob import to empty braces if the glob is unused 2021-10-19 23:31:30 +09:00
bors[bot]
580a6c41eb
Merge #10568
10568: fix(assist): fix #10566 and #10567 r=bnjjj a=bnjjj

close #10566
close #10567

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-10-19 12:57:24 +00:00
Benjamin Coenen
3a5147e9fe fix(assist): delete trailing whitespaces
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-10-19 14:54:29 +02:00
bors[bot]
dfa355b431
Merge #10588
10588: internal: Parse const trait bounds r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-19 12:32:30 +00:00
Lukas Wirth
b219a4c465 internal: Parse const trait bounds 2021-10-19 14:20:00 +02:00
bors[bot]
e77fc481ad
Merge #10587
10587: fix: Fix `add_missing_match_arm` panicking on failed upmapping r=Veykril a=Veykril

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10580#issuecomment-946170475

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-19 12:16:30 +00:00
Lukas Wirth
7e1d6e5265 fix: Fix add_missing_match_arm panicking 2021-10-19 14:00:24 +02:00
bors[bot]
0e4c3b2c2b
Merge #10586
10586: internal: Derive completions work on hir, not names r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-19 11:51:07 +00:00
Lukas Wirth
3dfe5045c5 Derive completions work on hir, not names 2021-10-19 13:50:08 +02:00
bors[bot]
d85946b735
Merge #10585
10585: fix: Resolve derive attributes even when shadowed r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-19 11:43:08 +00:00
Lukas Wirth
aa9d093488 Resolve derive attributes even when shadowed 2021-10-19 13:42:36 +02:00
bors[bot]
87d5ef8c4a
Merge #10578
10578: Fix partialord codegen take 2 r=lnicola a=yoshuawuyts

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10576. This reverts "generate `PartialOrd` to our previous match-based design, and in turn uses that to correctly take references for multi-value comparisons. This is a bit more verbose, but it should be more readable and easier to edit by end-users than multiple nested layers of borrows. I also manually verified every example in the Rust playground to ensure it works. Thanks!

cc/ `@WaffleLapkin` 

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-10-18 12:56:33 +00:00
Yoshua Wuyts
e346d32e69 fix Ordering::Equal path 2021-10-18 14:45:24 +02:00
Yoshua Wuyts
41fd824415 Revert "Simplify generated PartialOrd code"
This reverts commit 601ed3a10d.
2021-10-18 14:41:38 +02:00
bors[bot]
48c3be922e
Merge #10574
10574: fix: Fix PartialOrd codegen r=lnicola a=yoshuawuyts

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10571#issuecomment-945516462. Thanks!

r? `@lnicola` 

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-10-18 10:47:04 +00:00
Yoshua Wuyts
a9ec345cf7 Fix PartialOrd codegen 2021-10-18 12:44:05 +02:00