]> git.lizzy.rs Git - rust.git/log
rust.git
19 months agoAuto merge of #13764 - WaffleLapkin:badassexprs, r=Veykril
bors [Tue, 20 Dec 2022 18:11:54 +0000 (18:11 +0000)]
Auto merge of #13764 - WaffleLapkin:badassexprs, r=Veykril

fix: Correctly check for parentheses redundancy in `remove_parentheses` assist

This is quite a bunch of code and some hacks, but I _think_ this time it's correct.

I've added a lot of tests, most of which fail with the assist impl from #13733 :')

19 months agoAuto merge of #13805 - ntBre:master, r=jonas-schievink
bors [Tue, 20 Dec 2022 17:58:41 +0000 (17:58 +0000)]
Auto merge of #13805 - ntBre:master, r=jonas-schievink

Complete enum variants without parens when snippets are disabled

This handles the portion of #13767 that bothered me, but I can try to work on the other parts we discussed if needed.

19 months agopass `snippet_cap` to `format_literal_label`, return early if None
Brent Westbrook [Tue, 20 Dec 2022 16:27:19 +0000 (11:27 -0500)]
pass `snippet_cap` to `format_literal_label`, return early if None

19 months agoreturn immediately from `render_tuple_lit` if `snippet_cap` is None
Brent Westbrook [Tue, 20 Dec 2022 16:07:37 +0000 (11:07 -0500)]
return immediately from `render_tuple_lit` if `snippet_cap` is None

partially addresses #13767

19 months agoDon't panic in `Expr::needs_parens_in`
Maybe Waffle [Tue, 20 Dec 2022 15:16:26 +0000 (15:16 +0000)]
Don't panic in `Expr::needs_parens_in`

19 months agoAuto merge of #13804 - WaffleLapkin:inlay_hint_mods, r=Veykril
bors [Tue, 20 Dec 2022 14:18:49 +0000 (14:18 +0000)]
Auto merge of #13804 - WaffleLapkin:inlay_hint_mods, r=Veykril

Split inlay hints into modules per hint type

I think this makes the code a lot easier to maintain.

19 months agoAdd docs to make tidy tests happy :')
Maybe Waffle [Tue, 20 Dec 2022 13:30:53 +0000 (13:30 +0000)]
Add docs to make tidy tests happy :')

19 months agoMove inlay hints tests into implementation modules
Maybe Waffle [Tue, 20 Dec 2022 12:45:31 +0000 (12:45 +0000)]
Move inlay hints tests into implementation modules

19 months agoSplit inlay hints into modules
Maybe Waffle [Fri, 16 Dec 2022 16:13:46 +0000 (16:13 +0000)]
Split inlay hints into modules

19 months agoAuto merge of #13800 - lowr:fix/mbe-expr-backwards-compat, r=Veykril
bors [Tue, 20 Dec 2022 12:01:30 +0000 (12:01 +0000)]
Auto merge of #13800 - lowr:fix/mbe-expr-backwards-compat, r=Veykril

fix: don't let mbe expr fragments match let exprs and inline consts

Fixes #11729

`expr` fragment in mbe should not match let expressions and inline consts for backwards compatibility. See rust-lang/rust#86730 for details.

This patch is porting [this logic in rustc](https://github.com/rust-lang/rust/blob/f0c4da49983aa699f715caf681e3154b445fb60b/compiler/rustc_parse/src/parser/nonterminal.rs#L28-L34) (which is called [here in rustc's mbe engine](https://github.com/rust-lang/rust/blob/f0c4da49983aa699f715caf681e3154b445fb60b/compiler/rustc_expand/src/mbe/macro_parser.rs#L576)) to our mbe engine.

19 months agofix: don't let mbe expr fragments match let exprs and inline consts
Ryo Yoshida [Tue, 20 Dec 2022 11:31:47 +0000 (20:31 +0900)]
fix: don't let mbe expr fragments match let exprs and inline consts

19 months agoAuto merge of #13795 - jonas-schievink:fix-rustfmt-edition-in-path-deps, r=jonas...
bors [Mon, 19 Dec 2022 16:57:12 +0000 (16:57 +0000)]
Auto merge of #13795 - jonas-schievink:fix-rustfmt-edition-in-path-deps, r=jonas-schievink

fix: Use the correct edition when formatting code in path dependencies

Fixes https://github.com/rust-lang/rust-analyzer/issues/13790

Don't go through the Cargo workspace info, since that doesn't contain path dependencies. Instead, query the crate graph via `Analysis::crate_edition`.

19 months agoUse the correct edition when formatting path deps
Jonas Schievink [Mon, 19 Dec 2022 16:53:56 +0000 (17:53 +0100)]
Use the correct edition when formatting path deps

19 months agoAuto merge of #13794 - jonas-schievink:reset-step-limit-after-bump, r=jonas-schievink
bors [Mon, 19 Dec 2022 16:07:40 +0000 (16:07 +0000)]
Auto merge of #13794 - jonas-schievink:reset-step-limit-after-bump, r=jonas-schievink

fix: fix "parser seems stuck" panic when parsing colossal files

The parser step count is incremented every time the parser inspects a token. It's purpose is to ensure the parser doesn't get stuck in infinite loops. But since `self.pos` grows monotonically when parsing source code, it gives a better idea for whether the parser is stuck or not: if `self.pos` is changed, we know that the parser cannot be stuck, so it is safe to reset the step count to 0. This makes the limit check scale with the size of the file, and so should fix https://github.com/rust-lang/rust-analyzer/issues/13788.

19 months agoReset parser step count when bumping
Jonas Schievink [Mon, 19 Dec 2022 15:27:00 +0000 (16:27 +0100)]
Reset parser step count when bumping

19 months agoAuto merge of #13792 - Veykril:flycheck, r=Veykril
bors [Sat, 17 Dec 2022 22:45:08 +0000 (22:45 +0000)]
Auto merge of #13792 - Veykril:flycheck, r=Veykril

Add a command to clear flycheck diagnostics

And document the flycheck notifications

19 months agoAdd a command to clear flycheck diagnostics
Lukas Wirth [Sat, 17 Dec 2022 22:43:26 +0000 (23:43 +0100)]
Add a command to clear flycheck diagnostics

19 months agoMake cancelFlycheck request a notification
Lukas Wirth [Sat, 17 Dec 2022 22:29:25 +0000 (23:29 +0100)]
Make cancelFlycheck request a notification

19 months agoMake manual flycheck runs work when checkOnSave is disabled
Lukas Wirth [Sat, 17 Dec 2022 22:26:54 +0000 (23:26 +0100)]
Make manual flycheck runs work when checkOnSave is disabled

19 months agoAuto merge of #13785 - Veykril:run-flycheck, r=Veykril
bors [Fri, 16 Dec 2022 22:06:35 +0000 (22:06 +0000)]
Auto merge of #13785 - Veykril:run-flycheck, r=Veykril

Add command for manually running flychecks

Closes https://github.com/rust-lang/rust-analyzer/issues/13125

19 months agoAdd command for manually running flychecks
Lukas Wirth [Fri, 16 Dec 2022 21:43:14 +0000 (22:43 +0100)]
Add command for manually running flychecks

19 months agoAuto merge of #13784 - Veykril:bm-hints, r=Veykril
bors [Fri, 16 Dec 2022 20:51:20 +0000 (20:51 +0000)]
Auto merge of #13784 - Veykril:bm-hints, r=Veykril

Deduplicate inserted parentheses in binding mode hints

19 months agoDeduplicate inserted parentheses in binding mode hints
Lukas Wirth [Fri, 16 Dec 2022 20:16:55 +0000 (21:16 +0100)]
Deduplicate inserted parentheses in binding mode hints

19 months agoAuto merge of #13783 - Veykril:bm-hints, r=Veykril
bors [Fri, 16 Dec 2022 19:53:06 +0000 (19:53 +0000)]
Auto merge of #13783 - Veykril:bm-hints, r=Veykril

Add parentheses for binding mode hints when they attach to an Or-pattern

19 months agoAdd parentheses for binding mode hints when they attach to an Or-pattern
Lukas Wirth [Fri, 16 Dec 2022 19:52:31 +0000 (20:52 +0100)]
Add parentheses for binding mode hints when they attach to an Or-pattern

19 months agoAuto merge of #13777 - dzvon:fix-13776, r=jonas-schievink
bors [Fri, 16 Dec 2022 03:23:38 +0000 (03:23 +0000)]
Auto merge of #13777 - dzvon:fix-13776, r=jonas-schievink

fix: add a check for `if` token in patterns parser

Closes #13776

19 months agodocs: update the comment and add a test to `half_open_range_pat`
Dezhi Wu [Fri, 16 Dec 2022 02:44:25 +0000 (10:44 +0800)]
docs: update the comment and add a test to `half_open_range_pat`

19 months agofix: add a check for `if` token in patterns parser
Dezhi Wu [Thu, 15 Dec 2022 04:46:02 +0000 (12:46 +0800)]
fix: add a check for `if` token in patterns parser

Closes #13776

19 months agoAuto merge of #13772 - noritada:minor/set-experimental-attr-to-changelog-draft, r...
bors [Wed, 14 Dec 2022 14:54:19 +0000 (14:54 +0000)]
Auto merge of #13772 - noritada:minor/set-experimental-attr-to-changelog-draft, r=lnicola

minor: Set the `experimental` AsciiDoc document attribute to generated draft changelog

This PR sets the `experimental` AsciiDoc document attribute to generated draft changelog.

That attribute is required by the keyboard macro (`kbd:[...]`).
This change of the draft will prevent issues like https://github.com/rust-analyzer/rust-analyzer.github.io/pull/191 .

19 months agoAuto merge of #13774 - lowr:fix/no-infer-vars-in-inference-result, r=Veykril
bors [Wed, 14 Dec 2022 14:27:32 +0000 (14:27 +0000)]
Auto merge of #13774 - lowr:fix/no-infer-vars-in-inference-result, r=Veykril

fix: resolve all inference vars in `InferenceResult::assoc_resolutions`

I think this fixes '#13773, ~but still haven't found repro. I'll try finding one so we can have a regression test~.

We should resolve every inference variable in `InferenceResult` after inference is done. We started recording `Substitution`s for each resolved associated items in #13725, but failed to do so which causes crash when analyzing source in IDE layer.

19 months agoAuto merge of #13769 - jonas-schievink:parse-half-open-range-pat, r=jonas-schievink
bors [Wed, 14 Dec 2022 14:14:46 +0000 (14:14 +0000)]
Auto merge of #13769 - jonas-schievink:parse-half-open-range-pat, r=jonas-schievink

feat: Parse half-open `..= X` patterns

Closes https://github.com/rust-lang/rust-analyzer/issues/13739

19 months agofix: resolve all inference vars in `InferenceResult::assoc_resolutions`
Ryo Yoshida [Wed, 14 Dec 2022 12:56:55 +0000 (21:56 +0900)]
fix: resolve all inference vars in `InferenceResult::assoc_resolutions`

19 months agoAuto merge of #13766 - rust-lang:fix-config-patch, r=Veykril
bors [Wed, 14 Dec 2022 13:50:29 +0000 (13:50 +0000)]
Auto merge of #13766 - rust-lang:fix-config-patch, r=Veykril

Fix wrong config patching logic for addCallParenthesis

19 months agominor: Set the `experimental` AsciiDoc document attribute to generated draft changelog
Noritada Kobayashi [Wed, 14 Dec 2022 09:49:26 +0000 (18:49 +0900)]
minor: Set the `experimental` AsciiDoc document attribute to generated draft changelog

The keyboard macro (`kbd:[...]`) requires this attribute.

This default change will prevent issues like
https://github.com/rust-analyzer/rust-analyzer.github.io/pull/191 .

19 months agoParse `..= X` patterns
Jonas Schievink [Tue, 13 Dec 2022 16:32:25 +0000 (17:32 +0100)]
Parse `..= X` patterns

19 months agoFix wrong config patching logic for addCallParenthesis
Florian Diebold [Tue, 13 Dec 2022 15:39:00 +0000 (16:39 +0100)]
Fix wrong config patching logic for addCallParenthesis

19 months agoFix "needs parens" check in `remove_parentheses` assist
Maybe Waffle [Tue, 13 Dec 2022 00:06:00 +0000 (00:06 +0000)]
Fix "needs parens" check in `remove_parentheses` assist

19 months agoAuto merge of #13746 - feniljain:fix_extract_function, r=jonas-schievink
bors [Mon, 12 Dec 2022 14:51:03 +0000 (14:51 +0000)]
Auto merge of #13746 - feniljain:fix_extract_function, r=jonas-schievink

fix: make make_body respect comments in extract_function

Possible fix for #13621

### Points to help in review:

- Earlier we were only considering statements in a block expr and hence comments were being ignored, now we handle tokens hence making it aware of comments and then preserving them using `hacky_block_expr_with_comments`

Seems like I am not able to attach output video, github is glitching for it :(

19 months agoAuto merge of #13715 - feniljain:fix_completions, r=jonas-schievink
bors [Mon, 12 Dec 2022 14:37:45 +0000 (14:37 +0000)]
Auto merge of #13715 - feniljain:fix_completions, r=jonas-schievink

fix: breaking snippets on typed incomplete suggestions

Possible fix for #7929

Fix the case where if a user types `&&42.o`, snippet completion was still applying &&Ok(42). Note this was fixed previously on `&&42.` but this still remained a problem for this case

Previous relevant PR: #13517

### Points to help in review:

- The main problem why everything broke on adding an extra `o` was, earlier `dot_receiver` was `42.` which was a `LITERAL` but now `42.o` becomes a `FIELD_EXPR`

- Till now `include_references` was just checking for parent of `LITERAL` and if it was a `REF_EXPR`, but now we consider `FIELD_EXPR` and traverse all of them, finally to reach `REF_EXPR`. If `REF_EXPR` is not found we  just return the original `initial_element`

- We are constructing a new node during `include_references` because if we rely on `dot_receiver` solely we would get `&&42.o` to be replaced with, but we want `&&42` to be replaced with

### Output Video:

https://user-images.githubusercontent.com/49019259/205420166-efbdef78-5b3a-4aef-ab4b-d892dac056a0.mov

Hope everything I wrote makes sense ðŸ˜…

Also interestingly previous PR's number was `13517` and this PR's number is `13715`, nicee

19 months agoAuto merge of #13726 - feniljain:fix_assists, r=jonas-schievink
bors [Mon, 12 Dec 2022 14:06:45 +0000 (14:06 +0000)]
Auto merge of #13726 - feniljain:fix_assists, r=jonas-schievink

feat: allow unwrap block in let initializers

Possible fix for #13679

### Points to help in review:

- I just added a parent case for let statements and it seems everything else was in place already, so turned out to be a small fix

19 months agoAuto merge of #13732 - rami3l:fix/gen-partial-eq, r=jonas-schievink
bors [Mon, 12 Dec 2022 13:52:49 +0000 (13:52 +0000)]
Auto merge of #13732 - rami3l:fix/gen-partial-eq, r=jonas-schievink

fix: add fallback case in generated `PartialEq` impl

Partially fixes #13727.

When generating `PartialEq` implementations for enums, the original code can already generate the following fallback case:

```rs
_ => std::mem::discriminant(self) == std::mem::discriminant(other),
```

However, it has been suppressed in the following example for no good reason:

```rs
enum Either<T, U> {
    Left(T),
    Right(U),
}

impl<T, U> PartialEq for Either<T, U> {
    fn eq(&self, other: &Self) -> bool {
        match (self, other) {
            (Self::Left(l0), Self::Left(r0)) => l0 == r0,
            (Self::Right(l0), Self::Right(r0)) => l0 == r0,
            // _ => std::mem::discriminant(self) == std::mem::discriminant(other),
            // ^ this completes the match arms!
        }
    }
}
```

This PR has removed that suppression logic.

~~Of course, the PR could have suppressed the fallback case generation for single-variant enums instead, but I believe that this case is quite rare and should be caught by `#[warn(unreachable_patterns)]` anyway.~~

After this fix, when the enum has >1 variants, the following fallback arm will be generated :

* `_ => false,` if we've already gone through every case where the variants of `self` and `other` match;
* The original one (as stated above) in other cases.

---

Note: The code example is still wrong after the fix due to incorrect trait bounds.

19 months agoAuto merge of #13762 - jonas-schievink:underscore-expr-first, r=jonas-schievink
bors [Mon, 12 Dec 2022 12:12:02 +0000 (12:12 +0000)]
Auto merge of #13762 - jonas-schievink:underscore-expr-first, r=jonas-schievink

fix: Fix parsing of `_ = x` in closure body

Fixes https://github.com/rust-lang/rust-analyzer/issues/13757

19 months agoFix parsing of `_ = x` in closure body
Jonas Schievink [Mon, 12 Dec 2022 11:57:29 +0000 (12:57 +0100)]
Fix parsing of `_ = x` in closure body

19 months agoAuto merge of #13756 - flodiebold:simplify-assoc-item-subst, r=flodiebold
bors [Sat, 10 Dec 2022 16:06:54 +0000 (16:06 +0000)]
Auto merge of #13756 - flodiebold:simplify-assoc-item-subst, r=flodiebold

Make assoc_resolutions always have a Substitution

19 months agoMake assoc_resolutions always have a Substitution
Florian Diebold [Sat, 10 Dec 2022 16:05:33 +0000 (17:05 +0100)]
Make assoc_resolutions always have a Substitution

19 months agoAuto merge of #13725 - bvanjoi:resolve-const-triat-impls, r=flodiebold
bors [Sat, 10 Dec 2022 13:58:28 +0000 (13:58 +0000)]
Auto merge of #13725 - bvanjoi:resolve-const-triat-impls, r=flodiebold

feat: resolve const for trait impls

Fixed #13694

19 months agofeat: resolve const for trait impls(close #13694)
bvanjoi [Mon, 5 Dec 2022 01:53:11 +0000 (09:53 +0800)]
feat: resolve const for trait impls(close #13694)

19 months agoAuto merge of #13750 - lowr:fix/rpit-in-projection, r=flodiebold
bors [Sat, 10 Dec 2022 11:30:14 +0000 (11:30 +0000)]
Auto merge of #13750 - lowr:fix/rpit-in-projection, r=flodiebold

fix: normalize projection after discarding free `BoundVar`s in RPIT

Fixes #13307

When we lower the return type of a function, it may contain free `BoundVar`s in `OpaqueType`'s substitution, which would cause panic during canonicalization as part of projection normalization. Those `BoundVar`s are irrelevant in this context and will be discarded, and we should defer projection normalization until then.

19 months agoAuto merge of #13742 - lowr:fix/assoc-type-shorthand-with-gats, r=flodiebold
bors [Sat, 10 Dec 2022 11:17:18 +0000 (11:17 +0000)]
Auto merge of #13742 - lowr:fix/assoc-type-shorthand-with-gats, r=flodiebold

fix: only shift `BoundVar`s that come from outside lowering context

Fixes #13734

There are some free functions `TyLoweringContext` methods call, which do not know anything about current binders in scope. We need to shift in the `BoundVar`s in substitutions that we get from them (#4952), but not those we get from `TyLoweringContext` methods.

19 months agoAuto merge of #13749 - WaffleLapkin:remove_some_redudant_adjustment_hints, r=Veykril
bors [Fri, 9 Dec 2022 19:36:05 +0000 (19:36 +0000)]
Auto merge of #13749 - WaffleLapkin:remove_some_redudant_adjustment_hints, r=Veykril

fix: Don't show duplicated adjustment hints for blocks, ifs and matches

Before:
![2022-12-09_21-10](https://user-images.githubusercontent.com/38225716/206761100-5511d91b-2543-4166-aa2c-abdb8bad3613.png)
After:
![2022-12-09_21-22](https://user-images.githubusercontent.com/38225716/206761113-c58dbb5a-8616-4287-a3b4-69c13703294d.png)

----

I want to improve adjustment hints, this is the first step :)

19 months agofix: normalize projection after discarding free `BoundVar`s in RPIT
Ryo Yoshida [Fri, 9 Dec 2022 19:07:00 +0000 (04:07 +0900)]
fix: normalize projection after discarding free `BoundVar`s in RPIT

19 months agofix: Don't show duplicated adjustment hints for blocks, ifs and matches
Maybe Waffle [Fri, 9 Dec 2022 17:40:54 +0000 (17:40 +0000)]
fix: Don't show duplicated adjustment hints for blocks, ifs and matches

19 months agoAuto merge of #13745 - Veykril:ty-hint-variant-field, r=Veykril
bors [Fri, 9 Dec 2022 16:59:02 +0000 (16:59 +0000)]
Auto merge of #13745 - Veykril:ty-hint-variant-field, r=Veykril

Show type info on hover of enum variant fields

Small addition to https://github.com/rust-lang/rust-analyzer/pull/13490

19 months agofix: make make_body respect comments in extract_function
feniljain [Fri, 9 Dec 2022 13:00:30 +0000 (18:30 +0530)]
fix: make make_body respect comments in extract_function

19 months agoAuto merge of #13733 - WaffleLapkin:remove_parens, r=Veykril
bors [Fri, 9 Dec 2022 11:42:09 +0000 (11:42 +0000)]
Auto merge of #13733 - WaffleLapkin:remove_parens, r=Veykril

feat: Add "Remove redundant parentheses" assist

![Peek 2022-12-08 22-22](https://user-images.githubusercontent.com/38225716/206542898-d6c97468-d615-4c5b-8650-f89b9c0321a0.gif)

Can be quite handy when refactoring :)

19 months agoAuto merge of #13722 - MariaSolOs:add-json-contrib, r=Veykril
bors [Fri, 9 Dec 2022 11:29:10 +0000 (11:29 +0000)]
Auto merge of #13722 - MariaSolOs:add-json-contrib, r=Veykril

Add VS Code schema validation for `rust-project.json`

Now that https://github.com/SchemaStore/schemastore/pull/2628 has been merged, adding the `jsonValidation` contribution to the VS Code extension for better editor support when modifying `rust-project.json` files.

Related issue: #13714

19 months agoShow type info on hover of enum variant fields
Lukas Wirth [Fri, 9 Dec 2022 09:09:55 +0000 (10:09 +0100)]
Show type info on hover of enum variant fields

19 months agoSimplify `remove_parentheses`'s implementation
Maybe Waffle [Thu, 8 Dec 2022 18:54:08 +0000 (18:54 +0000)]
Simplify `remove_parentheses`'s implementation

19 months agoMove precedence handling to `crates/syntax`
Maybe Waffle [Thu, 8 Dec 2022 18:44:03 +0000 (18:44 +0000)]
Move precedence handling to `crates/syntax`

19 months agoExplicitly say that the assist removes *redundant* parentheses
Maybe Waffle [Thu, 8 Dec 2022 18:22:57 +0000 (18:22 +0000)]
Explicitly say that the assist removes *redundant* parentheses

19 months agoOnly shift `BoundVar`s that come from outside `TyLoweringContext`
Ryo Yoshida [Thu, 8 Dec 2022 11:41:42 +0000 (20:41 +0900)]
Only shift `BoundVar`s that come from outside `TyLoweringContext`

19 months agoDisallow access to free `BoundVar`s outside `TyLoweringContext`
Ryo Yoshida [Wed, 7 Dec 2022 14:22:37 +0000 (23:22 +0900)]
Disallow access to free `BoundVar`s outside `TyLoweringContext`

19 months agoAuto merge of #13490 - HKalbasi:layout, r=jonas-schievink
bors [Wed, 7 Dec 2022 15:22:03 +0000 (15:22 +0000)]
Auto merge of #13490 - HKalbasi:layout, r=jonas-schievink

Compute data layout of types

cc #4091

Things that aren't working:
* Closures
* Generators (so no support for `Future` I think)
* Opaque types
* Type alias and associated types which may need normalization

Things that show wrong result:
* ~Enums with explicit discriminant~
* SIMD types
* ~`NonZero*` and similar standard library items which control layout with special attributes~

At the user level, I didn't put much work, since I wasn't confident about what is the best way to present this information. Currently it shows size and align for ADTs, and size, align, offset for struct fields, in the hover, similar to clangd. I used it some days and I feel I liked it, but we may consider it too noisy and move it to an assist or command.

19 months agofix: refine fallback case in generated `PartialEq` impl
rami3l [Wed, 7 Dec 2022 02:25:17 +0000 (10:25 +0800)]
fix: refine fallback case in generated `PartialEq` impl

19 months agoAdd a fixme comment in current_target_data_layout
hkalbasi [Tue, 6 Dec 2022 22:59:50 +0000 (02:29 +0330)]
Add a fixme comment in current_target_data_layout

19 months agouse rustc crates instead of copy paste
hkalbasi [Tue, 6 Dec 2022 22:29:38 +0000 (01:59 +0330)]
use rustc crates instead of copy paste

19 months agoConsider expression precedense in `remove_parentheses` assist
Maybe Waffle [Tue, 6 Dec 2022 19:11:24 +0000 (19:11 +0000)]
Consider expression precedense in `remove_parentheses` assist

19 months agoAdd `remove_parentheses` assist
Maybe Waffle [Tue, 6 Dec 2022 16:18:25 +0000 (16:18 +0000)]
Add `remove_parentheses` assist

19 months agofix: add fallback case in generated `PartialEq` impl
rami3l [Tue, 6 Dec 2022 13:40:45 +0000 (21:40 +0800)]
fix: add fallback case in generated `PartialEq` impl

19 months agoAuto merge of #13730 - lowr:feat/builtin-macro-helper-attr, r=Veykril
bors [Tue, 6 Dec 2022 08:16:14 +0000 (08:16 +0000)]
Auto merge of #13730 - lowr:feat/builtin-macro-helper-attr, r=Veykril

Support builtin derive macro helper attributes

Closes #13244

It's a bit wasteful for `Macro2Data` to have `helpers` field currently just for `Default` derive macro, but I tend to think it's okay for the time being given how rare macro2's are used.

19 months agoResolve macro2's derive helpers in IDE layer
Ryo Yoshida [Tue, 6 Dec 2022 06:53:03 +0000 (15:53 +0900)]
Resolve macro2's derive helpers in IDE layer

Macro2's generally don't have derive helpers, but currently builtin
derive macros are declared with macro2 syntax, which can have derive
helpers.

19 months agoParse and collect derive helpers for builtin derive macros
Ryo Yoshida [Mon, 7 Nov 2022 12:24:17 +0000 (21:24 +0900)]
Parse and collect derive helpers for builtin derive macros

19 months agoAuto merge of #13728 - detrumi:chalk-update, r=lnicola
bors [Mon, 5 Dec 2022 17:27:53 +0000 (17:27 +0000)]
Auto merge of #13728 - detrumi:chalk-update, r=lnicola

Update to Chalk 88

This Chalk release introduces fuel for the recursive solver ([chalk#774](https://github.com/rust-lang/chalk/pull/774)).
I'm not sure how often it calls `should_continue` compared to the other solver, so we might want to increase `CHALK_SOLVER_FUEL`, the current default value of 100 might be too low.

This should fix a lot of hangs and crashes, for example this solves the hang in #12897.

19 months agoIncrease Chalk fuel from 100 to 1000
Wilco Kusee [Mon, 5 Dec 2022 17:13:11 +0000 (18:13 +0100)]
Increase Chalk fuel from 100 to 1000

The old value was for the old chalk-engine solver, nowadays the newer chalk-recursive solver is used.
The new solver currently uses fuel a bit more quickly, so a higher value is needed.
Running analysis-stats showed that a value of 100 increases the amount of unknown types,
while for a value of 1000 it's staying mostly the same.

19 months agoUpdate to Chalk 88
Wilco Kusee [Mon, 5 Dec 2022 16:29:23 +0000 (17:29 +0100)]
Update to Chalk 88

19 months agofeat: allow unwrap block in let initializers
feniljain [Mon, 5 Dec 2022 03:07:31 +0000 (08:37 +0530)]
feat: allow unwrap block in let initializers

19 months agoAdd JSON schema contribution
Maria José Solano [Sun, 4 Dec 2022 20:04:56 +0000 (12:04 -0800)]
Add JSON schema contribution

19 months agoAuto merge of #13721 - Veykril:incoherent-impls, r=Veykril
bors [Sun, 4 Dec 2022 19:37:26 +0000 (19:37 +0000)]
Auto merge of #13721 - Veykril:incoherent-impls, r=Veykril

Support `rustc_has_incoherent_inherent_impls`

Fixes us not resolving `<dyn Error>::downcast` now that `Error` moved to core, while that assoc function is declared in `alloc`.

19 months agoSupport `rustc_has_incoherent_inherent_impls`
Lukas Wirth [Sun, 4 Dec 2022 19:12:11 +0000 (20:12 +0100)]
Support `rustc_has_incoherent_inherent_impls`

20 months agosupport nonzero* niche optimizations
hkalbasi [Thu, 27 Oct 2022 19:58:34 +0000 (23:28 +0330)]
support nonzero* niche optimizations

20 months agoCompute data layout of types
hkalbasi [Sun, 23 Oct 2022 08:12:05 +0000 (11:42 +0330)]
Compute data layout of types

20 months agoAuto merge of #13717 - lowr:fix/proc-macro-ident-is-raw, r=Veykril
bors [Sat, 3 Dec 2022 18:42:33 +0000 (18:42 +0000)]
Auto merge of #13717 - lowr:fix/proc-macro-ident-is-raw, r=Veykril

Handle raw identifiers in proc macro server

Fixes #13706

When proc macros create `proc_macro::Ident`s, they pass an identifier text without "r#" prefix and a flag `is_raw` to proc macro server. Our `tt::Ident` currently stores the text *with* "r#" so we need to adjust them somewhere.

Rather than following rustc and adding `is_raw` field to our `tt::Ident`, I opted for adjusting the representation of identifiers in proc macro server, because we don't need the field outside it.

It's hard to write regression test for this, but at least I:
- ran `cargo +nightly t --features sysroot-abi` and all the tests passed
- built proc macro server with `cargo +nightly b -r --bin rust-analyzer-proc-macro-srv --features sysroot-abi` and made sure #13706 resolved
  - For the record, the nightly versions used are `rustc 1.67.0-nightly (32e613bba 2022-12-02)` and `cargo 1.67.0-nightly (e027c4b5d 2022-11-25)`.

20 months agoHandle raw identifiers in proc macro server
Ryo Yoshida [Sat, 3 Dec 2022 13:57:08 +0000 (22:57 +0900)]
Handle raw identifiers in proc macro server

20 months agoAuto merge of #13707 - lowr:feat/move-const-to-impl, r=Veykril
bors [Sat, 3 Dec 2022 13:16:22 +0000 (13:16 +0000)]
Auto merge of #13707 - lowr:feat/move-const-to-impl, r=Veykril

Add `move_const_to_impl` assist

Closes #13277

For the initial implementation, this assist:
- only applies to inherent impl. Much as we can *technically* provide this assist for default impl in trait definitions, it'd be complicated to get it right.
- may break code when the const's name collides with an item of a trait the self type implements.

Comments in the code explain those caveats in a bit more detail.

20 months agoAuto merge of #13713 - allanbrondum:bug/trait-method-callers, r=Veykril
bors [Sat, 3 Dec 2022 12:45:27 +0000 (12:45 +0000)]
Auto merge of #13713 - allanbrondum:bug/trait-method-callers, r=Veykril

check reference is a NameRef (and not Name)

Fixes that implementing methods are shown in call hierarchy https://github.com/rust-lang/rust-analyzer/issues/13712

20 months agofix: breaking snippets on typed incomplete suggestions
feniljain [Sat, 3 Dec 2022 02:40:54 +0000 (08:10 +0530)]
fix: breaking snippets on typed incomplete suggestions

Fix the case where if a user types `&&42.o`, snippet completion
was still applying &&Ok(42). Note this was fixed previously
on `&&42.` but this still remained a problem for this case

20 months agofmt
Allan Brondum Rasmussen [Sat, 3 Dec 2022 00:20:27 +0000 (01:20 +0100)]
fmt

20 months agoremove unneeded test
Allan Brondum Rasmussen [Fri, 2 Dec 2022 23:53:56 +0000 (00:53 +0100)]
remove unneeded test

20 months agocheck reference is a NameRef (and not Name)
Allan Brondum Rasmussen [Fri, 2 Dec 2022 22:50:39 +0000 (23:50 +0100)]
check reference is a NameRef (and not Name)

20 months agoAdd `move_const_to_impl` assist
Ryo Yoshida [Tue, 22 Nov 2022 09:36:58 +0000 (18:36 +0900)]
Add `move_const_to_impl` assist

20 months agoAuto merge of #13697 - jonas-schievink:version-inlay-hint-resolve-data, r=jonas-schievink
bors [Tue, 29 Nov 2022 18:37:00 +0000 (18:37 +0000)]
Auto merge of #13697 - jonas-schievink:version-inlay-hint-resolve-data, r=jonas-schievink

internal: Version the inlay hint resolve data

cc https://github.com/rust-lang/rust-analyzer/issues/13657
cc https://github.com/rust-lang/rust-analyzer/issues/13372
cc https://github.com/rust-lang/rust-analyzer/issues/13170

This will make us log an error and return the unmodified inlay hints when the client attempts to resolve inlay hints in a file that has since been modified.

20 months agoUpdate hash
Jonas Schievink [Tue, 29 Nov 2022 18:33:16 +0000 (19:33 +0100)]
Update hash

20 months agoVersion the inlay hint resolve data
Jonas Schievink [Tue, 29 Nov 2022 18:20:32 +0000 (19:20 +0100)]
Version the inlay hint resolve data

20 months agoAuto merge of #13696 - jonas-schievink:signature-help-between-closing-delims, r=jonas...
bors [Tue, 29 Nov 2022 17:51:15 +0000 (17:51 +0000)]
Auto merge of #13696 - jonas-schievink:signature-help-between-closing-delims, r=jonas-schievink

fix: Fix signature help not showing up when cursor is between `))` or `>>`

Fixes https://github.com/rust-lang/rust-analyzer/issues/13672

20 months agoFix signature help not showing up when cursor is between `))` or `>>`
Jonas Schievink [Tue, 29 Nov 2022 17:50:21 +0000 (18:50 +0100)]
Fix signature help not showing up when cursor is between `))` or `>>`

20 months agoAuto merge of #13695 - detrumi:chalk-update, r=Veykril
bors [Tue, 29 Nov 2022 14:58:09 +0000 (14:58 +0000)]
Auto merge of #13695 - detrumi:chalk-update, r=Veykril

Update Chalk to version 87

Changes:
- Support new `tuple_trait` lang item ([chalk#782](https://github.com/rust-lang/chalk/pull/782))
- Removed empty lifetime ([chalk#783](https://github.com/rust-lang/chalk/pull/783))

20 months agoUpdate Chalk to version 87
Wilco Kusee [Tue, 29 Nov 2022 14:25:09 +0000 (15:25 +0100)]
Update Chalk to version 87

20 months agoAuto merge of #13690 - Crauzer:vararg-type, r=Veykril
bors [Tue, 29 Nov 2022 07:55:57 +0000 (07:55 +0000)]
Auto merge of #13690 - Crauzer:vararg-type, r=Veykril

feat: Implement vararg parameter type inference

This PR implements the "collection" of the `va_list` type into the function parameter types list.

20 months agoAuto merge of #13686 - MariaSolOs:test-lenses, r=Veykril
bors [Tue, 29 Nov 2022 07:42:35 +0000 (07:42 +0000)]
Auto merge of #13686 - MariaSolOs:test-lenses, r=Veykril

Don't show runnable code lenses in libraries outside of the workspace

Addresses #13664. For now I'm just disabling runnable code lenses since the ones that display the number of references and implementations do work correctly with external code.

Also made a tiny TypeScript change to use the typed `sendNotification` overload.

20 months agoFix formatting
Maria José Solano [Tue, 29 Nov 2022 03:10:16 +0000 (19:10 -0800)]
Fix formatting