]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoHandle attribute macros in `descend_into_macros`
Jonas Schievink [Sun, 6 Jun 2021 13:51:05 +0000 (15:51 +0200)]
Handle attribute macros in `descend_into_macros`

3 years agoMerge #9155
bors[bot] [Sun, 6 Jun 2021 14:50:06 +0000 (14:50 +0000)]
Merge #9155

9155: internal: replace attribute with equivalent whitespace r=jonas-schievink a=jonas-schievink

This is needed to that the `TokenMap` we create contains offsets that match the source. Currently the offsets don't match because the attribute is removed, shifting all subsequent token offsets by the attribute's text length.

Currently this fix has no visible effect because we don't remap tokens in attribute macros.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoReplace attribute with equivalent whitespace
Jonas Schievink [Sun, 6 Jun 2021 13:51:49 +0000 (15:51 +0200)]
Replace attribute with equivalent whitespace

This is needed to that the `TokenMap` we create contains offsets that
match the source.

3 years agoMerge #9149
bors[bot] [Sat, 5 Jun 2021 19:26:33 +0000 (19:26 +0000)]
Merge #9149

9149: feat: Support goto-definition for include macros input path r=Veykril a=Veykril

![0l6l9iWPNE](https://user-images.githubusercontent.com/3757771/120891155-3fa85800-c607-11eb-9b20-7ac330dceb4b.gif)
Fixes #5871

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #9150
bors[bot] [Sat, 5 Jun 2021 18:16:57 +0000 (18:16 +0000)]
Merge #9150

9150: Unescape generated clippy lints r=lnicola a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #9140
bors[bot] [Sat, 5 Jun 2021 17:23:40 +0000 (17:23 +0000)]
Merge #9140

9140: feat: Render documentation for derive completion r=Veykril a=Veykril

![eEzGiq2wNa](https://user-images.githubusercontent.com/3757771/120847308-9c5a3300-c573-11eb-958d-e0f22f4757ed.gif)

Nothing fancy as all the std derives aren't really documented though maybe some 3rd party crates document them equally to their trait counterparts.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoUnescape generated clippy lints
Lukas Wirth [Sat, 5 Jun 2021 17:14:53 +0000 (19:14 +0200)]
Unescape generated clippy lints

3 years agoSupport goto-definition for include macro paths
Lukas Wirth [Sat, 5 Jun 2021 12:02:36 +0000 (14:02 +0200)]
Support goto-definition for include macro paths

3 years agoMerge #9147
bors[bot] [Sat, 5 Jun 2021 12:29:52 +0000 (12:29 +0000)]
Merge #9147

9147: internal: enable proc macros and build scripts in cli r=flodiebold a=lnicola

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoEnable proc macros and build scripts by default in CLI
Laurențiu Nicola [Sat, 5 Jun 2021 11:03:56 +0000 (14:03 +0300)]
Enable proc macros and build scripts by default in CLI

3 years agoMerge #9148
bors[bot] [Sat, 5 Jun 2021 11:16:46 +0000 (11:16 +0000)]
Merge #9148

9148: minor: Prevent renaming of aliases on usages r=Veykril a=Veykril

Otherwise trying to rename a usage that goes through an alias will still rename the aliased item instead, cc https://github.com/rust-analyzer/rust-analyzer/issues/5671
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoPrevent renaming of aliases on usages
Lukas Wirth [Sat, 5 Jun 2021 11:15:07 +0000 (13:15 +0200)]
Prevent renaming of aliases on usages

3 years agoMerge #9146
bors[bot] [Sat, 5 Jun 2021 10:44:36 +0000 (10:44 +0000)]
Merge #9146

9146: minor: Fix incorrect list nesting in format_like feature description r=Veykril a=Veykril

bors r+
Closes #6261

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix incorrect list nesting in format_like feature description
Lukas Wirth [Sat, 5 Jun 2021 10:43:45 +0000 (12:43 +0200)]
Fix incorrect list nesting in format_like feature description

3 years agoMerge #9145
bors[bot] [Sat, 5 Jun 2021 09:32:40 +0000 (09:32 +0000)]
Merge #9145

9145: internal: Enable attribute macro expansion in `analysis-stats` r=flodiebold a=flodiebold

Before:
```
> $ rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     19.08s, 277minstr
  crates: 34, mods: 688, decls: 13202, fns: 10412
Item Collection:     16.21s, 76ginstr
  exprs: 290580, ??ty: 2508 (0%), ?ty: 1814 (0%), !ty: 947
Inference:           27.46s, 108ginstr
Total:               43.67s, 184ginstr
```
After:
```
> $ ./target/release/rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     1.09s, 277minstr
  crates: 34, mods: 688, decls: 14790, fns: 11006
Item Collection:     18.20s, 78ginstr
  exprs: 297826, ??ty: 493 (0%), ?ty: 558 (0%), !ty: 342
Inference:           28.34s, 111ginstr
Total:               46.54s, 190ginstr
```

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoEnable attribute macro expansion in `analysis-stats`
Florian Diebold [Sat, 5 Jun 2021 09:29:24 +0000 (11:29 +0200)]
Enable attribute macro expansion in `analysis-stats`

Before:
```
> $ rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     19.08s, 277minstr
  crates: 34, mods: 688, decls: 13202, fns: 10412
Item Collection:     16.21s, 76ginstr
  exprs: 290580, ??ty: 2508 (0%), ?ty: 1814 (0%), !ty: 947
Inference:           27.46s, 108ginstr
Total:               43.67s, 184ginstr
```
After:
```
> $ ./target/release/rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     1.09s, 277minstr
  crates: 34, mods: 688, decls: 14790, fns: 11006
Item Collection:     18.20s, 78ginstr
  exprs: 297826, ??ty: 493 (0%), ?ty: 558 (0%), !ty: 342
Inference:           28.34s, 111ginstr
Total:               46.54s, 190ginstr
```

3 years agoComplete third-party attributes
Lukas Wirth [Fri, 4 Jun 2021 19:07:19 +0000 (21:07 +0200)]
Complete third-party attributes

3 years agoRender documentation for derive completion
Lukas Wirth [Fri, 4 Jun 2021 18:25:16 +0000 (20:25 +0200)]
Render documentation for derive completion

3 years agoMerge #9141
bors[bot] [Fri, 4 Jun 2021 18:44:22 +0000 (18:44 +0000)]
Merge #9141

9141: fix: Don't inline mutable locals in 'inline_local_variable' r=Veykril a=Veykril

Fixes #9139

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDon't inline mutable locals in 'inline_local_variable'
Lukas Wirth [Fri, 4 Jun 2021 18:36:43 +0000 (20:36 +0200)]
Don't inline mutable locals in 'inline_local_variable'

3 years agoMerge #9138
bors[bot] [Fri, 4 Jun 2021 17:45:37 +0000 (17:45 +0000)]
Merge #9138

9138: feat: Implement hover for lints r=Veykril a=Veykril

fixes https://github.com/rust-analyzer/rust-analyzer/issues/8857, fixes https://github.com/rust-analyzer/rust-analyzer/issues/3941

![URXBanNxYe](https://user-images.githubusercontent.com/3757771/120830905-4bd8da80-c55f-11eb-9f55-ff5a321726fa.gif)

We also generate the default lints(and lint groups 🎉) instead now by invoking `rustc -W help` and parsing the output from that.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoExclude `crates/ide_db/src/helpers/generated_lints.rs` from `tidy::check_todo`
Lukas Wirth [Fri, 4 Jun 2021 17:18:45 +0000 (19:18 +0200)]
Exclude `crates/ide_db/src/helpers/generated_lints.rs` from `tidy::check_todo`

3 years agoReplace `-` with `_` in generated lint names
Lukas Wirth [Fri, 4 Jun 2021 17:03:45 +0000 (19:03 +0200)]
Replace `-` with `_` in generated lint names

3 years agoGenerate default lint groups
Lukas Wirth [Fri, 4 Jun 2021 16:55:08 +0000 (18:55 +0200)]
Generate default lint groups

3 years agoGenerate default lint completions
Lukas Wirth [Fri, 4 Jun 2021 16:35:19 +0000 (18:35 +0200)]
Generate default lint completions

3 years agoImplement hover for lints
Lukas Wirth [Fri, 4 Jun 2021 15:03:18 +0000 (17:03 +0200)]
Implement hover for lints

3 years agoMerge #9137
bors[bot] [Fri, 4 Jun 2021 14:51:39 +0000 (14:51 +0000)]
Merge #9137

9137: fix: fix incorrect "unresolved import" error when using derive helpers r=jonas-schievink a=jonas-schievink

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

cursed bug

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoReturn `ReachedFixedPoint::No` when resolving derive helper
Jonas Schievink [Fri, 4 Jun 2021 14:50:35 +0000 (16:50 +0200)]
Return `ReachedFixedPoint::No` when resolving derive helper

3 years agoMerge #9136
bors[bot] [Fri, 4 Jun 2021 13:55:49 +0000 (13:55 +0000)]
Merge #9136

9136: feat: Add function references hover action r=Veykril a=Veykril

![image](https://user-images.githubusercontent.com/3757771/120811670-8422ed80-c54c-11eb-87f5-dd65c1f8ef7d.png)
This is off by default as this can slow down hover messages significantly for very big projects I believe.
Fixes #6590
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAdd function references hover action
Lukas Wirth [Fri, 4 Jun 2021 13:49:43 +0000 (15:49 +0200)]
Add function references hover action

3 years agoMerge #9135
bors[bot] [Fri, 4 Jun 2021 12:10:21 +0000 (12:10 +0000)]
Merge #9135

9135: Reorganize inlay_hints tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoCleanup parameter_hint_heuristics inlay hints test
Lukas Wirth [Fri, 4 Jun 2021 12:09:20 +0000 (14:09 +0200)]
Cleanup parameter_hint_heuristics inlay hints test

3 years agoReorganize inlay_hints tests
Lukas Wirth [Fri, 4 Jun 2021 11:47:39 +0000 (13:47 +0200)]
Reorganize inlay_hints tests

3 years agoMerge #9128
bors[bot] [Thu, 3 Jun 2021 16:17:25 +0000 (16:17 +0000)]
Merge #9128

9128: feat: expand procedural attribute macros r=jonas-schievink a=jonas-schievink

This adds experimental support for attribute macros. They can be enabled by setting `rust-analyzer.experimental.procAttrMacros` to `true`.

Known issues:
* Tokens aren't remapped, presumably because we edit the input syntax tree (this causes IDE features to not work inside items with attribute macros on them)
* Macro errors aren't reported correctly

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8971
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8964 / https://github.com/la10736/rstest/issues/120
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/2984
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/5412
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6029
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6687

https://github.com/rust-analyzer/rust-analyzer/issues/6740 is still not fixed – we now expand `#[proc_macro_hack]`, but fail to expand the resulting `proc_macro_call!()` macro.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoSet enable_proc_attr_macros in hir_ty TestDB
Jonas Schievink [Thu, 3 Jun 2021 16:11:33 +0000 (18:11 +0200)]
Set enable_proc_attr_macros in hir_ty TestDB

3 years agoUpdate list of built-in attributes
Jonas Schievink [Thu, 3 Jun 2021 16:06:17 +0000 (18:06 +0200)]
Update list of built-in attributes

3 years agoMake it opt-in
Jonas Schievink [Thu, 3 Jun 2021 14:11:20 +0000 (16:11 +0200)]
Make it opt-in

3 years agoExpand procedural attribute macros
Jonas Schievink [Mon, 31 May 2021 11:37:11 +0000 (13:37 +0200)]
Expand procedural attribute macros

3 years agoMerge #9130
bors[bot] [Thu, 3 Jun 2021 14:26:07 +0000 (14:26 +0000)]
Merge #9130

9130: Prefix/suffix parameter inlay hint hiding heuristic is more strict r=Veykril a=Veykril

Instead of just plainly checking prefix/suffix of the argument string to the parameter name we only check for prefixes and suffixes if they are split apart via an underscore meaning, with the argument `foo`, it will be hidden for the parameter name `foo_bar` but not for `foobar`.

bors r+
Closes https://github.com/rust-analyzer/rust-analyzer/issues/8878

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoPrefix/suffix parameter inlay hint hiding heuristic is more strict
Lukas Wirth [Thu, 3 Jun 2021 14:22:24 +0000 (16:22 +0200)]
Prefix/suffix parameter inlay hint hiding heuristic is more strict

3 years agoMerge #9129
bors[bot] [Thu, 3 Jun 2021 13:45:17 +0000 (13:45 +0000)]
Merge #9129

9129: NFC: remove redundant clones (clippy::perf) r=Veykril a=matthiaskrgr

Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
3 years agoNFC: remove redundant clones (clippy::perf)
Matthias Krüger [Thu, 3 Jun 2021 13:32:46 +0000 (15:32 +0200)]
NFC: remove redundant clones (clippy::perf)

3 years agoMerge #9127
bors[bot] [Thu, 3 Jun 2021 12:27:57 +0000 (12:27 +0000)]
Merge #9127

9127: internal: make variant fields inherit the enum's visibility in the ItemTree r=jonas-schievink a=jonas-schievink

No observable changes from what I can tell, but this is "more correct".

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoItemTree: make variant fields inherit the enum's visibility
Jonas Schievink [Thu, 3 Jun 2021 12:26:26 +0000 (14:26 +0200)]
ItemTree: make variant fields inherit the enum's visibility

3 years agoMerge #9124
bors[bot] [Thu, 3 Jun 2021 12:09:10 +0000 (12:09 +0000)]
Merge #9124

9124: Apply a few clippy suggestions r=lnicola a=clemenswasser

Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
3 years agoMerge #9104
bors[bot] [Thu, 3 Jun 2021 11:52:15 +0000 (11:52 +0000)]
Merge #9104

9104: Implement `#[rustc_skip_array_during_method_dispatch]` r=flodiebold a=jonas-schievink

haxx run the world

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8552
Part of https://github.com/rust-analyzer/rust-analyzer/issues/9056

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAdd comment
Jonas Schievink [Thu, 3 Jun 2021 11:51:43 +0000 (13:51 +0200)]
Add comment

3 years agoUse push_str
Clemens Wasser [Thu, 3 Jun 2021 11:01:16 +0000 (13:01 +0200)]
Use push_str

3 years agoApply more clippy suggestions and update generated
Clemens Wasser [Thu, 3 Jun 2021 10:46:56 +0000 (12:46 +0200)]
Apply more clippy suggestions and update generated

3 years agoMerge #9105
bors[bot] [Thu, 3 Jun 2021 09:55:37 +0000 (09:55 +0000)]
Merge #9105

9105: internal: calculate pattern adjustments r=flodiebold a=iDawer

This extends `InferenceResult` with `pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>`.

Fixes #9095

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
3 years agoApply a few clippy suggestions
Clemens Wasser [Thu, 3 Jun 2021 09:45:10 +0000 (11:45 +0200)]
Apply a few clippy suggestions

3 years agoMerge #9123
bors[bot] [Thu, 3 Jun 2021 08:24:56 +0000 (08:24 +0000)]
Merge #9123

9123: manual.adoc: add Gentoo Linux installation method r=lnicola a=mjkalyan

Added installation instructions for the binary ebuild of the "latest" `rust-analyzer` in Gentoo's GURU repository.

Co-authored-by: mjkalyan <34904034+mjkalyan@users.noreply.github.com>
3 years agomanual.adoc: add Gentoo Linux installation method
mjkalyan [Thu, 3 Jun 2021 06:16:23 +0000 (00:16 -0600)]
manual.adoc: add Gentoo Linux installation method

Added installation instructions for the binary ebuild of the "latest" `rust-analyzer` in Gentoo's GURU repository.

3 years agoMerge #9119
bors[bot] [Wed, 2 Jun 2021 20:28:15 +0000 (20:28 +0000)]
Merge #9119

9119: fix: some minor "extract type alias" fixes r=jonas-schievink a=jonas-schievink

It now correctly works inside traits, and no longer messes up the indentation of the original node

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoPreserve indentation
Jonas Schievink [Wed, 2 Jun 2021 20:27:12 +0000 (22:27 +0200)]
Preserve indentation

3 years agoAccount for traits
Jonas Schievink [Wed, 2 Jun 2021 20:20:41 +0000 (22:20 +0200)]
Account for traits

3 years agoMerge #9118
bors[bot] [Wed, 2 Jun 2021 20:12:10 +0000 (20:12 +0000)]
Merge #9118

9118: Document that `addCallArgumentSnippets` requires `addCallParenthesis r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoDocument that `addCallArgumentSnippets` requires `addCallParenthesis
Lukas Wirth [Wed, 2 Jun 2021 20:10:09 +0000 (22:10 +0200)]
Document that `addCallArgumentSnippets` requires `addCallParenthesis

3 years agoMerge #9117
bors[bot] [Wed, 2 Jun 2021 19:43:29 +0000 (19:43 +0000)]
Merge #9117

9117: Allow expand-macro to be invoked anywhere inside a macro call r=Veykril a=Veykril

I don't really see a reason to only limit this to the name-ref of a macro.
bors r+
Closes #4606

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAllow expand-macro to be invoked anywhere inside a macro call
Lukas Wirth [Wed, 2 Jun 2021 19:39:53 +0000 (21:39 +0200)]
Allow expand-macro to be invoked anywhere inside a macro call

3 years agoMerge #9114
bors[bot] [Wed, 2 Jun 2021 18:01:42 +0000 (18:01 +0000)]
Merge #9114

9114: Fix bind patterns always being treated as ref taking patterns r=Veykril a=Veykril

Fixes #9107
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix bind patterns always being treated as ref taking patterns
Lukas Wirth [Wed, 2 Jun 2021 18:00:39 +0000 (20:00 +0200)]
Fix bind patterns always being treated as ref taking patterns

3 years agoMerge #9108
bors[bot] [Wed, 2 Jun 2021 17:25:11 +0000 (17:25 +0000)]
Merge #9108

9108: Don't show extract into variable assist for unit expressions r=jonas-schievink a=brandondong

**Reproduction:**

```rust
fn main() {
    let mut i = 3;
    $0if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    }$0
}
```

1. Select the snippet of code between the $0's.
2. The extract into variable assist shows up, pushing down the more useful extract into function assist.
3. The resulting output of selecting the extract into variable assist is valid but with the extracted variable having the unit type:
```rust
fn main() {
    let mut i = 3;
    let var_name = if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    };
    var_name
}
```

**Fix:**
- Don't show the extract into variable assist for unit expressions. I could not think of any scenarios where such a variable extraction would be desired.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoMerge #9112
bors[bot] [Wed, 2 Jun 2021 16:18:42 +0000 (16:18 +0000)]
Merge #9112

9112: Fix some bugs in `extract_struct_from_enum_variant` assist r=Veykril a=Veykril

bors r+
Fixes #9100
Fixes #9099
Kind of fixes  #9109, it now copies all the generics might be incorrect if the variant doesn't use all of them)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoFix references to patterns in extract_struct_from_enum_variant assist
Lukas Wirth [Wed, 2 Jun 2021 16:16:59 +0000 (18:16 +0200)]
Fix references to patterns in extract_struct_from_enum_variant assist

3 years agoCarry over attributes in extract_struct_from_enum_variant
Lukas Wirth [Wed, 2 Jun 2021 15:54:57 +0000 (17:54 +0200)]
Carry over attributes in extract_struct_from_enum_variant

3 years agoAccount for generics in extract_struct_from_enum_variant
Lukas Wirth [Wed, 2 Jun 2021 15:44:00 +0000 (17:44 +0200)]
Account for generics in extract_struct_from_enum_variant

3 years agoMerge #9111
bors[bot] [Wed, 2 Jun 2021 15:21:17 +0000 (15:21 +0000)]
Merge #9111

9111: fix: make "extract type alias" place extracted type alias outside of impl r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #9110
bors[bot] [Wed, 2 Jun 2021 15:14:06 +0000 (15:14 +0000)]
Merge #9110

9110: internal: simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRemove obsolete is_new_item field on CompletionContext
Lukas Wirth [Wed, 2 Jun 2021 13:25:02 +0000 (15:25 +0200)]
Remove obsolete is_new_item field on CompletionContext

3 years agoPlace extracted type alias outside of impl
Jonas Schievink [Wed, 2 Jun 2021 14:50:44 +0000 (16:50 +0200)]
Place extracted type alias outside of impl

3 years agoAdd MethodCall and FieldAccess variants to ImmediateLocation
Lukas Wirth [Wed, 2 Jun 2021 13:21:18 +0000 (15:21 +0200)]
Add MethodCall and FieldAccess variants to ImmediateLocation

3 years agoDon't show extract into variable assist for unit expressions
Brandon [Wed, 2 Jun 2021 06:49:31 +0000 (23:49 -0700)]
Don't show extract into variable assist for unit expressions

3 years agointernal: implement pattern adjustments.
Dawer [Tue, 1 Jun 2021 20:29:07 +0000 (01:29 +0500)]
internal: implement pattern adjustments.

3 years agominor: Avoid eprintln on panic
Dawer [Tue, 1 Jun 2021 12:21:00 +0000 (17:21 +0500)]
minor: Avoid eprintln on panic

3 years agoImplement `#[rustc_skip_array_during_method_dispatch]`
Jonas Schievink [Tue, 1 Jun 2021 19:33:14 +0000 (21:33 +0200)]
Implement `#[rustc_skip_array_during_method_dispatch]`

3 years agoMerge #9102
bors[bot] [Tue, 1 Jun 2021 17:03:54 +0000 (17:03 +0000)]
Merge #9102

9102: minor: Fall back to legacy prelude r=jonas-schievink a=jonas-schievink

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

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFall back to legacy prelude
Jonas Schievink [Tue, 1 Jun 2021 17:03:00 +0000 (19:03 +0200)]
Fall back to legacy prelude

3 years agoMerge #9097
bors[bot] [Tue, 1 Jun 2021 11:46:59 +0000 (11:46 +0000)]
Merge #9097

9097: feat: Implement per-edition preludes r=jonas-schievink a=jonas-schievink

Part of https://github.com/rust-analyzer/rust-analyzer/issues/9056

Our previous implementation was incorrect (presumably because of the misleading comment in libstd [here](https://github.com/rust-lang/rust/blob/a7890c7952bdc9445eb6c63dc671fa7a1ab0260d/library/std/src/lib.rs#L339-L343)). `#[prelude_import]` does not define the prelude, it can only override the implicit prelude for the current crate.

This PR fixes that, which also makes the prelude imports in `rustc_span` work. Closes https://github.com/rust-analyzer/rust-analyzer/issues/8815.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoImplement per-edition preludes
Jonas Schievink [Tue, 1 Jun 2021 11:39:19 +0000 (13:39 +0200)]
Implement per-edition preludes

3 years agoMerge #8717
bors[bot] [Mon, 31 May 2021 21:01:52 +0000 (21:01 +0000)]
Merge #8717

8717: Update match checking algorithm r=iDawer a=iDawer

I've recently got interest in the match checking to extend the current algo to support reporting witnesses of non-exhaustiveness.
It appears the algo is outdated from rustc's implementation. I decided to rewrite it based on the latest rustc's version. It is a diff-based port to ra codebase. That means you can diff-compare these files to rustc.
I'm striving to keep minimal ra-related changes in the algo to make it easier to backport future changes from the upstream.

Based on upstream algorithm of version rust-lang/rust 1.52.0-nightly (25c15cdbe 2021-04-22)
https://github.com/rust-lang/rust/blob/25c15cdbe/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

The goal of this PR is to cover the current `missing-match-arm` diagnostic.

What is remaining to do:
- [x] Error handling. The errors that are unrelated to match checking will be handled before the check. Just like how it made in rustc.
  - [x] Lowering `hir_def::expr::Pat` to `hir_ty::diagnostics::match_check::Pat`. rustc's match checking works on top of `rustc_mir_build::thir::Pat`, which is lowered from `hir::Pat` and carries some extra semantics used by the check. All unrelated checks are done there. RA could use this to rule out running the check on unimplemented cases (`Pat::ConstBlock`, etc).
  - [x] ~~Proper~~Loose typecheck of match arm patterns (https://github.com/rust-analyzer/rust-analyzer/pull/8840, https://github.com/rust-analyzer/rust-analyzer/pull/8875).
- [x] Tests from `hir_ty::diagnostics::match_check::tests`.
- [x] Clean up `todo`s
- [x] Test run on real repos https://github.com/rust-analyzer/rust-analyzer/pull/8717#issuecomment-847120265.

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
3 years agoExpand fixme comments
Dawer [Mon, 31 May 2021 20:44:51 +0000 (01:44 +0500)]
Expand fixme comments

3 years agofix: panic on extra fields in a pattern
Dawer [Mon, 24 May 2021 12:03:36 +0000 (17:03 +0500)]
fix: panic on extra fields in a pattern

3 years agoCorrect binding pattern's type; handle invalid records.
Dawer [Sat, 22 May 2021 07:36:48 +0000 (12:36 +0500)]
Correct binding pattern's type; handle invalid records.

3 years agoTake substitutions into account.
Dawer [Wed, 19 May 2021 13:08:13 +0000 (18:08 +0500)]
Take substitutions into account.

3 years agoeprint panic context
Dawer [Wed, 19 May 2021 13:00:25 +0000 (18:00 +0500)]
eprint panic context

3 years agominor: doc comment pat_util
Dawer [Sun, 16 May 2021 13:11:45 +0000 (18:11 +0500)]
minor: doc comment pat_util

3 years agoTest match guards, reference patterns
Dawer [Wed, 12 May 2021 07:50:22 +0000 (12:50 +0500)]
Test match guards, reference patterns

3 years agoBox field detection; test #[non-exhaustive] attribute
Dawer [Wed, 12 May 2021 06:04:56 +0000 (11:04 +0500)]
Box field detection; test #[non-exhaustive] attribute

3 years agoBetter tests: check if match checking bails out.
Dawer [Tue, 11 May 2021 13:24:39 +0000 (18:24 +0500)]
Better tests: check if match checking bails out.

3 years agoReplace the old match checking algorithm
Dawer [Tue, 11 May 2021 12:18:16 +0000 (17:18 +0500)]
Replace the old match checking algorithm

3 years agoInclude old tests
Dawer [Tue, 11 May 2021 11:15:35 +0000 (16:15 +0500)]
Include old tests

3 years agoDon't panic on a pattern of unresolved ADT variant.
Dawer [Mon, 10 May 2021 17:40:35 +0000 (22:40 +0500)]
Don't panic on a pattern of unresolved ADT variant.

3 years agoClean up, more docs.
Dawer [Mon, 10 May 2021 11:55:00 +0000 (16:55 +0500)]
Clean up, more docs.

3 years agoCheck pattern types.
Dawer [Mon, 10 May 2021 08:22:13 +0000 (13:22 +0500)]
Check pattern types.

3 years agoExpand binding patterns.
Dawer [Sat, 8 May 2021 18:06:17 +0000 (23:06 +0500)]
Expand binding patterns.

3 years agoFix visibility warnings
Dawer [Fri, 7 May 2021 07:20:23 +0000 (12:20 +0500)]
Fix visibility warnings

3 years agoLower binding pattern
Dawer [Fri, 7 May 2021 05:38:51 +0000 (10:38 +0500)]
Lower binding pattern

3 years agoLower bool literals
Dawer [Thu, 6 May 2021 14:39:27 +0000 (19:39 +0500)]
Lower bool literals

3 years agoTreat ctor of unhandled type as non-exhaustive.
Dawer [Thu, 6 May 2021 12:26:05 +0000 (17:26 +0500)]
Treat ctor of unhandled type as non-exhaustive.