]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoFix highlighting of `Self`
Lukas Wirth [Sat, 5 Mar 2022 22:34:37 +0000 (23:34 +0100)]
Fix highlighting of `Self`

2 years agofix: Recognize `Self` as a proper keyword
Lukas Wirth [Sat, 5 Mar 2022 22:20:06 +0000 (23:20 +0100)]
fix: Recognize `Self` as a proper keyword

2 years agoMerge #11598
bors[bot] [Sat, 5 Mar 2022 11:31:29 +0000 (11:31 +0000)]
Merge #11598

11598: feat: Parse destructuring assignment r=Veykril a=ChayimFriedman2

Part of #11532.

Lowering is not as easy and may not even be feasible right now as it requires generating identifiers: `(a, b) = (b, a)` is desugared into
```rust
{
    let (<gensym_a>, <gensym_b>) = (b, a);
    a = <gensym_a>;
    b = <gensym_b>;
}
```

rustc uses hygiene to implement that, but we don't support hygiene yet.

However, I think parsing was the main problem as lowering will just affect type inference, and while `{unknown}` is not nice it's much better than a syntax error.

I'm still looking for the best way to do lowering, though.

Fixes #11454.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoMerge #11574
bors[bot] [Sat, 5 Mar 2022 11:20:05 +0000 (11:20 +0000)]
Merge #11574

11574: Small refactor text edit 2nd r=Veykril a=HansAuger

Some more changes to text_edit. Basic idea is to make `Indel` implement `PartialOrd` to take advantage of some sweet sweet iteration, most notably itertool's `merge`.

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoMerge #11623
bors[bot] [Sat, 5 Mar 2022 10:32:07 +0000 (10:32 +0000)]
Merge #11623

11623: fix: Add type variable table to InferenceTableSnapshot r=flodiebold a=tysg

Fixes #11601.

I observed that removing the `rollback` line in https://github.com/rust-analyzer/rust-analyzer/commit/6fc3d3aa4cbf637d748c60cfdbb98b5f6a040576 fixes the issue.

Looking at the stacktrace, I believe not restoring `type_variable_table` causes `type_variable_table` and `var_unification_table` to go out of sync, then when `hir_ty::infer::unify::InferenceTable::new_var` tries to extend `type_variable_table` to be the same length as `var_unification_table`, problems will arise.

However, I cannot pinpoint exactly how or where the vector capacity overflow happens, so my understanding might not be correct after all.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2 years agoAdd type variable table to InferenceTableSnapshot
Tianyi Song [Sat, 5 Mar 2022 09:59:28 +0000 (17:59 +0800)]
Add type variable table to InferenceTableSnapshot

2 years agoMerge #11622
bors[bot] [Fri, 4 Mar 2022 23:20:29 +0000 (23:20 +0000)]
Merge #11622

11622: show variadic args in hover function signature r=Veykril a=euclio

The current behavior is to ignore the ellipsis.

Co-authored-by: Andy Russell <arussell123@gmail.com>
2 years agoshow variadic args in hover function signature
Andy Russell [Fri, 4 Mar 2022 21:24:13 +0000 (16:24 -0500)]
show variadic args in hover function signature

2 years agoMerge #11595
bors[bot] [Fri, 4 Mar 2022 20:21:43 +0000 (20:21 +0000)]
Merge #11595

11595: fix: lower string literals with actual value instead of default r=lnicola a=tysg

Fixes #11582. Some questions below in the code review section.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2 years agoMerge #11620
bors[bot] [Fri, 4 Mar 2022 19:47:39 +0000 (19:47 +0000)]
Merge #11620

11620: feat: Support locals with multiple declaration sites r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8860

This implements the first approach of https://github.com/rust-analyzer/rust-analyzer/issues/8860#issuecomment-845461773:
> treat every Local as having potentially many sources?

The way this is written does allow changing to a MultiLocal approach instead though, I'll investigate whether that turns out to be better or not.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Fri, 4 Mar 2022 19:09:32 +0000 (20:09 +0100)]
Simplify

2 years agoSupport locals with multiple declaration sites
Lukas Wirth [Fri, 4 Mar 2022 18:49:08 +0000 (19:49 +0100)]
Support locals with multiple declaration sites

2 years agoMerge #11140
bors[bot] [Fri, 4 Mar 2022 12:55:07 +0000 (12:55 +0000)]
Merge #11140

11140: Preserve order of generic args r=HKalbasi a=HKalbasi

https://github.com/rust-lang/rust/pull/90207 removed order restriction of generic args, i.e. const generics can now become before of type generics. We need to preserve this order to analyze correctly, and this PR does that.

It also simplifies implementation of const generics a bit IMO.

Implementing default generics the same problem of #7434, we need lower them to body and then evaluate them.

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2 years agoResolve only type params in type ns
hkalbasi [Fri, 4 Mar 2022 09:00:53 +0000 (12:30 +0330)]
Resolve only type params in type ns

2 years agoPreserve order of generic args
hkalbasi [Wed, 29 Dec 2021 13:35:59 +0000 (17:05 +0330)]
Preserve order of generic args

2 years agoLower string literals with real val, not default
Tianyi Song [Tue, 1 Mar 2022 07:44:53 +0000 (15:44 +0800)]
Lower string literals with real val, not default

2 years agoMerge #11616
bors[bot] [Thu, 3 Mar 2022 22:25:42 +0000 (22:25 +0000)]
Merge #11616

11616: fix: Fix semantic highlighting breaking for lifetimes in macros r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoslightly improve highlighting performance for derive annotated items
Lukas Wirth [Thu, 3 Mar 2022 21:59:34 +0000 (22:59 +0100)]
slightly improve highlighting performance for derive annotated items

2 years agofix: Fix semantic highlighting breaking for lifetimes in macros
Lukas Wirth [Thu, 3 Mar 2022 21:50:43 +0000 (22:50 +0100)]
fix: Fix semantic highlighting breaking for lifetimes in macros

2 years agoMerge #11613
bors[bot] [Thu, 3 Mar 2022 18:59:22 +0000 (18:59 +0000)]
Merge #11613

11613: fix: Add `abort` to safe intrinsics list r=lnicola a=lnicola

Closes #11611

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd abort to safe intrinsics list
Laurențiu Nicola [Thu, 3 Mar 2022 18:58:20 +0000 (20:58 +0200)]
Add abort to safe intrinsics list

2 years agoMerge #11610
bors[bot] [Thu, 3 Mar 2022 17:42:33 +0000 (17:42 +0000)]
Merge #11610

11610: Add a (currently failing) test for #11242 r=flodiebold a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoMerge #11609
bors[bot] [Thu, 3 Mar 2022 17:34:00 +0000 (17:34 +0000)]
Merge #11609

11609: Add another case to the syntax fixup code r=flodiebold a=flodiebold

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoAdd a (currently failing) test for #11242
Florian Diebold [Thu, 3 Mar 2022 17:32:40 +0000 (18:32 +0100)]
Add a (currently failing) test for #11242

2 years agoAdd another case to the syntax fixup code
Florian Diebold [Thu, 3 Mar 2022 17:29:40 +0000 (18:29 +0100)]
Add another case to the syntax fixup code

2 years agoDo not consider `_` to be an expression for `macro_rules!`
Chayim Refael Friedman [Wed, 2 Mar 2022 01:50:54 +0000 (01:50 +0000)]
Do not consider `_` to be an expression for `macro_rules!`

2 years agoParse destructuring assignment
Chayim Refael Friedman [Thu, 24 Feb 2022 08:49:47 +0000 (08:49 +0000)]
Parse destructuring assignment

The only patterns we should parse are `..` in structs and `_`: the rest are either not supported or already valid expressions.

2 years agoMerge #11593
bors[bot] [Tue, 1 Mar 2022 18:27:04 +0000 (18:27 +0000)]
Merge #11593

11593: Build release binaries on Ubuntu 18.04 r=lnicola a=lnicola

Fixes #11558

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoBuild release binaries on Ubuntu 18.04
Laurențiu Nicola [Tue, 1 Mar 2022 05:24:27 +0000 (07:24 +0200)]
Build release binaries on Ubuntu 18.04

2 years agoMerge #11433
bors[bot] [Mon, 28 Feb 2022 10:15:44 +0000 (10:15 +0000)]
Merge #11433

11433: minor: Add scary warning to `onEnter` r=lnicola a=lnicola

Closes #11432

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd scary warning to onEnter
Laurențiu Nicola [Tue, 8 Feb 2022 06:34:24 +0000 (08:34 +0200)]
Add scary warning to onEnter

2 years agoMerge #11579
bors[bot] [Mon, 28 Feb 2022 09:18:26 +0000 (09:18 +0000)]
Merge #11579

11579: minor: Future-proof against a next edition by using `>=` and not `==` r=lnicola a=ChayimFriedman2

So that we won't have a strange bug when edition 2024 will land.

rustc [also does that](https://github.com/rust-lang/rust/blob/427cf81206d3b6cf41c86c1b9ce113a33f1ce860/compiler/rustc_builtin_macros/src/edition_panic.rs#L84).

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoFuture-proof against a next edition by using `>=` and not `==`
Chayim Refael Friedman [Mon, 28 Feb 2022 09:13:55 +0000 (11:13 +0200)]
Future-proof against a next edition by using `>=` and not `==`

So that we won't have a strange bug when edition 2024 will land.

rustc [also does that](https://github.com/rust-lang/rust/blob/427cf81206d3b6cf41c86c1b9ce113a33f1ce860/compiler/rustc_builtin_macros/src/edition_panic.rs#L84).

2 years agoredirct: use iterators and knowledge about preordered arrays for more efficient merging
Moritz Vetter [Mon, 28 Feb 2022 04:13:45 +0000 (05:13 +0100)]
redirct: use iterators and knowledge about preordered arrays for more efficient merging

2 years agoMerge #11573
bors[bot] [Sun, 27 Feb 2022 12:00:04 +0000 (12:00 +0000)]
Merge #11573

11573: refactorings and FIXME fixes in text edit r=lnicola a=HansAuger

This is mainly me learning some rust, and only anecdotally about addressing some `fixme`s. Feel free to nope :)

There is a follow up PR in the pipeline which tackles the other two `fixme`s but it's a bit more invasive. So I wanted to get this out of the way

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoMerge #11567
bors[bot] [Sun, 27 Feb 2022 11:34:01 +0000 (11:34 +0000)]
Merge #11567

11567: Fix `if` in #11561 r=Veykril a=ChayimFriedman2

Fixes #11561.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoMerge #11570
bors[bot] [Sun, 27 Feb 2022 09:17:46 +0000 (09:17 +0000)]
Merge #11570

11570: minor: Remove misleading comments r=lnicola a=ChayimFriedman2

They're not true anymore after #11375.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoRemove misleading comments
Chayim Refael Friedman [Sun, 27 Feb 2022 07:52:11 +0000 (09:52 +0200)]
Remove misleading comments

They're not true anymore after #11375.

2 years agoadd two more unit tests for text_edit
Moritz Vetter [Sun, 27 Feb 2022 01:11:56 +0000 (02:11 +0100)]
add two more unit tests for text_edit

2 years agoFix `if` in #11561
Chayim Refael Friedman [Sun, 27 Feb 2022 00:12:22 +0000 (00:12 +0000)]
Fix `if` in #11561

2 years agoMerge #11560
bors[bot] [Sat, 26 Feb 2022 17:00:11 +0000 (17:00 +0000)]
Merge #11560

11560: internal: Update `url` to make `webrender` build when computing metrics r=jonas-schievink a=lnicola

Closes #9997

This doesn't seem to affect the metrics, but I'm not sure since somehow I get different values than what shows up on CI.

With `stable`:

```
  exprs: 94151, ??ty: 96 (0%), ?ty: 25 (0%), !ty: 6
```

CI shows 16.

Also, https://github.com/rust-analyzer/rust-analyzer/pull/7250 strikes again, I can never tell what those numbers are.

r? `@jonas-schievink`

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11565
bors[bot] [Sat, 26 Feb 2022 16:49:16 +0000 (16:49 +0000)]
Merge #11565

11565: fix: Fix body selection in while loops r=Veykril a=lnicola

CC #11561

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11566
bors[bot] [Sat, 26 Feb 2022 15:48:11 +0000 (15:48 +0000)]
Merge #11566

11566: minor: Make hir::Local::name infallible r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMake hir::Local::name infallible
Lukas Wirth [Sat, 26 Feb 2022 14:06:11 +0000 (15:06 +0100)]
Make hir::Local::name infallible

2 years agorefact: edit text in place in TextEdit::apply
Moritz Vetter [Sat, 26 Feb 2022 14:50:09 +0000 (15:50 +0100)]
refact: edit text in place in TextEdit::apply

2 years agotest: add unit test for TextEdit::apply()
Moritz Vetter [Sat, 26 Feb 2022 14:46:14 +0000 (15:46 +0100)]
test: add unit test for TextEdit::apply()

2 years agoFix body selection in while loops
Laurențiu Nicola [Sat, 26 Feb 2022 14:45:06 +0000 (16:45 +0200)]
Fix body selection in while loops

2 years agoMerge #11564
bors[bot] [Sat, 26 Feb 2022 13:53:30 +0000 (13:53 +0000)]
Merge #11564

11564: internal: Cleanup highlighting tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRename test highlighting output files
Lukas Wirth [Sat, 26 Feb 2022 13:51:13 +0000 (14:51 +0100)]
Rename test highlighting output files

2 years agoSplit up highlighting tests a bit more
Lukas Wirth [Sat, 26 Feb 2022 13:45:09 +0000 (14:45 +0100)]
Split up highlighting tests a bit more

2 years agoRe-order and cleanup highlighting tests
Lukas Wirth [Sat, 26 Feb 2022 13:29:03 +0000 (14:29 +0100)]
Re-order and cleanup highlighting tests

2 years agoMerge #11562
bors[bot] [Sat, 26 Feb 2022 12:54:57 +0000 (12:54 +0000)]
Merge #11562

11562: fix: Don't emit unresolvedReference highlight tags in unlinked files r=Veykril a=Veykril

Emitting these overwrites any syntax based highlighting that is being done in the file, causing a lot of noise if the user gave them a specific color.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Don't emit unresolvedReference highlight tags in unlinked files
Lukas Wirth [Sat, 26 Feb 2022 12:53:54 +0000 (13:53 +0100)]
fix: Don't emit unresolvedReference highlight tags in unlinked files

2 years agoUpdate url to make webrender build
Laurențiu Nicola [Sat, 26 Feb 2022 09:56:57 +0000 (11:56 +0200)]
Update url to make webrender build

2 years agoMerge #11538
bors[bot] [Fri, 25 Feb 2022 21:17:24 +0000 (21:17 +0000)]
Merge #11538

11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofeat: Make private editable completions configurable, disable by default
Lukas Wirth [Wed, 23 Feb 2022 15:02:54 +0000 (16:02 +0100)]
feat: Make private editable completions configurable, disable by default

2 years agoMerge #11554
bors[bot] [Fri, 25 Feb 2022 18:14:04 +0000 (18:14 +0000)]
Merge #11554

11554: fix: fix type mismatches with `unreachable!` macro in Rust 1.59 r=jonas-schievink a=jonas-schievink

should fix https://github.com/rust-analyzer/rust-analyzer/issues/11551

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoImplement the new built-in `unreachable!` macro
Jonas Schievink [Fri, 25 Feb 2022 18:13:04 +0000 (19:13 +0100)]
Implement the new built-in `unreachable!` macro

2 years agoMerge #11552
bors[bot] [Fri, 25 Feb 2022 17:41:05 +0000 (17:41 +0000)]
Merge #11552

11552: fix: properly display `$crate` in hovers r=jonas-schievink a=jonas-schievink

We used to print it as `{extern_crate}`, this PR resolves it to the crate's name, or falls back to `$crate` if the crate has no name.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoResolve `$crate` in `HirDisplay` of `Path`
Jonas Schievink [Fri, 25 Feb 2022 17:38:51 +0000 (18:38 +0100)]
Resolve `$crate` in `HirDisplay` of `Path`

2 years agoMerge #11550
bors[bot] [Fri, 25 Feb 2022 16:11:22 +0000 (16:11 +0000)]
Merge #11550

11550: Refactor autoderef/method resolution r=flodiebold a=flodiebold

- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoAvoid autoderef coercions leaking if they don't apply
Florian Diebold [Fri, 25 Feb 2022 14:46:02 +0000 (15:46 +0100)]
Avoid autoderef coercions leaking if they don't apply

2 years agoMerge #11549
bors[bot] [Fri, 25 Feb 2022 13:34:18 +0000 (13:34 +0000)]
Merge #11549

11549: feat: support concat_bytes r=jonas-schievink a=ihciah

Support `concat_bytes`.
Solve #11544.

Co-authored-by: ihciah <ihciah@gmail.com>
2 years agoFix unreachable pub
Florian Diebold [Fri, 25 Feb 2022 11:09:49 +0000 (12:09 +0100)]
Fix unreachable pub

2 years agoMerge #11548
bors[bot] [Fri, 25 Feb 2022 10:57:24 +0000 (10:57 +0000)]
Merge #11548

11548: Add CSV output to analysis-stats r=flodiebold a=flodiebold

For easy diffing, to find changes in unknown types / type mismatches.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoRefactor autoderef and method resolution
Florian Diebold [Wed, 16 Feb 2022 16:44:03 +0000 (17:44 +0100)]
Refactor autoderef and method resolution

 - don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

2 years agoAdd some tests
Florian Diebold [Sun, 5 Sep 2021 14:40:46 +0000 (16:40 +0200)]
Add some tests

2 years agofeat: support concat_bytes
ihciah [Fri, 25 Feb 2022 10:46:11 +0000 (18:46 +0800)]
feat: support concat_bytes

2 years agoAdd CSV output to analysis-stats
Florian Diebold [Thu, 24 Feb 2022 19:44:26 +0000 (20:44 +0100)]
Add CSV output to analysis-stats

For easy diffing.

2 years agoMinor perf change: `vec.clone().into_iter()` => `vec.iter().cloned()`
Chayim Refael Friedman [Fri, 25 Feb 2022 01:00:24 +0000 (01:00 +0000)]
Minor perf change: `vec.clone().into_iter()` => `vec.iter().cloned()`

2 years agoUpdate references to macro_rules in the "Extract module" assist
Chayim Refael Friedman [Fri, 25 Feb 2022 01:23:40 +0000 (01:23 +0000)]
Update references to macro_rules in the "Extract module" assist

See https://github.com/rust-analyzer/ungrammar/pull/46#issuecomment-1049801890.

2 years agoDo not change visibility of macro_rules in the "Extract module" assist
Chayim Refael Friedman [Fri, 25 Feb 2022 01:23:15 +0000 (01:23 +0000)]
Do not change visibility of macro_rules in the "Extract module" assist

See https://github.com/rust-analyzer/ungrammar/pull/46#issuecomment-1049801890.

2 years agoGenerate AST code after rust-analyzer/ungrammar#46
Chayim Refael Friedman [Fri, 25 Feb 2022 00:02:06 +0000 (00:02 +0000)]
Generate AST code after rust-analyzer/ungrammar#46

2 years agoMerge #11462
bors[bot] [Thu, 24 Feb 2022 20:59:27 +0000 (20:59 +0000)]
Merge #11462

11462: 11422 highlight continue and break r=Veykril a=HansAuger

Closes #11422

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agorefactor(11422): make number unsigned, nest enums into each other
Moritz Vetter [Thu, 24 Feb 2022 20:29:26 +0000 (21:29 +0100)]
refactor(11422): make number unsigned, nest enums into each other

2 years agofix(11422): have two different funuctions - one for iterating breaks, one for iteraat...
Moritz Vetter [Thu, 24 Feb 2022 17:56:08 +0000 (18:56 +0100)]
fix(11422): have two different funuctions - one for iterating breaks, one for iteraating breaks and continues

2 years agoadd logic to highlight continue and break keywords according to expectations
Moritz Vetter [Sun, 13 Feb 2022 11:48:04 +0000 (12:48 +0100)]
add logic to highlight continue and break keywords according to expectations

2 years agorefactor helper function to work with function taking expression enum instead of...
Moritz Vetter [Sun, 13 Feb 2022 11:04:51 +0000 (12:04 +0100)]
refactor helper function to work with function taking expression enum instead of break expression

2 years agoadd some breaking tests (TDD - style)
Moritz Vetter [Sun, 13 Feb 2022 03:05:52 +0000 (04:05 +0100)]
add some breaking tests (TDD - style)

2 years agoMerge #11531
bors[bot] [Thu, 24 Feb 2022 12:57:51 +0000 (12:57 +0000)]
Merge #11531

11531: fix: Make fill_match_arms assist handle doc(hidden) and non_exhaustive r=Veykril a=OleStrohm

Fixes #11499
Fixes #11500
This keeps track of the relevant attributes and adds in a wildcard pat at the end of the match when necessary.

I decided to do them in the same PR since they both needed the ability to add a wildcard arm, and so their changes would overlap if done separately, but I'll split them up if that seems better.

This is my first PR to rust-analyzer, so all feedback is greatly appreciated!

Co-authored-by: Ole Strohm <strohm99@gmail.com>
2 years agoMerge #11540
bors[bot] [Thu, 24 Feb 2022 11:25:18 +0000 (11:25 +0000)]
Merge #11540

11540: fix: Resolve private fields in type inference r=flodiebold a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253#issuecomment-920962927
(the same issue probably exists for method calls, but I think fixing that might be trickier)

Visibility checks were introduced in https://github.com/rust-analyzer/rust-analyzer/issues/7841 for autoderef to work properly, so now we just record the first field we find unconditionally, and then overwrite it if autoderef manages to find another field in a later cycle.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #11545
bors[bot] [Thu, 24 Feb 2022 10:14:36 +0000 (10:14 +0000)]
Merge #11545

11545: add `is_slice` method to `hir::Type` r=flodiebold a=nerdypepper

would like to have this on `hir::Type` for a small project i am working on, unless there is another way to check if `hir::Type` is a slice primitive?

Co-authored-by: Akshay <nerdy@peppe.rs>
2 years agoadd `is_slice` method to `hir::Type`
Akshay [Thu, 24 Feb 2022 09:50:12 +0000 (15:20 +0530)]
add `is_slice` method to `hir::Type`

2 years agoIgnore doc(hidden) for crate-local enums
Ole Strohm [Wed, 23 Feb 2022 18:08:18 +0000 (18:08 +0000)]
Ignore doc(hidden) for crate-local enums

2 years agofix: Resolve private fields in type inference
Lukas Wirth [Wed, 23 Feb 2022 15:45:58 +0000 (16:45 +0100)]
fix: Resolve private fields in type inference

2 years agoSimplify
Lukas Wirth [Wed, 23 Feb 2022 15:29:33 +0000 (16:29 +0100)]
Simplify

2 years agoMerge #11539
bors[bot] [Wed, 23 Feb 2022 15:05:22 +0000 (15:05 +0000)]
Merge #11539

11539: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Wed, 23 Feb 2022 14:55:06 +0000 (15:55 +0100)]
Simplify

2 years agoMerge #11537
bors[bot] [Wed, 23 Feb 2022 11:01:06 +0000 (11:01 +0000)]
Merge #11537

11537: internal: Reduce visibility of proc-macros to pub(crate) r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoReduce visibility of proc-macros to pub(crate)
Lukas Wirth [Wed, 23 Feb 2022 10:57:11 +0000 (11:57 +0100)]
Reduce visibility of proc-macros to pub(crate)

2 years agoMerge #11536
bors[bot] [Wed, 23 Feb 2022 10:32:15 +0000 (10:32 +0000)]
Merge #11536

11536: internal: Resolve functions as proc-macros via `FileAstId` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/11528
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoResolve functions as proc-macros via FileAstId
Lukas Wirth [Wed, 23 Feb 2022 10:21:46 +0000 (11:21 +0100)]
Resolve functions as proc-macros via FileAstId

2 years agoMerge #11535
bors[bot] [Wed, 23 Feb 2022 07:59:13 +0000 (07:59 +0000)]
Merge #11535

11535: Add Kakoune and Helix configuration r=lnicola a=woshilapin

Follow-up of https://github.com/rust-analyzer/rust-analyzer.github.io/pull/181
Fixes https://github.com/rust-analyzer/rust-analyzer.github.io/pull/180

cc `@lnicola`

Co-authored-by: Jean SIMARD <woshilapin@tuziwo.info>
2 years agoAdd Kakoune and Helix configuration
Jean SIMARD [Wed, 23 Feb 2022 07:55:16 +0000 (08:55 +0100)]
Add Kakoune and Helix configuration

Follow-up of rust-analyzer/rust-analyser.github.io#181
Fixes rust-analyzer/rust-analyser.github.io#180

2 years agoMerge #11534
bors[bot] [Wed, 23 Feb 2022 04:39:42 +0000 (04:39 +0000)]
Merge #11534

11534: minor: Improve instructions for running pre-release versions r=lnicola a=lnicola

Closes #11468

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoRemove reference to updates.channel from settings
Laurențiu Nicola [Wed, 23 Feb 2022 04:38:01 +0000 (06:38 +0200)]
Remove reference to updates.channel from settings

2 years agoRephrase nightly instructions in the manual
Laurențiu Nicola [Wed, 23 Feb 2022 04:37:16 +0000 (06:37 +0200)]
Rephrase nightly instructions in the manual

2 years agoAdded test
Ole Strohm [Tue, 22 Feb 2022 22:48:44 +0000 (22:48 +0000)]
Added test

2 years agoDedup code
Ole Strohm [Tue, 22 Feb 2022 22:41:03 +0000 (22:41 +0000)]
Dedup code

2 years agoMerge #11461
bors[bot] [Tue, 22 Feb 2022 18:46:12 +0000 (18:46 +0000)]
Merge #11461

11461: Extract struct from enum variant filters generics r=jo-goro a=jo-goro

Fixes #11452.

This PR updates extract_struct_from_enum_variant. Extracting a struct `A` form an enum like
```rust
enum X<'a, 'b> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will now be correctly generated as
```rust
struct A<'a> { a: &'a () }

enum X<'a, 'b> {
    A(A<'a>),
    B { b: &'b () },
}
```
instead of the previous
```rust
struct A<'a, 'b>{ a: &'a () } // <- should not have 'b

enum X<'a, 'b> {
    A(A<'a, 'b>),
    B { b: &'b () },
}
```

This also works for generic type parameters and const generics.

Bounds are also copied, however I have not yet implemented a filter for unneeded bounds. Extracting `B` from the following enum
```rust
enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will be generated as
```rust
struct B<'b: 'a> { b: &'b () } // <- should be `struct B<'b> { b: &'b () }`

enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B(B<'b>),
}
```

Extracting bounds with where clauses is also still not implemented.

Co-authored-by: Jonas Goronczy <goronczy.jonas@gmail.com>