Commit Graph

516 Commits

Author SHA1 Message Date
bors[bot]
a8247685cf
Merge #10686
10686: internal: Add `Semantics::original_ast_node` for upmapping nodes out of macro files r=Veykril a=Veykril

Fixes trying to insert imports into macro expanded files which then do text edits on very wrong text ranges.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-03 20:23:14 +00:00
Lukas Wirth
96db0d8bdd Add Semantics::original_ast_node for upmapping nodes out of macro files 2021-11-03 21:12:36 +01:00
Lukas Wirth
52f5af7165 Expose version string of crates fom HIR 2021-11-03 15:40:06 +01:00
Lukas Wirth
ebd63ec1cf feat: Make unqualified derive attributes flyimportable 2021-10-29 14:51:26 +02:00
Lukas Wirth
7fdbdc4ab2 Enable auto-import and qualify-path in derive attributes 2021-10-28 18:40:38 +02:00
Laurențiu Nicola
8457ae34bd Set MSRV 2021-10-23 15:07:11 +03:00
Laurențiu Nicola
ca44b6892e Use array IntoIter 2021-10-22 09:23:29 +03:00
Lukas Wirth
1294bfce86 Migrate to edition 2021 2021-10-21 20:10:40 +02: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
Andrzej Głuszak
88e2f07826 Fixes 2021-10-20 22:35:31 +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
bors[bot]
0af9d1fc8a
Merge #10546
10546: feat: Implement promote_local_to_const assist r=Veykril a=Veykril

Fixes #7692, that is now one can invoke the `extract_variable` assist on something and then follow that up with this assist to turn it into a const.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-14 19:51:34 +00:00
Lukas Wirth
06286ee90b Implement promotoe_local_to_const assist 2021-10-14 21:49:46 +02:00
Ryan Levick
0ff89deb69 Add basic support for delegation 2021-10-13 18:05:09 +02: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
12465a8a3c Expose HasSource::source through Semantics with caching behaviour 2021-10-07 15:00:14 +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
9583dd5725
Replace if let with match where appropriate 2021-10-05 09:00:21 +11:00
Aramis Razzaghipour
f29796da61
Replace if let Some(_) = foo with if foo.is_some() 2021-10-05 09:00:18 +11:00
Jonas Schievink
3aa37d7f80 Avoid cycle when lowering predicates for associated item lookup 2021-10-04 17:39:55 +02:00
Dawer
df4bb02b6f minor: don't drop binders when doing autoderef 2021-09-30 19:57:15 +05:00
bors[bot]
629db286d1
Merge #10373
10373: fix: `into_iterator` not completed on `Vec<{unknown}>` r=iDawer a=iDawer

Fixes  #10297 

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-28 19:38:59 +00:00
Dawer
f222665ebe fix: replace errors in a type when doing autoderef 2021-09-29 00:26:58 +05:00
Lukas Wirth
dedc2368b9 Use SmallVec<[_; 1]> in descend_into_macros_impl 2021-09-27 19:18:26 +02:00
Dawer
11aed78e2b fix: replace errors in receiver type when iterating method candidates 2021-09-27 21:46:00 +05:00
Lukas Wirth
75660ff94f Cleanup descend_into_macros_impl 2021-09-27 18:44:40 +02:00
Lukas Wirth
b6ed91a6de Rename *Owner traits to Has* 2021-09-27 12:54:24 +02:00
Lukas Wirth
a28c5d7311 Rename Dyn* nodes to Any* nodes 2021-09-27 12:45:36 +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
Jonas Schievink
5967f3d3a9 Fix diagnostics in unnamed consts 2021-09-24 20:41:24 +02:00
Lukas Wirth
b36f12dba5 Simplify 2021-09-21 16:05:21 +02:00
Lukas Wirth
6d6e0b8f21 Generate ast nodes for each ast trait 2021-09-21 15:52:11 +02:00
Lukas Wirth
6465868449 Make inlay hints work in attributed items 2021-09-18 13:19:29 +02:00
Aleksey Kladov
73b0f9dc04 internal: remove dead code 2021-09-15 21:22:06 +03:00
Lukas Wirth
64fb7be247 Revert attributed items inlay hints 2021-09-14 20:30:28 +02:00
Lukas Wirth
0f4463e45e fix source_to_def trying to use attribute macro calls as containers 2021-09-14 14:42:14 +02:00
Lukas Wirth
d1e489185f Pick smaller node ancestors first when descending at offset 2021-09-14 14:10:59 +02:00
Lukas Wirth
538ac599d2 Add some more attribute ide tests 2021-09-14 03:57:29 +02:00
Lukas Wirth
e193e3b076 feat: Make inlay hints work in attributed items 2021-09-14 01:59:45 +02:00
Lukas Wirth
bb946f78f6 fix: fix expansion order for fn-like macros and attributes in token descending 2021-09-14 01:20:43 +02:00
Lukas Wirth
2b907652ee Speculatively expand attributes in completions 2021-09-13 19:30:23 +02:00
Florian Diebold
a2d9f7d7bb Avoid type inference panic on bitslice methods
Should fix #10090, #10046, #10179.
This is only a workaround, but the proper fix requires some bigger
refactoring (also related to fixing #10058), and this at least prevents
the crash.
2021-09-12 10:49:40 +02:00
bors[bot]
317059985a
Merge #10202
10202: fix: Type param hover shows correct sized bounds. r=flodiebold a=iDawer

Closes  #9949

This adds implicit `: Sized` bound to type parameters at lowering step.

Hovering on type parameter does not show it's `: Sized` bound be it set explicitly or implicitly. This is because it doesn't track that the bound was set implicitly.

### Perf

```rust
./target/rust-analyzer-baseline-3dae94bf -q analysis-stats --memory-usage .
Database loaded:     4.51s, 311minstr, 110mb (metadata 1.08s, 22minstr, 743kb; build 3.20s, 8730kinstr, -237kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.63s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           118.25s, 284ginstr, 601mb
Total:               147.88s, 370ginstr, 973mb

./target/rust-analyzer-hover-ty-param-dfb15292 -q analysis-stats --memory-usage .
Database loaded:     4.53s, 311minstr, 110mb (metadata 1.10s, 22minstr, 743kb; build 3.20s, 8672kinstr, -189kb)
  crates: 38, mods: 770, decls: 17173, fns: 12835
Item Collection:     29.59s, 85ginstr, 372mb
  exprs: 353460, ??ty: 364 (0%), ?ty: 232 (0%), !ty: 144
Inference:           121.69s, 296ginstr, 601mb
Total:               151.28s, 382ginstr, 974mb

```

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 07:54:56 +00:00
Aleksey Kladov
9b2bac621e minor: make code clearer with ControlFlow 2021-09-11 20:49:10 +03:00
Giles Cope
4ccd90af81
remove unused deps 2021-09-11 16:20:04 +01:00
Dawer
dfb15292c2 fix: Type param hover shows correct sized bounds. 2021-09-10 20:48:39 +05:00
bors[bot]
ac2520128d
Merge #10135
10135: minor: fix some clippy lints r=lnicola a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-09-03 14:28:27 +00:00
Lukas Wirth
36a5ce9790 minor: fix some clippy lints 2021-09-03 16:00:50 +02:00
Lukas Wirth
0fee14bfdd When descending tokens don't bail on failed macro call expansions 2021-09-02 19:12:08 +02:00