Commit Graph

9404 Commits

Author SHA1 Message Date
bors[bot]
4a2f60cb7b
Merge #6964
6964: Add full pattern completions for Struct and Variant patterns r=matklad a=Veykril


Just gonna call it full pattern completion as pattern completion is already implemented in a sense by showing idents in pattern position. What this does is basically complete struct and variant patterns where applicable(function params, let statements and refutable pattern locations).

This does not replace just completing the corresponding idents of the structs and variants, instead two completions are shown for these, a completion for the ident itself and a completion for the pattern(if the pattern make sense to be used that is). I figured in some cases one would rather type out the pattern manually if it has a lot of fields but you only care about one since this completion would cause one more work in the end since you would have to delete all the extra matched fields again.

These completions are tagged as `CompletionKind::Snippet`, not sure if that is the right one here.
<details>
  <summary>some gifs</summary>

![dx2lxgzhj3](https://user-images.githubusercontent.com/3757771/102719967-6987ef80-42f1-11eb-8ae0-8aff53777860.gif)
![EP2E7sJLkB](https://user-images.githubusercontent.com/3757771/102785777-c7264580-439e-11eb-8a64-f142e19fb65b.gif)
![JMNHHWknr9](https://user-images.githubusercontent.com/3757771/102785796-d1e0da80-439e-11eb-934b-218ada31b51c.gif)
</details>

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-22 18:03:51 +00:00
Lukas Wirth
83121efcd5 Reduce some more code duplication 2020-12-22 19:00:38 +01:00
bors[bot]
b28322eed6
Merge #7005
7005: Improve extract_module_to_file assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-22 16:15:20 +00:00
Aleksey Kladov
41bc32368e Improve extract_module_to_file assist
* simplify code
* correctly handle crate roots and mod.rs files (nested inline modules
  are still mishandled)
* make sure that new text contains a trailing newline
2020-12-22 19:13:53 +03:00
bors[bot]
013739c73d
Merge #6993
6993: Clean up descriptions for settings r=matklad a=rherrmann

Use two consecutive newlines (`\n\n`) to actually continue text on a
new line.

Use proper markup to reference related settings.

Consistently format references to files, command line arguments, etc.
as `code`. Format mentions of UI elements in _italic_.

Fix typos, add missing full-stops, add missing default values.

Co-authored-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2020-12-22 15:07:36 +00:00
Jonas Schievink
26f604b907 Store invocation site for eager macros 2020-12-22 15:02:03 +01:00
Rüdiger Herrmann
9f070531a6 Clean up descriptions for settings
Use two consecutive newlines (`\n\n`) to actually continue text on a
new line.

Use proper markup to reference related settings.

Consistently format references to files, editor commands, command line
arguments, files, etc. as `code`.

Fix typos, add missing full-stops, add missing default values.
2020-12-22 14:51:17 +01:00
bors[bot]
b98ee075ee
Merge #6746
6746: Feature/add assist extract module to file r=matklad a=sasurau4

Fix #6522 

## Screenshot

<img src="https://user-images.githubusercontent.com/13580199/102748269-33a44300-43a5-11eb-9e37-f5fcb8e62f73.gif" width=600 />


## TODO

- [x] Remove all TODO comment
- [x] Pass the doc test



Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2020-12-22 10:04:24 +00:00
Rüdiger Herrmann
658ba9e29c Delete related whitespace when removing unused param
Include adjacent whitespace in the text edits to remove the
parameter declaration and its occurences in calling code.

https://github.com/rust-analyzer/rust-analyzer/issues/6663
2020-12-21 18:42:42 +01:00
bors[bot]
c8a73fe655
Merge #6982
6982: Remove parentheses when inverting `!(cond)` r=matklad a=Jesse-Bakker

Followup to #6894

When inverting a composite condition twice, the parentheses were left. This also removes those unnecessary parentheses when applying the invert-if assist.

Co-authored-by: Jesse Bakker <github@jessebakker.com>
2020-12-21 16:57:49 +00:00
Jesse Bakker
2e7abf8384 Remove parentheses when inverting !(cond) 2020-12-21 17:37:38 +01:00
Lukas Wirth
a4f34e2c8c Acquire original text range when searching for references 2020-12-21 17:28:47 +01:00
Jonas Schievink
ee8d7a7123 Filter out empty rustc spans 2020-12-21 15:38:27 +01:00
Lukas Wirth
2cd2947bf8 Insert snippet positions after fields names in record patterns 2020-12-21 15:10:27 +01:00
bors[bot]
9bb9fbab3a
Merge #6965
6965: Properly attach attributes to Param instead of parent ParamList r=matklad a=Veykril

Fixes #2783, fixes #2781

The problem with `let _a = [0,#[cfg(feature = "L")]0];` has already been fixed some time ago it seems:
<details>
  <summary>Syntax Tree for the const item</summary>

```
  LET_STMT@200..236
    LET_KW@200..203 "let"
    WHITESPACE@203..204 " "
    IDENT_PAT@204..206
      NAME@204..206
        IDENT@204..206 "_a"
    WHITESPACE@206..207 " "
    EQ@207..208 "="
    WHITESPACE@208..209 " "
    ARRAY_EXPR@209..235
      L_BRACK@209..210 "["
      LITERAL@210..211
        INT_NUMBER@210..211 "0"
      COMMA@211..212 ","
      LITERAL@212..234
        ATTR@212..233
          POUND@212..213 "#"
          L_BRACK@213..214 "["
          PATH@214..217
            PATH_SEGMENT@214..217
              NAME_REF@214..217
                IDENT@214..217 "cfg"
          TOKEN_TREE@217..232
            L_PAREN@217..218 "("
            IDENT@218..225 "feature"
            WHITESPACE@225..226 " "
            EQ@226..227 "="
            WHITESPACE@227..228 " "
            STRING@228..231 "\"L\""
            R_PAREN@231..232 ")"
          R_BRACK@232..233 "]"
        INT_NUMBER@233..234 "0"
      R_BRACK@234..235 "]"
    SEMICOLON@235..236 ";"
```
</details>

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-21 08:54:31 +00:00
bors[bot]
fa75e11eb6
Merge #6967
6967: Correctly parse legacy trait objects with leading ForType r=matklad a=Veykril

Fixes #1422

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-21 08:46:42 +00:00
Daiki Ihara
66fd262962 Fix assist test logic 2020-12-21 15:55:40 +09:00
Daiki Ihara
2b4a7848a8 Update test diagnostics in ide 2020-12-21 15:55:40 +09:00
Daiki Ihara
7a2eebde22 Add initial_contents field for CreateFile 2020-12-21 15:55:40 +09:00
Daiki Ihara
414576fb30 Add extract_module_to_file assist 2020-12-21 15:55:40 +09:00
Daiki Ihara
c8f5792a36 Add handling file_system_edit in test assists 2020-12-21 15:52:02 +09:00
Lukas Wirth
3ea4d43850 Properly parse legacy trait objects with leading ForType 2020-12-20 21:53:55 +01:00
Lukas Wirth
64caa027b8 Parse attributes in tuple expressions 2020-12-20 21:01:36 +01:00
Lukas Wirth
4be9ed675e Properly attach attributes to Param instead of parent ParamList 2020-12-20 20:30:18 +01:00
Lukas Wirth
33ecad4407 Create non-exhaustive patterns for non_exhaustive attributed items 2020-12-20 20:13:06 +01:00
Lukas Wirth
a5874a38cb Reduce code duplication in pattern completion 2020-12-20 19:20:55 +01:00
Lukas Wirth
2f6a24950a Emit snippets for struct pattern completion if enabled 2020-12-20 19:16:28 +01:00
Lukas Wirth
b184bfad7a Add completions for patterns 2020-12-20 18:19:23 +01:00
bors[bot]
8eea4c9d3b
Merge #6959
6959: Use pattern_single instead of pattern in mbe pat r=jonas-schievink a=edwin0cheng

Fix #6882

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-20 14:08:53 +00:00
bors[bot]
eefbae7ed4
Merge #6921
6921: Higher-ranked trait bounds for where clauses r=flodiebold a=Veykril

There is a slight problem with this which is also noted in a FIXME now but `LifetimeParameters` of these ForLifetime where clauses allocate the lifetimes in the corresponding arena as if they were lifetimes of the item itself and not just the clause they belong to. I wasn't entirely sure what I could do about this but given nothing really uses lifetimes like that currently I figured it might be fine? Open to suggestions for that problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-20 11:47:01 +00:00
Lukas Wirth
15a52f69d9 Show enum variant completions for ref scrutinee 2020-12-20 12:32:53 +01:00
Lukas Wirth
943e4faceb Show enum variant on Self qualified paths 2020-12-20 12:31:59 +01:00
Edwin Cheng
f942d10e80 Use pattern_single instead of pattern in mbe pat 2020-12-20 17:13:40 +08:00
Aleksey Kladov
f6ed16674c Align code_model name with ungrammar 2020-12-20 10:05:24 +03:00
bors[bot]
87886e8986
Merge #6929
6929: Handle $_ in mbe r=edwin0cheng a=lnicola

Fixes #6926

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-12-20 06:33:19 +00:00
Laurențiu Nicola
75a26f64ff mbe: treat _ as ident 2020-12-20 08:06:17 +02:00
bors[bot]
feff4f3a04
Merge #6953
6953: Add test_rename_bind_pat r=bjorn3 a=bjorn3

Fixes #2976

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-19 18:56:50 +00:00
bjorn3
9fe85e1fdf Add test_rename_bind_pat 2020-12-19 19:55:44 +01:00
bors[bot]
052e7227b6
Merge #6946
6946: Better fuzzy heuristics r=matklad a=SomeoneToIgnore

Continuation of the https://github.com/rust-analyzer/rust-analyzer/pull/6922, mainly created for a test.

Turns out our current completions tests were sorting the completions by label, I had to remove that to test the order properly and update this order in a bunch of tests (ergo the changes)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-12-19 18:43:20 +00:00
Kirill Bulatov
b45ec84739 Fewer allocations 2020-12-19 20:42:16 +02:00
Aleksey Kladov
9f6d76da77 Make sure that HighlightModifier::ALL is synchronized with enum 2020-12-19 18:47:36 +03:00
bors[bot]
df3652b663
Merge #6948
6948: Add API for mapping `Attr` back to its syntax node r=jonas-schievink a=jonas-schievink

This will be useful for emitting diagnostics pertaining to a specific attribute

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-19 14:25:33 +00:00
Aleksey Kladov
113688cef0 Clarify the meaning of no-op highlight tag 2020-12-19 17:16:05 +03:00
Jonas Schievink
218e88ab55 Add API for mapping Attr back to its syntax node 2020-12-19 15:15:02 +01:00
Aleksey Kladov
a13947abe6 Use more Rustic highlighting specifiers
*Method* works for OO languages, but in rust we can also have
associated constants & types, so let's move this to a modifier.
2020-12-19 17:10:47 +03:00
Kirill Bulatov
0415dcd832 Tidy up 2020-12-19 14:13:27 +02:00
Kirill Bulatov
8c292e3cc5 Keep the original completion order in tests 2020-12-19 13:18:40 +02:00
Kirill Bulatov
5fa078f26f Add a slightly better fuzzy search heuristics 2020-12-19 12:54:17 +02:00
Jonas Schievink
a2062d1892 Make RawAttrs crate-private
There should be no need to use this from outside
2020-12-19 02:44:22 +01:00
Jonas Schievink
81ccf37d3b Remove Attrs::merge
Only the `RawAttrs` version of this is in use
2020-12-19 02:43:00 +01:00
Jonas Schievink
0ac75f8982 Remove resolved FIXME 2020-12-19 02:32:31 +01:00
Jonas Schievink
aa00d1acd6 fixture -> ra_fixture 2020-12-19 01:12:41 +01:00
Jonas Schievink
d5edd0e928 Test paths to derive macros 2020-12-19 01:11:33 +01:00
Jonas Schievink
ea5cc8d07a More accurate #[derive] parsing
This now allows full paths to the derive macro
2020-12-19 01:10:56 +01:00
bors[bot]
c7b7c37ea5
Merge #6937
6937: Deduplicate highlight tags and symbol kinds r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-18 20:05:20 +00:00
Aleksey Kladov
c45221907a Deduplicate highlight tags and symbol kinds
Curiously, LSP uses different enums for those, and unsurprising and
annoyingly, there are things which exist in one but not in the other.

Let's not repeat the mistake and unify the two things
2020-12-18 23:04:26 +03:00
bors[bot]
38b108c20e
Merge #6935
6935: Don't look at attributes when lowering to ItemTree r=jonas-schievink a=jonas-schievink

Resolves 2 `cfg_attr` FIXMEs

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-18 19:38:07 +00:00
Jonas Schievink
77972e2001 Don't look at attributes when lowering to ItemTree
Resolves 2 `cfg_attr` FIXMEs
2020-12-18 20:37:26 +01:00
bors[bot]
c073e4f6ba
Merge #6934
6934: Implement `cfg_attr` handling r=jonas-schievink a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-18 19:27:18 +00:00
Jonas Schievink
aab9cc9cfb Hit a mark 2020-12-18 20:25:41 +01:00
Jonas Schievink
382ee2fa03 Add test 2020-12-18 20:01:02 +01:00
Jonas Schievink
d42d1d33f0 Fix parsing of active cfg_attr 2020-12-18 20:00:59 +01:00
Aleksey Kladov
ade2f5cd12 Reduce test verbosity 2020-12-18 21:26:47 +03:00
Aleksey Kladov
0e3581e823 NavTarget doesn't assume that it points to a symbol 2020-12-18 21:15:48 +03:00
Jonas Schievink
08de1b4fa5 Implement RawAttr::filter 2020-12-18 18:58:42 +01:00
Aleksey Kladov
cd4a7bf36e Minor, cleanup API 2020-12-18 19:50:00 +03:00
Aleksey Kladov
55ba353b39 Don't expose SyntaxKind from IDE API
SyntaxKind is somewhat of an internal type, but IDE is using it to
basically specify an icon. Let's have a dedicated entity for this
instead.
2020-12-18 19:28:48 +03:00
Aleksey Kladov
2465fa02b7 Cleaup imports
ide should re-export everything it needs.
2020-12-18 18:02:11 +03:00
Jesse Bakker
700034bd5a Do not merge imports with different attributes 2020-12-18 15:29:37 +01:00
bors[bot]
f4929fa9cc
Merge #6901
6901: Temp fixes panic caused by no ast for proc-macro r=maklad a=edwin0cheng

There are some panic when hover/goto definition for proc-macro. It is because in current design, we don't have `ast-node` for proc-macro and then it trigger [this](479d1f7eec/crates/hir/src/has_source.rs (L116)) line to panic.

This PR is a temp fix for all of these similar to bd4c352831/crates/completion/src/render/macro_.rs (L42)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-18 02:30:51 +00:00
Edwin Cheng
60a3785ac2 Temp fixes panic caused by no ast for proc-macro 2020-12-18 10:26:17 +08:00
Jonas Schievink
4f07d8dd58 Refactor attributes API to allow handling cfg_attr 2020-12-18 02:24:14 +01:00
Kirill Bulatov
9d2cbf05e3 Show first fuzzy completions fully containing the input 2020-12-17 23:10:18 +02:00
Lukas Wirth
fa65d6ba85 Higher-ranked trait bounds for where clauses 2020-12-17 22:01:42 +01:00
bors[bot]
b55cb897e5
Merge #6912
6912: Default to host platform for cargo metadata r=jonhoo a=jonhoo

This modifies the logic for calling cargo metadata so that it will use
the host platform if no explicit target platform is given. This is
needed since cargo metadata defaults to outputting information for _all_
targets.

Fixes #6908.

Co-authored-by: Jon Gjengset <jongje@amazon.com>
Co-authored-by: Jon Gjengset <jon@thesquareplanet.com>
2020-12-17 18:32:13 +00:00
Jon Gjengset
faed47b3d3 Fun times with rustfmt 2020-12-17 10:24:58 -08:00
Jon Gjengset
71478e067b
Update crates/project_model/src/cargo_workspace.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-17 13:18:23 -05:00
bors[bot]
b0e5d1efdb
Merge #6920
6920: Minor API cleanup r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-17 17:18:50 +00:00
Aleksey Kladov
30216880c4 Minor API cleanup 2020-12-17 20:14:13 +03:00
Aleksey Kladov
c888f1de6f Rewrite doctest runnables
Handle more cases in a generic way without copy-pasting code.
2020-12-17 20:11:40 +03:00
Aleksey Kladov
0da1532ef2 Minor code style 2020-12-17 20:10:39 +03:00
kjeremy
d828bd794b LSP 3.16 - Released 2020-12-17 11:33:35 -05:00
Jonas Schievink
9231821c03 Make Attrs::from_attrs_owner private 2020-12-17 15:45:26 +01:00
Jonas Schievink
eaeabbb815 Add AttrDefId::krate
Access to the containing crate will be needed to handle `cfg_attr`
2020-12-17 14:29:29 +01:00
Lukas Wirth
c8c58d81ec Remove obsolete FIXME 2020-12-17 13:40:11 +01:00
Aleksey Kladov
2ae31e34b1 Rename ImplDef -> Impl
We used to have `Def` suffix for all symbols, but we moved off from
that. `FunctionDef` isn't better than `Function`. Looks like we've
forgot to change `Impl` though!
2020-12-17 14:36:15 +03:00
bors[bot]
d641bccb0f
Merge #6907
6907: Lifetime reference search  r=matklad a=Veykril

PR #6787 but rewritten to make use of the HIR now. This only applies to Lifetimes, not labels. Also Higher-Ranked Trait Bounds aren't supported yet, but I feel like this PR is big enough as is which is why I left them out after noticing I forgot about them.

Supporting renaming required slight changes in the renaming module as lifetime names aren't allowed for anything but lifetimes(and labels) and vice versa for normal names.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-17 11:00:39 +00:00
Jon Gjengset
9802c0ccd0 Default to host platform for cargo metadata
This modifies the logic for calling cargo metadata so that it will use
the host platform if no explicit target platform is given. This is
needed since cargo metadata defaults to outputting information for _all_
targets.

Fixes #6908.
2020-12-16 17:38:37 -08:00
Jonas Schievink
6615fda695 decl_check: don't pass db around so often 2020-12-17 01:19:56 +01:00
Jonas Schievink
21b68a328c Remove module_lang_items
It isn't used anywhere except in `crate_lang_items`. Remove it to
slightly reduce memory usage and simplify the code.
2020-12-17 00:26:01 +01:00
Jonas Schievink
28b5334580 Avoid querying attributes in item tree lowering
ItemTree is per-file, so there is no unique crate associated with it.
This means that it cannot know the active CfgOptions and thus couldn't
handle `cfg_attr`.

Prepare it for `cfg_attr`s by avoiding accessing attributes.
2020-12-16 23:42:03 +01:00
Lukas Wirth
55faa2daa3 Lifetime reference search 2020-12-16 22:21:01 +01:00
bors[bot]
067067a6c1
Merge #6896
6896: Node-ify lifetimes r=jonas-schievink a=Veykril

Let's see if this passes the tests 🤞 

Depends on https://github.com/rust-analyzer/ungrammar/pull/15

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-16 17:08:03 +00:00
bors[bot]
63bbdb31e5
Merge #6897
6897: Basic support for macros 2.0 r=jonas-schievink a=jonas-schievink

This adds support for (built-in-only) macros 2.0, and removes some hacks used for builtin derives, which are declared via macros 2.0 in libcore.

First steps for https://github.com/rust-analyzer/rust-analyzer/issues/2248.

Blocked on https://github.com/rust-analyzer/ungrammar/pull/16.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-12-16 16:52:46 +00:00
Lukas Wirth
dd496223f5 Node-ify lifetimes 2020-12-16 14:16:09 +01:00
bors[bot]
c1c36acb02
Merge #6861
6861: generate default implementation for an enum from an enum variant #6860 r=matklad a=bnjjj

close #6860

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-12-16 08:36:05 +00:00
bors[bot]
ece626fe81
Merge #6894
6894: Parenthesize composite if condition before inverting in invert-if assist r=matklad a=Jesse-Bakker

Fixes #6867

Co-authored-by: Jesse Bakker <github@jessebakker.com>
2020-12-16 08:20:11 +00:00
Benjamin Coenen
2c82a1aec7 generate default implementation for an enum from an enum variant #6860
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-12-15 21:35:41 +01:00
Jonas Schievink
b238ddd21a Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
2020-12-15 20:33:05 +01:00
Jonas Schievink
c31c3246a8 Basic support for decl macros 2.0 2020-12-15 18:43:34 +01:00
bors[bot]
eb9ba457b0
Merge #6879
6879: Change HasChildSource::ChildId assoc item to generic param r=matklad a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-15 17:22:03 +00:00
Lukas Wirth
2c67a4abe4 Change HasChildSource::ChildId assoc item to generic param 2020-12-15 18:21:01 +01:00
Jesse Bakker
0f42a71806 Parenthesize composite if condition before inverting in invert-if assist 2020-12-15 16:25:57 +01:00
Jonas Schievink
479babf874 Reject visibilities on macro_rules! 2020-12-15 15:37:49 +01:00
Jonas Schievink
c1cb595382 Move to upstream macro_rules! model 2020-12-15 15:37:37 +01:00
bors[bot]
39aae835fd
Merge #6886
6886: Expand statements for macros in lowering r=matklad a=edwin0cheng

Fixes #6811

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-15 12:41:07 +00:00
bors[bot]
435d46b183
Merge #6888
6888: Use standard test style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-15 12:34:37 +00:00
Edwin Cheng
1f4da7098c Remove obsolete comment 2020-12-15 17:25:59 +08:00
bors[bot]
a9d19200f2
Merge #6889
6889: Resolve `macro-error` diagnostics on asm & llvm_asm r=matklad a=lf-

We currently stub these out as returning unit.

This fixes spurious RA `macro-error` diagnostics introduced somewhere around 0.2.400 in the following:
```rust
unsafe { asm!(""); llvm_asm!(""); }
```

I'd ideally like to write a unit test for this, but I'm not familiar with where the tests for `hir_expand` are.

Thanks to @edwin0cheng for help on resolving this issue.

Co-authored-by: lf- <lf-@users.noreply.github.com>
2020-12-15 09:15:41 +00:00
lf-
090a59970d Resolve macro-error diagnostics on asm & llvm_asm
We currently stub these out as returning unit.

This fixes spurious RA diagnostics in the following:
```rust
unsafe { asm!(""); llvm_asm!(""); }
```
2020-12-15 01:06:53 -08:00
Aleksey Kladov
c582e52a1b Use standard test style 2020-12-15 11:53:16 +03:00
Benjamin Coenen
490475ee19 generate default implementation for an enum from an enum variant #6860
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-12-15 09:46:02 +01:00
bors[bot]
65e31a1b5b
Merge #6875
6875: Add find usages for enum constructors r=matklad a=sasurau4

Fix #2549 for enum

Co-authored-by: Daiki Ihara <sasurau4@gmail.com>
2020-12-15 08:38:08 +00:00
Edwin Cheng
9da1eee436 Add regression test 2020-12-15 15:24:35 +08:00
Edwin Cheng
a68ff269a9 Expand statements for mbe in lowering 2020-12-15 14:39:15 +08:00
Daiki Ihara
36a9daac70 Add find usages for enum constructors 2020-12-15 00:39:42 +09:00
bors[bot]
34f7b5383a
Merge #6874
6874: Implement `module_path!()` r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/6747

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-14 15:39:31 +00:00
Jonas Schievink
81820fe52c Implement module_path!() 2020-12-14 16:38:53 +01:00
bors[bot]
817fbebbb5
Merge #6862
6862: Add LifetimeParam resolving to Semantics r=matklad a=Veykril

This is stuff required for the lifetime references/definitions PR. I pulled this out to make it easier to review as well as because there is one thing that still has to be addressed which can be found in the review comments.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-14 15:15:52 +00:00
bors[bot]
134c7563be
Merge #6817
6817: Replace goblin crate with object r=matklad a=lnicola

Continuation of #4385.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-12-14 15:04:47 +00:00
Lukas Wirth
c6172f3f6d Add LifetimeParam resolving to Semantics 2020-12-14 16:04:28 +01:00
Benjamin Coenen
08090d81b1 generate default implementation for an enum from an enum variant #6860
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-12-14 09:44:24 +01:00
Florian Diebold
4788aaa5f0 Add test for #6852 2020-12-13 14:53:04 +01:00
Laurențiu Nicola
dc519b88af Replace goblin crate with object 2020-12-13 14:08:59 +02:00
Florian Diebold
7d7949b315 Change recommendation when source can't be loaded from sysroot
Since we just tried running `rustup component add`, it doesn't make sense to me
to recommend trying that again. If we're reaching this case, it's probably more
likely that rustc was installed via package manager, in which case the source
should be installed the same way (e.g. if you install the rust-src package on
Ubuntu it will install a symlink in the right place to make our sysroot
detection work).
2020-12-13 13:04:50 +01:00
bors[bot]
ca3a54f0a4
Merge #6852
6852: Ignore lifetime params in substitutions r=matklad a=Veykril

[`hir_ty::utils::Generics`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/utils.rs#L153) currently only assumes type parameters but not lifetime parameters and therefor creates incorrect index and length calculations, this PR just makes the use sites ignore LifetimeGenerics for now.

This fixes the panic at least locally for me for `analysis-stats`. Funnily enough this panic prevented me from using reference search for the `args` field to fix this problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-13 11:34:43 +00:00
Lukas Wirth
ae8a802085 Ignore lifetime params in substitutions 2020-12-13 11:34:44 +01:00
bors[bot]
a15d19619e
Merge #6845
6845: Don't HirDisplay unknown types when displaying for source r=Veykril a=Veykril

Was wondering why the add missing impl assist didn't do anything here:
![Code_JCA1Qo0V9P](https://user-images.githubusercontent.com/3757771/101990300-7af44a80-3ca6-11eb-8431-e5eb4de4e78c.png)
Turns out me forgetting to set the Index::Idx type in the trait causes RA to panic due to it trying to to create an unparsable type in the `make` module.
Now we get this instead which imo is definitely better to have.
![Code_MUFPJUCULY](https://user-images.githubusercontent.com/3757771/101990347-c9094e00-3ca6-11eb-9c6a-146bddf64b7c.png)



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 18:06:36 +00:00
Lukas Wirth
69b78edb5e Don't HirDisplay unknown types when displaying for source 2020-12-12 19:05:00 +01:00
Jeremy Kolb
26a1675764 Remove some redundant allocations 2020-12-12 12:27:09 -05:00
bors[bot]
479d1f7eec
Merge #6818
6818: Add Lifetimes to the HIR r=matklad a=Veykril

This doesn't handle resolve yet as I don't know yet how that will be used. I'll get to that once I start moving the lifetime reference PR to the hir.

This also adds a new `hir` name type for lifetimes and labels, `hir::LifetimeName`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 14:35:38 +00:00
ivan770
f7f4f366ac
Added remove this semicolon test 2020-12-12 13:50:11 +02:00
bors[bot]
70db57cc59
Merge #6839
6839: Infer labeled blocks r=flodiebold a=Veykril

The test should cover all the interesting cases I believe(main part of it is copied from the loop label break test above it).

The test is indented to stay consistent with the rest of the tests in the file, I can dedent all the tests in the file in a follow up PR if desired.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 10:18:16 +00:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Lukas Wirth
378ec2841b Infer labeled blocks 2020-12-12 00:06:48 +01:00
bors[bot]
4998807039
Merge #6813
6813: negative sign matching in mbe matching for literal r=edwin0cheng a=edwin0cheng

Fix #6292

r @jonas-schievink 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-12-11 22:17:40 +00:00
Edwin Cheng
ae29fb0211 Add missing arg for eat_char 2020-12-12 06:14:11 +08:00
Lukas Wirth
8ed8e4f25a Use Attrs::docs in NavigationTarget instead of DocCommentsOwner 2020-12-11 21:19:58 +01:00
bors[bot]
91bf15a2f5
Merge #6834
6834: Use Attrs::docs in runnables instead of DocCommentsOwner r=kjeremy a=Veykril

I figured that we should probably move as much of the doc usage to the HIR as possible hence this PR. If we should keep this AST-based feel free to close.

This change does have the nice(but not really useful as I doubt anyones gonna write doc tests like these) side effect that these two doc string snippets allow being run now.
![image](https://user-images.githubusercontent.com/3757771/101945607-bf241400-3bee-11eb-96ce-ccae80028b1f.png)
![image](https://user-images.githubusercontent.com/3757771/101946375-2e9a0380-3bef-11eb-9950-e35168fdd048.png)


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-11 19:57:08 +00:00
Lukas Wirth
ac19a71459 Use Attrs::docs in runnables instead of DocCommentsOwner 2020-12-11 20:11:03 +01:00
Jonas Schievink
00c34b048e Add upstream commit to builtin_attr.rs 2020-12-11 19:12:06 +01:00
bors[bot]
3674e494ca
Merge #6819
6819: Add builtin attributes for use in nameres r=jonas-schievink a=jonas-schievink

These are not yet used, but have to go through nameres later in order to support procedural macro attributes

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-11 18:03:09 +00:00
Jonas Schievink
2fdde98b5c Move print_memory_usage to cli.rs 2020-12-11 18:24:27 +01:00
Jonas Schievink
c007ac3830 Avoid panic when collecting memory metrics 2020-12-11 18:18:27 +01:00
Lukas Wirth
37c5b82938 Don't highlight parent nodes of comments on hover 2020-12-11 16:00:52 +01:00
Aleksey Kladov
4015ff0e0b Improve code structure
Make sure that there's only one entry point, analyze, remove awkard
analyzer2 name
2020-12-11 17:06:21 +03:00
Jonas Schievink
253678ead2 Add builtin attributes for use in nameres 2020-12-11 14:04:33 +01:00
Aleksey Kladov
e179ed6f53 Use natural trait ordering in derive completion
derive(Clone, Copy) reads better than derive(Copy, Clone).

However, we preserve the reverse ordering in the lookup text for
sorting purposes. That way, it's convenient to type just `Ord` to
derive everything.
2020-12-11 15:45:53 +03:00
Edwin Cheng
175229ab3d negative sign matching in mbe matching for literal 2020-12-11 17:59:04 +08:00
bors[bot]
41321d9678
Merge #6807
6807: Replicate Cargo environment variables r=jonas-schievink a=jonas-schievink

These might be relied on by procedural macros, and can also be accessed via `env!`.

Required for fixing https://github.com/rust-analyzer/rust-analyzer/issues/6696. We do not yet propagate these to any proc macros though.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-10 18:30:11 +00:00
Jonas Schievink
4d4b91117a Use itertools 2020-12-10 19:29:11 +01:00
bors[bot]
814e31957e
Merge #6804
6804: Bump the macro token limit r=jonas-schievink a=jonas-schievink

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/6504

Not entirely sure what the previous limit was based on, but it looks like it does get hit in practice.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-10 18:14:17 +00:00
Jonas Schievink
41d73d1312 Replicate Cargo environment variables 2020-12-10 18:51:39 +01:00
bors[bot]
0baff25d99
Merge #6805
6805: Fix accidently quadratic syntax rewriter r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-10 17:08:59 +00:00
Aleksey Kladov
3d5be5ba5b Fix accidently quadratic syntax rewriter
Switching from SyntaxNode to GreenNode is a costly operation (b/c
dereferencing a synax ptr in `with_green` is linear), so we should
avoid that.
2020-12-10 20:07:37 +03:00
Jonas Schievink
829d9d36eb Use decimal notation 2020-12-10 18:03:37 +01:00
Jonas Schievink
19508b474f Double the macro token limit 2020-12-10 17:51:39 +01:00
Jonas Schievink
614e5a2272 Improve macro limit error and move to const 2020-12-10 17:50:56 +01:00
bors[bot]
44978acf51
Merge #6769
6769: Add native "remove this semicolon" diagnostics r=matklad a=ivan770

Closes #6739 
![demo2](https://user-images.githubusercontent.com/14003886/101530533-b76c3180-399a-11eb-9d18-5c8457721655.gif)


Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2020-12-10 16:18:49 +00:00
ivan770
bbb0bc7b04
Cast to ExprStmt, style fixes 2020-12-10 18:10:39 +02:00
Aleksey Kladov
78de7f0d4a Remove debug print 2020-12-10 18:30:49 +03:00
bors[bot]
a6c8098113
Merge #6798
6798: Ignore extern items in incorrect-case check r=jonas-schievink a=jonas-schievink

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

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-10 15:08:30 +00:00
Aleksey Kladov
076945e47c Minor, more orthogonal code
It's better to accept things as arguments rather than store them.
2020-12-10 18:01:02 +03:00
Jonas Schievink
05d4a5a150 Use mark/hit 2020-12-10 15:56:04 +01:00
Jonas Schievink
d338513e95 Remove item tree tests
They were useful during initial development of the item tree, but
now just cause churn
2020-12-10 15:53:48 +01:00
Aleksey Kladov
17f236c2b0 Normalize spelling to American English 2020-12-10 17:51:56 +03:00
Jonas Schievink
d82292e1ce Ignore extern items in incorrect-case check 2020-12-10 15:45:01 +01:00
Jonas Schievink
f57ce36988 Fix FileId computation in IncorrectCase fix 2020-12-10 14:16:34 +01:00
Jonas Schievink
948832d10b format_args: handle key-value arguments 2020-12-10 13:46:47 +01:00
kjeremy
78dd2ba196 Send a CodeLensRefresh when we reload 2020-12-09 14:36:47 -05:00
Jonas Schievink
dedd888570 Implement HirDisplay for FnSig
This could be useful for diagnostics, but isn't used right now
2020-12-09 18:06:56 +01:00
bors[bot]
243ba330dd
Merge #6785
6785: Fix "no value set for FileTextQuery(FileId(..))" r=jonas-schievink a=jonas-schievink

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

Let's hope I got it right this time, but I feel like I slowly begin to understand the main loop logic.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-09 16:32:03 +00:00
Jonas Schievink
6857989f6f Fix "no value set for FileTextQuery(FileId(..))" 2020-12-09 17:30:46 +01:00
Aleksey Kladov
6e24321e45 Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;`
in a lossless cross-platform & network-transparent way.
2020-12-09 19:07:05 +03:00
Aleksey Kladov
5e3891c255 . 2020-12-09 18:42:07 +03:00
Jonas Schievink
d477c09c8a Avoid nesting Subtrees when parsing TokenStream 2020-12-09 14:58:46 +01:00
bors[bot]
ef989880ff
Merge #6771
6771: Properly attach inner attributes in Attrs::new r=matklad a=Veykril

Properly attach inner and outer attributes to the things they actually belong to in the HIR. ~~I can add some tests for this if wanted once I know where to put them/how to test for this.~~ Put some tests into `hover.rs`.
 
So the following snippet
```rust
mod foo {
	//! Hello
}
```
now shows `Hello` on hover 🎉

Fixes #2148


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 13:16:39 +00:00
bors[bot]
7bda4c722b
Merge #6776
6776: Include config into the manual r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-09 13:07:33 +00:00
Aleksey Kladov
0890512e1c Include config into the manual 2020-12-09 15:31:10 +03:00
bors[bot]
8fbaa8e495
Merge #6775
6775: Fix MissingFields DiagnosticFix trigger range r=lnicola a=Veykril

Fixes #5950

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 12:12:43 +00:00
Lukas Wirth
1d54c49271 Fix MissingFields DiagnosticFix trigger range 2020-12-09 12:45:39 +01:00
bors[bot]
cd83ded8ee
Merge #6774
6774: Increment recursion count in Expander only on success r=lnicola a=Veykril

Fixes #6764

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-09 11:35:18 +00:00
Lukas Wirth
ec415618df Properly decrement recursion count in Expander 2020-12-09 12:26:33 +01:00
Lukas Wirth
da3b5e35a6 Test inner and outer doc comments in hover 2020-12-09 09:42:15 +01:00
Lukas Wirth
f8823e8cbc Properly fetch inner and outer docs on hir-level 2020-12-09 09:22:41 +01:00
ivan770
35006eba79 Apply rustfmt changes 2020-12-09 08:22:13 +00:00
ivan770
86c183716c
Apply suggestions from code review
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-09 10:17:28 +02:00
Lukas Wirth
eac77997bf Properly fetch inner and outer attributes on hir-level 2020-12-08 23:21:20 +01:00
ivan770
7738467e0a Format code 2020-12-08 19:25:21 +00:00
Jonas Schievink
bb28aef918 Fix concat! with integer literals 2020-12-08 20:06:41 +01:00
ivan770
f2950a1350
Remove unused use 2020-12-08 20:50:40 +02:00
ivan770
581567a4c8
Remove use via super 2020-12-08 20:50:13 +02:00
ivan770
cb66bb8ff9
Remove this semicolon 2020-12-08 20:47:20 +02:00
Jonas Schievink
6c4d5164d9 Better error when a proc macro panics 2020-12-08 19:43:58 +01:00
bors[bot]
b3ceee2a27
Merge #6761
6761: Make config.rs a single source of truth for configuration. r=matklad a=matklad

Configuration is editor-independent. For this reason, we pick
JSON-schema as the repr of the source of truth. We do specify it using
rust-macros and some quick&dirty hackery though.

The idea for syncing truth with package.json is to just do that
manually, but there's a test to check that they are actually synced.

I'll add something like `rust-analyzer --config-schema` in a follow-up
commit.


Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-08 18:21:28 +00:00
Jonas Schievink
da5027138d Fix logic for determining macro calls
I believe this currently goes back all the way to the initial
user-written call, but that seems better than the current broken
behavior.
2020-12-08 19:11:12 +01:00
Jonas Schievink
306c6cbaac Use original_file_range in TestDB 2020-12-08 19:03:24 +01:00
Jonas Schievink
4943ef085d Make original_range a method on InFile<&SyntaxNode> 2020-12-08 19:01:27 +01:00
Aleksey Kladov
2544abbf86 Make config.rs a single source of truth for configuration.
Configuration is editor-independent. For this reason, we pick
JSON-schema as the repr of the source of truth. We do specify it using
rust-macros and some quick&dirty hackery though.

The idea for syncing truth with package.json is to just do that
manually, but there's a test to check that they are actually synced.

There's CLI to print config's json schema:

    $ rust-analyzer --print-config-schema

We go with a CLI rather than LSP request/response to make it easier to
incorporate the thing into extension's static config. This is roughtly
how we put the thing in package.json.
2020-12-08 19:25:41 +03:00
Jonas Schievink
6c1d292569 Add test for $crate in builtin macros
Fixes #6716
2020-12-08 17:17:30 +01:00
Jonas Schievink
678c74430b Handle macros in TestDB::check_diagnostics 2020-12-08 17:16:18 +01:00
bors[bot]
e2e6b709e6
Merge #6760
6760: Open Cargo.toml opens more specific manifest r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-08 13:30:16 +00:00
Aleksey Kladov
944f30bd69 Open Cargo.toml opens more specific manifest 2020-12-08 16:28:21 +03:00
bors[bot]
2aa7f2ece5
Merge #6750
6750: Remove documentation query, move doc handling to attributes r=matklad a=Veykril

Fixes #3182

Removes the documentation query in favor of `Attrs::docs`. Attrs already handlded doc comments partially but the alloc saving check was wrong so it only worked when other attributes existed as well. Unfortunately the `new` constructor has to do an intermediate allocation now because we need to keep the order of mixed doc attributes and doc comments.

I've also partially adjusted the `hover` module to have its tests check the changes, it still has some `HasSource` trait usage due to the `ShortLabel` trait usage, as that is only implemented on the Ast parts and not the Hir, should this ideally be implemented for the Hir types as well?(would be a follow up PR of course)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-08 13:23:12 +00:00
Aleksey Kladov
ecd1c11f9e cleanup: match over unwrap 2020-12-08 16:17:46 +03:00
Lukas Wirth
3174e941db Simplify ast::Comment api surface 2020-12-08 14:15:41 +01:00
Kirill Bulatov
bf24cb3e8d Tweak the search query params for better lookup speed 2020-12-08 15:05:09 +02:00
Lukas Wirth
2facd9517f Escape string literals in Attr::from_src 2020-12-08 13:47:58 +01:00
Kirill Bulatov
cbd3717f2c Better config name 2020-12-08 14:27:18 +02:00
Kirill Bulatov
3183ff3a7b Disable the completion for no corresponding client resolve capabilities 2020-12-08 01:07:20 +02:00
Kirill Bulatov
9656ceb896 Document the feature 2020-12-07 23:41:08 +02:00
Kirill Bulatov
19cfa5802e Simplify 2020-12-07 23:41:08 +02:00
Kirill Bulatov
6badf705b3 Check lsp completions' edits for disjointness 2020-12-07 23:41:08 +02:00
Kirill Bulatov
077c1c3c1f Less panic, more tests 2020-12-07 23:41:08 +02:00
Kirill Bulatov
045d7f096f Fix the profiling label 2020-12-07 23:41:08 +02:00
Kirill Bulatov
deda74edd8 Use stateless completion resolve 2020-12-07 23:41:08 +02:00
Kirill Bulatov
93bc009a59 Remove the state 2020-12-07 23:41:08 +02:00
Kirill Bulatov
74c3bbacc9 Make completion resolve async 2020-12-07 23:41:08 +02:00
Kirill Bulatov
f6d2540df0 Simplify import edit calculation 2020-12-07 23:41:08 +02:00
Kirill Bulatov
68a747efe0 Remove redundant code 2020-12-07 23:41:08 +02:00
Kirill Bulatov
50e06ee95a Refactor the code 2020-12-07 23:41:08 +02:00
Kirill Bulatov
d9bd1f171d Add eager resolve capability 2020-12-07 23:41:08 +02:00
Kirill Bulatov
2a7be4afb0 Better support client completion resolve caps 2020-12-07 23:41:08 +02:00
Kirill Bulatov
47464e556c Properly fill client completion resolve capabilities data 2020-12-07 23:41:08 +02:00
Kirill Bulatov
9a4daffe16 Resolve import inserts better 2020-12-07 23:41:08 +02:00
Kirill Bulatov
a539267c3b Remove unnecessary leftovers 2020-12-07 23:41:08 +02:00
Kirill Bulatov
6d2d279389 Working resolve completion imports prototype 2020-12-07 23:41:08 +02:00
Kirill Bulatov
48acd7d455 Draft the new lsp handler 2020-12-07 23:41:08 +02:00
Lukas Wirth
7a338e5207 Replace Arc<[str]> with String in attr::Documentation 2020-12-07 21:55:00 +01:00
Jonas Schievink
eeeacc4727 Apply environment set by build scripts 2020-12-07 20:52:31 +01:00
bors[bot]
d6aa1ba7d4
Merge #6752
6752: Pass `--target` when loading out dirs from check r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-07 19:42:08 +00:00
Jonas Schievink
a69996933a Pass --target when loading out dirs from check 2020-12-07 20:39:29 +01:00
Lukas Wirth
b064f6da9e Keep doc attribute order 2020-12-07 20:38:28 +01:00
Lukas Wirth
efe86a42dc Remove raw pre and suffixes from string attr literals 2020-12-07 19:58:17 +01:00
Lukas Wirth
1caaa201fa Remove hir_def/docs.rs module 2020-12-07 19:58:17 +01:00
Lukas Wirth
b3652ef288 Remove documentation query 2020-12-07 19:58:17 +01:00
bors[bot]
03b886de53
Merge #6719
6719: Use items can also have doc comments r=matklad a=Veykril

Prior to this change modules show more docs than they have cause they inherit the docs from documented use items inside of them.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 18:48:35 +00:00
Jonas Schievink
881c7a680b Use the right def_crate for builtin macros 2020-12-07 19:38:13 +01:00
bors[bot]
c1824b4933
Merge #6745
6745: Some more proc macro cleanups r=jonas-schievink a=jonas-schievink

* Remove `ProcMacroClient::dummy` and just use `Option<ProcMacroClient>` instead
* Remember the type of proc macros (later allows us to reject using an incorrect macro type)
* Prepare a few internals for procedural attribute macros

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-12-07 16:21:51 +00:00
Jonas Schievink
577d5f1c33 Remove resolved FIXME 2020-12-07 17:17:31 +01:00
Jonas Schievink
2b2318e695 Remove dummy ProcMacroClient in favor of Option 2020-12-07 17:16:50 +01:00
Jonas Schievink
fb21a215be Retain types of proc macros and allow attr. macros 2020-12-07 17:06:14 +01:00
bors[bot]
9a88332452
Merge #6743
6743: Don't insert blank lines between doc attributes r=Veykril a=Veykril

Fixes #6742.
Doc attributes should be concatenated via a single linebreak as written in the [rustdoc book](https://doc.rust-lang.org/nightly/rustdoc/the-doc-attribute.html).
Also changed the loop to use an iterator to get rid of the `docs.trim_end_matches("\n\n").to_owned()` part using `Itertools::intersperse`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 15:12:53 +00:00
Lukas Wirth
93262c750e Don't insert blank lines between doc attributes 2020-12-07 16:10:46 +01:00
bors[bot]
6df91a84dc
Merge #6731
6731: Add replace_match_with_if_let assist r=matklad a=Veykril

Basically the counterpart to `replace_if_let_with_match`, I personally sometimes want to replace matches like
```rust
match foo {
    pat => expr,
    _ => (),
}
``` 
into the corresponding
```rust
if let pat = foo {
    expr
}
```
which is the main reasoning behind this.
I put this into the same file as `replace_if_let_with_match` because the are complementing each other and I would probably rename the file to something like `replace_if_let_match` but I didn't do that for now because I was unsure whether git would still view this as a rename or not due to the amount of changes in the file so that the diff is still properly visible for now.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-07 15:00:07 +00:00
Jonas Schievink
e8a19e24ea Make ProcMacroProcessExpander private 2020-12-07 14:11:17 +01:00
Jonas Schievink
e42e6f9ab9 ProcMacroProcessExpander: support attribute macros 2020-12-07 14:02:27 +01:00
Florian Diebold
78dd548243 Upgrade Chalk
Also make overflow depth and max type size configurable through env variables.
This can be helpful at least for debugging.

Fixes #6628.
2020-12-07 11:48:58 +01:00
bors[bot]
a0fa522fda
Merge #6733
6733: Update attributes completion list r=jonas-schievink a=Veykril

Might be nice to have them grouped for readability/maintainability similar to how the [reference](https://doc.rust-lang.org/reference/attributes.html#built-in-attributes-index) does it but that would require the use of a `OnceCell` for sorting the entries back after construction.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-06 16:00:03 +00:00
Lukas Wirth
2ff1ebe8f3 Update attributes completion list 2020-12-06 16:46:24 +01:00