Commit Graph

783 Commits

Author SHA1 Message Date
Laurențiu Nicola
26aba38168 Bump chalk 2021-12-04 15:08:43 +02:00
Lukas Wirth
ec07bb98f8 fix: Omit generic defaults for types in hover messages 2021-11-22 18:27:03 +01:00
Alex Veber
24f816c481 fix: better Fn traits formatting 2021-11-21 02:39:22 +02:00
Lukas Wirth
69782f55de Move incorrect case diagnostic things into their module 2021-11-20 17:25:57 +01:00
Lukas Wirth
ceaec9d866 internal: Replace Vec with Box in hir Pat 2021-11-20 16:17:30 +01:00
Lukas Wirth
cc327774b7 internal: Replace Vec with Box in hir Expr 2021-11-20 16:00:45 +01:00
Jonas Schievink
9f4c26e780 Format Fn traits using parentheses 2021-11-19 19:58:00 +01:00
Lukas Wirth
91bbc55eed Check for derive attributes by item path, not derive identifier 2021-11-17 20:46:57 +01:00
bors[bot]
3b3063fb2d
Merge #10741
10741: internal: Flatten Definition::ModuleDef variant r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 23:19:44 +00:00
Lukas Wirth
7776aad166 internal: Flatten Definition::ModuleDef variant 2021-11-11 00:05:53 +01:00
bors[bot]
e7244e899f
Merge #10739
10739: internal: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-11-10 17:27:24 +00:00
Lukas Wirth
dea973089c Simplify 2021-11-10 18:26:18 +01:00
bors[bot]
b2bce38bb4
Merge #10729
10729: Fix: Lookup impls in local def maps r=jonas-schievink a=XFFXFF

fixes #10676 

Co-authored-by: zhoufan <1247714429@qq.com>
2021-11-10 16:47:35 +00:00
Laurențiu Nicola
e98b072da7 Bump chalk 2021-11-09 20:05:04 +02:00
zhoufan
f00cd911bf lookup impls in local del maps 2021-11-09 18:14:02 +08:00
bors[bot]
7765c1a94f
Merge #10668
10668: fix: Fix for-loop expressions breaking with BlockExpr iterable r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-10-30 14:42:53 +00:00
Lukas Wirth
c93983e76f Fix for-loop expressions breaking with BlockExpr iterable 2021-10-30 16:37:32 +02:00
Laurențiu Nicola
d0a99ad54e Bump chalk 2021-10-29 23:26:59 +03: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]
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
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
Laurențiu Nicola
24eca25d8a Make some functions non-generic 2021-10-20 20:20:17 +03:00
Andrzej Głuszak
98676efdc5 Semantic getter 2021-10-17 16:33:14 +02:00
Aramis Razzaghipour
dce5c640f8
Move IdxRange into la_arena 2021-10-15 13:03:28 +11:00
Aleksey Kladov
afacdd612d internal: update expect 2021-10-09 17:17:16 +03:00
Jonas Schievink
f8acae7895 Support let...else 2021-10-07 17:06:24 +02:00
crauzer
a4f08c117f Fix stdx::to_snake_case 2021-10-06 23:24:47 +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
Jonas Schievink
3aa37d7f80 Avoid cycle when lowering predicates for associated item lookup 2021-10-04 17:39:55 +02:00
Giacomo Stevanato
034dd41ea8 Add regression test 2021-09-29 21:08:44 +02:00
Giacomo Stevanato
7f76a73a38 Add regression test 2021-09-27 16:59:25 +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
Lukas Wirth
9c39363ada Simplify 2021-09-19 23:34:07 +02:00
teor
e0a501424c
Fix a comment typo in autoderef.rs 2021-09-16 13:47:01 +10:00
Lukas Wirth
a044175412 Simplify 2021-09-13 18:50:19 +02:00
bors[bot]
3e056b9e90
Merge #10213
10213: minor: Improve resilience of match checking r=flodiebold a=iDawer

In bug condition the match checking strives to recover giving false no-error diagnostic.

Suggested in https://github.com/rust-analyzer/rust-analyzer/pull/9105#discussion_r644656085

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-09-12 12:23:56 +00:00
Dawer
68dfe190ab Improve resilience of match checking
In bug condition the match checking strives to recover giving false no-error diagnostic.
2021-09-12 16:03:12 +05: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
15312aab58
removing seemingly unused dev deps. 2021-09-11 16:26:36 +01:00
Dawer
9ce3c075ad internal: add implicit : Sized bound to type parameters. 2021-09-10 20:41:53 +05:00
bors[bot]
8e47e359fa
Merge #10190
10190: minor: Bump deps r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-09-09 18:13:26 +00:00
Laurențiu Nicola
c930dcca13 Bump chalk 2021-09-09 21:12:38 +03:00