Commit Graph

373 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
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
9f31f59fdf Cleanup - remove unnecessary pub 2021-10-20 23:37:31 -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
Lukas Wirth
6c9b8d7ce5 Generate rustdoc lints 2021-10-20 13:48:05 +02:00
Lukas Wirth
aa9d093488 Resolve derive attributes even when shadowed 2021-10-19 13:42:36 +02:00
Andrzej Głuszak
98676efdc5 Semantic getter 2021-10-17 16:33:14 +02:00
Dezhi Wu
93ae993ec4 resolve ControlFlow ourself instead of hard coding. 2021-10-13 21:19:41 +08:00
Mirko Rainer
eccfa1645b Saw a FIXME comment and decided to fix it.
This renames `descend_into_macros` to  `descend_into_macros_single` and `descend_into_macros_many` into `descend_into_macros`.
 However, this does not touch a function in `SemanticsImpl` of same name.
2021-10-12 11:52:31 -04:00
Lukas Wirth
d71a4f40d9 Regenerate lints 2021-10-12 09:35:02 +02:00
Lukas Wirth
ed7c2948b3 Move lint source generator 2021-10-12 08:59:39 +02:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
bors[bot]
f30b62b751
Merge #10479
10479: fix: fix "index out of bounds" panic in name resolution r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/10084
Closes https://github.com/rust-analyzer/rust-analyzer/issues/9163

This is really just a salsa update to a version that removes the problematic code (see https://github.com/rust-analyzer/rust-analyzer/issues/10084#issuecomment-934445711)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-10-06 20:54:27 +00:00
Jonas Schievink
cda9668289 Update salsa 2021-10-06 22:42:54 +02:00
crauzer
05e58afde2 Add replace_try_expr_with_match assist 2021-10-06 20:11:00 +02:00
bors[bot]
86c534f244
Merge #10440
10440: Fix Clippy warnings and replace some `if let`s with `match` r=Veykril a=arzg

I decided to try fixing a bunch of Clippy warnings. I am aware of this project’s opinion of Clippy (I have read both [rust-lang/clippy#5537](https://github.com/rust-lang/rust-clippy/issues/5537) and [rust-analyzer/rowan#57 (comment)](https://github.com/rust-analyzer/rowan/pull/57#discussion_r415676159)), so I totally understand if part of or the entirety of this PR is rejected. In particular, I can see how the semicolons and `if let` vs `match` commits provide comparatively little benefit when compared to the ensuing churn.

I tried to separate each kind of change into its own commit to make it easier to discard certain changes. I also only applied Clippy suggestions where I thought they provided a definite improvement to the code (apart from semicolons, which is IMO more of a formatting/consistency question than a linting question). In the end I accumulated a list of 28 Clippy lints I ignored entirely.

Sidenote: I should really have asked about this on Zulip before going through all 1,555 `if let`s in the codebase to decide which ones definitely look better as `match` :P

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-10-05 08:58:40 +00:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
bors[bot]
e28aa1928b
Merge #10439
10439: fix: fix insert_use incorrectly merging glob imports r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 12:19:02 +00:00
Lukas Wirth
5b0c91d118 fix: fix insert_use incorrectly merging glob imports 2021-10-03 14:06:44 +02:00
Lukas Wirth
e684235329 Move module private logic down 2021-10-03 13:52:40 +02:00
bors[bot]
ebe6c38a44
Merge #10438
10438: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-03 11:06:06 +00:00
Lukas Wirth
0943c4be8b minor: Simplify 2021-10-03 13:05:42 +02:00
Lukas Wirth
86e5406539 Fix rename trying to edit the same range multiple times 2021-10-02 18:50:21 +02:00
Aleksey Kladov
46eb03d99a internal: use naming that matches intended use-case 2021-10-02 12:18:18 +03:00
Lucas
6606b49710
Reduce allocation in builtin_crates
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-01 01:56:30 +10:00
lhvy
2b3baa8503
Give defaultLibrary semantic token modifier to items from standard library 2021-10-01 01:19:24 +10:00
Lukas Wirth
774a8cf08b Fix inline_call breaking RecordExprField shorthands 2021-09-28 19:22:32 +02:00
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Aleksey Kladov
2bf81922f7 internal: more reasonable grammar for blocks
Consider these expples

        { 92 }
  async { 92 }
    'a: { 92 }
   #[a] { 92 }

Previously the tree for them were

  BLOCK_EXPR
    { ... }

  EFFECT_EXPR
    async
    BLOCK_EXPR
      { ... }

  EFFECT_EXPR
    'a:
    BLOCK_EXPR
      { ... }

  BLOCK_EXPR
    #[a]
    { ... }

As you see, it gets progressively worse :) The last two items are
especially odd. The last one even violates the balanced curleys
invariant we have (#10357) The new approach is to say that the stuff in
`{}` is stmt_list, and the block is stmt_list + optional modifiers

  BLOCK_EXPR
    STMT_LIST
      { ... }

  BLOCK_EXPR
    async
    STMT_LIST
      { ... }

  BLOCK_EXPR
    'a:
    STMT_LIST
      { ... }

  BLOCK_EXPR
    #[a]
    STMT_LIST
      { ... }
2021-09-26 19:16:09 +03:00
bors[bot]
c51a3c78cf
Merge #10358
10358: internal: Remove inherent methods from ast nodes that do non-syntactic complex tasks  r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-26 14:49:25 +00:00
Lukas Wirth
151afdfe5c Remove inherent methods from ast node that carry semantic meaning 2021-09-26 16:49:03 +02:00
Lukas Wirth
215a077ee4 Remove imports when inlining all calls in a file 2021-09-26 16:01:54 +02:00
Lukas Wirth
1a50f904ef Reject recursive calls in inline_call 2021-09-26 14:55:03 +02:00
Lukas Wirth
42eb4efb5b Cleanup 2021-09-23 16:28:03 +02:00
hamidreza kalbasi
589c1dfa04 move function to defs.rs 2021-09-22 18:35:54 +03:30
Aleksey Kladov
73b0f9dc04 internal: remove dead code 2021-09-15 21:22:06 +03:00
Lukas Wirth
6f9de71402 fix: Use original definition ranges for ide_db::search instead of the expanded ranges 2021-09-14 02:49:06 +02:00
toyboot4e
89e46b40c3 Minor: replace old name CrateDefMap 2021-09-05 19:22:34 +09:00
Lukas Wirth
e2ede38d47 Use correct search scopes for macros 2021-09-02 17:30:55 +02:00
Jonas Schievink
bdba35cc93 fix: multi-token mapping aware find references 2021-09-01 19:19:16 +02:00
Lukas Wirth
68bf359363 fix: make goto_implementation multi-token mapping aware 2021-09-01 14:51:37 +02:00
Dezhi Wu
ba0947dded switch log crate to tracing 2021-08-30 15:11:42 +08:00
Aleksey Kladov
78365c64c8 internal: slightly improve compile times
As per style guide, avoid monomorphisations
2021-08-29 12:53:56 +03:00
Lukas Wirth
99f1e66997 Only report unique text ranges in highlight_related 2021-08-29 01:11:29 +02:00
Lukas Wirth
72bfbb0691 Return all usages inside macros in usage searches 2021-08-29 00:49:57 +02:00
Lukas Wirth
512135920d Highlight all related tokens in macro inputs 2021-08-29 00:49:57 +02:00