Commit graph

7407 commits

Author SHA1 Message Date
Jonas Schievink
d4ddec2bdf Shrink arenas after building ItemTree 2020-06-24 16:54:21 +02:00
Jonas Schievink
94169ee504 ItemTree: Use more boxed slices 2020-06-24 16:54:21 +02:00
Jonas Schievink
abdba92334 Don't allocate empty generics 2020-06-24 16:54:21 +02:00
Jonas Schievink
43cad21623 Don't allocate common visibilities 2020-06-24 16:54:20 +02:00
Jonas Schievink
16fd4dabb7 Remove file id from item tree
It's not needed, and `source` is only used by tests anyways
2020-06-24 16:53:56 +02:00
Jonas Schievink
c019002d17 Slightly reduce ItemTree memory footprint 2020-06-24 16:53:56 +02:00
Jonas Schievink
f9a1a9cd3c Merge item tree traits
The Source trait isn't needed anymore since we no longer merge
extern crate items with use items.
2020-06-24 16:53:56 +02:00
Jonas Schievink
b5fd02d93c Generate ModItem via macro 2020-06-24 16:53:56 +02:00
Jonas Schievink
20ff1cdcfb Address more comments 2020-06-24 16:53:56 +02:00
Jonas Schievink
a0ad457575 if let else -> match 2020-06-24 16:53:56 +02:00
Jonas Schievink
ae7a296c85 Unify and test attribute handling 2020-06-24 16:53:56 +02:00
Jonas Schievink
689e147c9d Collect inner items in expression macros 2020-06-24 16:53:54 +02:00
Jonas Schievink
5a81427304 Measure ItemTree query memory usage 2020-06-24 16:53:16 +02:00
Jonas Schievink
ffa0435050 Make generics and attr queries use ItemTree
Now it's fast
2020-06-24 16:53:16 +02:00
Jonas Schievink
19586bc5c6 Record HirFileId's in profiler 2020-06-24 16:53:16 +02:00
Jonas Schievink
1fbe21a545 Make remaining item data queries use item tree 2020-06-24 16:53:16 +02:00
Jonas Schievink
4b03b39d5b draw the rest of the owl 2020-06-24 16:53:16 +02:00
Jonas Schievink
b94caeb88b ItemTree: Make clonable and add AST access 2020-06-24 16:53:16 +02:00
Jonas Schievink
c12f7b610b Lower generics 2020-06-24 16:53:16 +02:00
Jonas Schievink
864b650f92 ItemTree: use a newtyped ID 2020-06-24 16:53:16 +02:00
Jonas Schievink
278556f9fe Move ItemTree lowering into its own module 2020-06-24 16:53:16 +02:00
Jonas Schievink
f9e5ba7d40 Remove now-broken incremental test
The ItemTree tracks impl and trait items, so the CrateDefMap now needs
recomputing when those change
2020-06-24 16:53:16 +02:00
Jonas Schievink
0e2602f75e Remove raw item query 2020-06-24 16:53:16 +02:00
Jonas Schievink
7054e89d18 Fix test 2020-06-24 16:53:16 +02:00
Jonas Schievink
9d24412929 Move collector 2020-06-24 16:53:14 +02:00
Jonas Schievink
f9417bcf49 Draw the rest of the owl 2020-06-24 16:52:37 +02:00
Jonas Schievink
e24de2007f collector changes WIP 2020-06-24 16:52:37 +02:00
Jonas Schievink
696a7a5a41 lower traits 2020-06-24 16:52:37 +02:00
Jonas Schievink
34bc80650b Hook up query, add impls, lower moar 2020-06-24 16:52:37 +02:00
Aleksey Kladov
1d75d11d6c Start item tree 2020-06-24 16:52:37 +02:00
Aleksey Kladov
e6c61d5072 Cleanup project.json deserialization 2020-06-24 16:16:52 +02:00
Aleksey Kladov
a07cad16ab Rename json_project -> project_json 2020-06-24 16:03:24 +02:00
bors[bot]
97c4d06258
Merge #5015 #5027 #5028
5015: Account for updated module ids when determining whether a resolution is changed r=matklad a=Nashenas88

Fixes #4943

5027: Make Debug less verbose for VfsPath and use Display in analysis-stats r=matklad a=lnicola



5028: Remove namedExports config r=matklad a=lnicola

Fixes a warning:

```
(!) Plugin commonjs: The namedExports option from "@rollup/plugin-commonjs" is deprecated. Named exports are now handled automatically.
```

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-24 13:02:37 +00:00
Paul Daniel Faria
43c6f6c039 Fix formatting issue with glob shadow test 2020-06-24 08:50:59 -04:00
Aleksey Kladov
154cb8243b Be more explicit about absolute paths at various places 2020-06-24 14:39:34 +02:00
Paul Daniel Faria
dfd79907b8 Use a macro in push_res to simplify code, simplify glob_shadowed_def assertion 2020-06-24 08:20:41 -04:00
Laurențiu Nicola
c15c22139f Make Debug less verbose for VfsPath and use Display in analysis-stats 2020-06-24 14:07:03 +03:00
bors[bot]
dff62def2e
Merge #5023
5023: Fix string literal inference in match r=flodiebold a=lnicola

Fixes #5020 

r? @flodiebold 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-24 10:40:47 +00:00
bors[bot]
414b731e7d
Merge #5024 #5026
5024: Simplify r=matklad a=matklad



bors r+
🤖

5026: Disable file watching when running slow tests r=matklad a=matklad

This should rid us of the intermittent test failure

https://github.com/rust-analyzer/rust-analyzer/pull/5017#issuecomment-648717983



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-24 10:31:20 +00:00
Aleksey Kladov
0a2b6087ec Simplify 2020-06-24 12:30:54 +02:00
Aleksey Kladov
a0b76161ab Disable file watching when running slow tests
This should rid us of the intermittent test failure

https://github.com/rust-analyzer/rust-analyzer/pull/5017#issuecomment-648717983
2020-06-24 12:27:13 +02:00
Laurențiu Nicola
2bd9f0f020 Fix string literal inference in match 2020-06-24 13:20:06 +03:00
Aleksey Kladov
5e7a1a1203 Simplify 2020-06-24 12:01:17 +02:00
Aleksey Kladov
04fe512f0d Simplify 2020-06-24 11:51:45 +02:00
Aleksey Kladov
9d64525daa Simplify 2020-06-24 11:50:53 +02:00
Aleksey Kladov
d4a493078a Simplify 2020-06-24 11:48:44 +02:00
Aleksey Kladov
c749fe223b Remove duplication 2020-06-24 11:31:30 +02:00
Aleksey Kladov
c6795fb83a More consistent usage of fixtures 2020-06-24 11:29:43 +02:00
Aleksey Kladov
e9cb818c26 Use fixtures more 2020-06-24 11:05:47 +02:00
Aleksey Kladov
08e2149eab Simplify 2020-06-24 10:28:28 +02:00
bors[bot]
c544f9a137
Merge #4940
4940: Add support for marking doctest items as distinct from normal code r=ltentrup a=Nashenas88

This adds `HighlightTag::Generic | HighlightModifier::Injected` as the default highlight for all elements within a doctest. Please feel free to suggest that a new tag be created or a different one used.

![Screenshot from 2020-06-23 09-18-13](https://user-images.githubusercontent.com/1673130/85408493-9752ce00-b532-11ea-94fe-197353ccc778.png)

Fixes #4929 
Fixes #4939

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-24 05:22:23 +00:00
Paul Daniel Faria
38af81f183 Account for updated module ids when determining whether a resolution is "changed" 2020-06-23 22:10:01 -04:00
Paul Daniel Faria
0d87eee3a9 Improve readability be replacing hard-to-read if-else branches with a match 2020-06-23 19:35:09 -04:00
Aleksey Kladov
d016cb4867 Use only one code-path for parsing fixtures
This removes leading newlines everywhere, shifting all ranges in tests
by one
2020-06-24 00:48:38 +02:00
Aleksey Kladov
e5101ae150 Centralize fixture parsing for assists 2020-06-24 00:30:34 +02:00
Aleksey Kladov
7ce122b1df Remove useless test code 2020-06-23 23:45:40 +02:00
Aleksey Kladov
aa69757a01 More principled indentation trimming in fixtures 2020-06-23 23:33:41 +02:00
Aleksey Kladov
f2f69e75c8 Minor, rename 2020-06-23 22:51:33 +02:00
Aleksey Kladov
ff687453a8 Slightly better name 2020-06-23 21:29:50 +02:00
Aleksey Kladov
295c8d4f7f Complicate
Fixing test fallout unfortunately requires more work, we need to do
it, but let's merge something at least!
2020-06-23 20:38:36 +02:00
Aleksey Kladov
a34f9b7fb3 Docs for Fixture 2020-06-23 18:58:45 +02:00
Aleksey Kladov
84cd28fddc Cut problematic dependency 2020-06-23 18:56:26 +02:00
Aleksey Kladov
fdf86aee18 Nicer API 2020-06-23 18:46:56 +02:00
Aleksey Kladov
3486b47e5c Simplify 2020-06-23 18:43:55 +02:00
Paul Daniel Faria
a8a606cdc4 Remove unrelated change 2020-06-23 12:40:55 -04:00
Aleksey Kladov
21f751a0e5 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
30748161f0 Simplify 2020-06-23 18:37:26 +02:00
Aleksey Kladov
6996ec860b Drop rarely used fixture functionality 2020-06-23 18:37:26 +02:00
Aleksey Kladov
f304874c8c Move fixtures to a separate file 2020-06-23 18:37:26 +02:00
Paul Daniel Faria
1e9095ae8c
Update comment for pop_and_inject
Co-authored-by: Leander Tentrup <ltentrup@users.noreply.github.com>
2020-06-23 12:15:45 -04:00
Paul Daniel Faria
2a56323537 Update injection mechanism and stop injecting through highlight element, switch to more general new highlight tag, generic 2020-06-23 12:13:50 -04:00
Paul Daniel Faria
d8230acd84 Add punctuation highlighting for highlighting punctuation in doctests, fix highlighting in doctests 2020-06-23 12:11:33 -04:00
Paul Daniel Faria
e137d9accb Add default color and opacity for documentation and injected, respectively, in the html generator 2020-06-23 12:08:04 -04:00
Paul Daniel Faria
351bba9bee Add support for marking doctest items as distinct from normal code, add default tag to all doctest elements 2020-06-23 12:08:04 -04:00
Aleksey Kladov
dad1333b48 New VFS 2020-06-23 17:51:06 +02:00
bors[bot]
7aa66371ee
Merge #5010
5010: Remove relative-path dependency r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-23 15:04:42 +00:00
Aleksey Kladov
676e82bb83 Remove relative-path dependency 2020-06-23 17:04:10 +02:00
bors[bot]
c0b9ae5503
Merge #5004
5004: Fix panic in split/merge import assists r=matklad a=lnicola

Fixes #4368 #4905

Not sure if this is the best solution here. Maybe the `make` functions should be fallible? We generally seem to be playing whack-a-mole with panics in assists, although most of them are `unwrap`s in the assist code.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-23 14:55:03 +00:00
Laurențiu Nicola
76ddface08 Fix panic in split and merge import assists 2020-06-23 16:51:07 +03:00
bors[bot]
3e09dbba94
Merge #5002
5002: Fix underflow panic when doctests are at top of file r=Nashenas88 a=Nashenas88

While debugging a comment at the top of a test string, I discovered that the offset calculations could underflow and panic. This only seemed to occur in tests, I assume because it's running a debug mode. The wrapping is quickly fixed later on in release mode, which is why this seems to have gone unnoticed. The new checks ensure the value is always positive or zero.

Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-23 13:25:43 +00:00
bors[bot]
338b229b79
Merge #4999
4999: SSR: Allow matching of whole macro calls r=matklad a=davidlattimore

Matching within macro calls is to come later and matching of macro calls within macro calls later still.

Co-authored-by: David Lattimore <dml@google.com>
2020-06-23 10:02:59 +00:00
Paul Daniel Faria
0b971625c3 Fix underflow panic when doctests are at top of file 2020-06-22 22:29:08 -04:00
bors[bot]
98c3e4e887
Merge #5000
5000: Remove RelativePathBuf from fixture r=matklad a=matklad

The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-22 22:15:22 +00:00
Aleksey Kladov
6a6098d4c3 Remove RelativePathBuf from fixture
The paths in fixture are not really relative (the default one is
`/main.rs`), so it doesn't make sense to use `RelativePathBuf` here.
2020-06-23 00:14:44 +02:00
David Lattimore
467af611fb SSR: Allow matching of whole macro calls
Matching within macro calls is to come later and matching of macro calls within macro calls later still.
2020-06-23 07:42:34 +10:00
bors[bot]
eabbeec14c
Merge #4988
4988: Don't offer to add missing fields of unknown types r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-22 15:47:22 +00:00
Laurențiu Nicola
acc2819c10 Don't offer to add missing fields of unknown types 2020-06-22 18:16:00 +03:00
bors[bot]
87615166af
Merge #4900
4900: Self variant enum res fix r=BGluth a=BGluth

Fixes #4789.

This is my first PR for this project, so it's probably worth giving it an extra close look.

A few things that I wasn't sure about:
- Is `resolve_path` really the best place to perform this check? It seemed like a natural place, but perhaps there's a better place?
- When handling the new variant `PathResolution::VariantDef`, I couldn't see an obvious variant of `TypeNs` to return in `in_type_ns` for Unions and Structs.

Co-authored-by: BGluth <gluthb@gmail.com>
2020-06-22 14:37:45 +00:00
BGluth
bdf7e70820 Enum variants with Self::[variant] now resolve (#4879) 2020-06-22 08:28:53 -06:00
Aleksey Kladov
7c9f97ecb8 Add paths::RelPath[Buf] 2020-06-22 15:03:37 +02:00
bors[bot]
d8842e89e9
Merge #4899
4899: don't complete top level attrs inside nested attrs and add better labels r=matklad a=bnjjj

close #4890

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 12:13:18 +00:00
bors[bot]
d144d69d2e
Merge #4921
4921: Allow SSR to match type references, items, paths and patterns r=davidlattimore a=davidlattimore

Part of #3186

Co-authored-by: David Lattimore <dml@google.com>
2020-06-22 11:50:34 +00:00
David Lattimore
662ab2ecc8 Allow SSR to match type references, items, paths and patterns
Part of #3186
2020-06-22 21:42:55 +10:00
Benjamin Coenen
5aad6c9fa6 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-22 13:39:05 +02:00
bors[bot]
19701b39ac
Merge #4928
4928: Fix renaming mod in use tree r=matklad a=unexge

Fixes #4825

Co-authored-by: unexge <unexge@gmail.com>
2020-06-22 11:19:09 +00:00
BGluth
3a3b40a554 Created goto Self enum variant test 2020-06-21 13:27:16 -06:00
Benjamin Coenen
3df879f139 don't complete top level attrs inside nested attrs and add better labels #4899
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-21 19:14:08 +02:00
Benjamin Coenen
9342574097 do not suggest assist for return type to result in bad case #4826
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-21 18:47:27 +02:00
Jeremy Kolb
a120ceed19 Update test for new serde 2020-06-21 12:10:50 -04:00
Jonas Schievink
500d8b2f60 Handle bindings after @ in patterns 2020-06-21 15:19:38 +02:00
bors[bot]
6d0a765d34
Merge #4962
4962: Implement APIs for parsing expressions, types, paths, patterns and items r=davidlattimore a=davidlattimore



Co-authored-by: David Lattimore <dml@google.com>
2020-06-21 12:37:29 +00:00
David Lattimore
bc99e95d7d Implement APIs for parsing expressions, types, paths, patterns and items 2020-06-21 22:28:17 +10:00
bors[bot]
50dad50188
Merge #4959
4959: Syntax highlighting for documentation comments on macro definitions r=matklad a=ltentrup

Two minor changes with regards to syntax highlighting of comments attached to macro definitions.

Before
<img width="290" alt="Bildschirmfoto 2020-06-20 um 00 05 19" src="https://user-images.githubusercontent.com/201808/85182705-c561b500-b289-11ea-944e-0bdf6508a44f.png">

After
<img width="288" alt="Bildschirmfoto 2020-06-20 um 00 03 36" src="https://user-images.githubusercontent.com/201808/85182727-d90d1b80-b289-11ea-9d2d-234731f19302.png">
Fixes #4949

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-21 12:05:16 +00:00
bors[bot]
04d64267de
Merge #4947
4947: Replace `impls_in_trait` query with smarter use of `CrateImplDefs` r=matklad a=jonas-schievink

`impls_in_trait` was allocating a whopping ~400 MB of RAM when running analysis-stats on r-a itself.

Remove it, instead adding a query that computes a summary `CrateImplDefs` map for all transitive dependencies. This can probably still be made more efficient, but this already reduces the peak memory usage by 25% without much performance impact on analysis-stats.

**Before**:

```
Total: 34.962107188s, 2083mb allocated 2141mb resident
   422mb ImplsForTraitQuery (deps)
   250mb CrateDefMapQueryQuery
   147mb MacroArgQuery
   140mb TraitSolveQuery (deps)
    68mb InferQueryQuery (deps)
    62mb ImplDatumQuery (deps)
```

**After**:

```
Total: 35.261100358s, 1520mb allocated 1569mb resident
   250mb CrateDefMapQueryQuery
   147mb MacroArgQuery
   144mb TraitSolveQuery (deps)
    68mb InferQueryQuery (deps)
    61mb ImplDatumQuery (deps)
    45mb BodyQuery
    45mb ImplDatumQuery
```

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-20 22:14:21 +00:00
Aleksey Kladov
f3cf85ab48 Move ReqQueue to lsp-server 2020-06-20 23:24:16 +02:00
bors[bot]
b575b02449
Merge #4961
4961: Centralize handing of in-flight requests r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-20 19:39:41 +00:00
bors[bot]
c8557b91a3
Merge #4958
4958: Infer FnSig via Fn traits r=flodiebold a=adamrk

Addresses https://github.com/rust-analyzer/rust-analyzer/issues/4481.
When inferring types check if the callee implements one of the builtin `Fn` traits. Also autoderef the callee before trying to figure out it's `FnSig`. 

Co-authored-by: adamrk <ark.email@gmail.com>
2020-06-20 15:10:35 +00:00
adamrk
1629fb770e Push obligation instead of matching on solution 2020-06-20 17:00:57 +02:00
Aleksey Kladov
93605c49ba Centralize handing of in-flight requests 2020-06-20 13:06:11 +02:00
adamrk
d8f5192d99 Get Output assoc type by name 2020-06-20 11:53:55 +02:00
adamrk
f07338bae2 Add test for dyn Fn Output 2020-06-20 11:43:40 +02:00
adamrk
436dcd9656 move tests to ra_hir_ty 2020-06-20 11:32:01 +02:00
adamrk
f0c8058f12 Fixes to callable_sig_from_fn_trait 2020-06-20 11:04:46 +02:00
adamrk
38f6cdbc8a Make get_fn_trait a method of FnTrait 2020-06-20 08:42:35 +02:00
adamrk
cf870af807 Switch back callable_sig for known fn types 2020-06-20 08:26:31 +02:00
Jonas Schievink
a3c2f5126f Recursively compute impl sets 2020-06-20 00:36:02 +02:00
Leander Tentrup
df5b37cb61 Syntax highlighting for documentation comments on macro definitions 2020-06-20 00:02:42 +02:00
bors[bot]
0f7961d557
Merge #4952
4952: Shift bound variables correctly when using assoc type shorthand r=matklad a=flodiebold

Fixes #4885.
Fixes #4800.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-19 21:40:59 +00:00
bors[bot]
af0dcc5481
Merge #4951
4951: Don't panic on crates depending on themselves r=matklad a=flodiebold

Fixes #3883.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-19 21:28:32 +00:00
Jonas Schievink
a91c2e94b7 Add new query to stats 2020-06-19 23:17:53 +02:00
adamrk
3f94a90c7b Infer FnSig from Fn traits 2020-06-19 22:51:25 +02:00
Jonas Schievink
aa8442af70 Don't include downstream crate in query 2020-06-19 22:33:13 +02:00
Florian Diebold
170cdf9076 Shift bound variables correctly when using assoc type shorthand
Fixes #4885.
Fixes #4800.
2020-06-19 22:07:58 +02:00
Florian Diebold
2745cb37c1 Use correct substs for super trait assoc types
When referring to an associated type of a super trait, we used the substs of the
subtrait. That led to the #4931 crash if the subtrait had less parameters, but
it could also lead to other incorrectness if just the order was different.

Fixes #4931.
2020-06-19 21:46:47 +02:00
Vincent Rouillé
c95bb0ba7b
Fix substs in resolve_value_path for ImplSelf
Fixes #4953.
2020-06-19 20:33:04 +02:00
Florian Diebold
584bddef0c Don't panic on crates depending on themselves
Fixes #3883.
2020-06-19 18:38:03 +02:00
bors[bot]
90a5c4626a
Merge #4851
4851: Add quickfix to add a struct field r=TimoFreiberg a=TimoFreiberg

Related to #4563 
I created a quickfix for record literals first because the NoSuchField diagnostic was already there.
To offer that quickfix for FieldExprs with unknown fields I'd need to add a new diagnostic (or create a `NoSuchField` diagnostic for those cases)

I think it'd make sense to make this a snippet completion (to select the generated type), but this would require changing the `Analysis` API and I'd like some feedback before I touch that.

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
2020-06-19 15:08:52 +00:00
bors[bot]
ec6df5d3e8
Merge #4937
4937: Allow overriding rust-analyzer display version r=matklad a=oxalica

The build script invokes `git` for version information which is displayed when rust-analyzer is called with `--version`. But in build environment without `git` or when the source code is not a git repo, there's no way to manually specify the version information.

This patch respects environment variable ~`REV`~ `RUST_ANALYZER_REV` in compile time for overriding.

Related: https://github.com/NixOS/nixpkgs/pull/90976

Co-authored-by: oxalica <oxalicc@pm.me>
2020-06-19 13:43:42 +00:00
bors[bot]
4575c38810
Merge #4839
4839: `Go to Type Definition` hover action. r=matklad a=vsrs

![hover_actions_goto](https://user-images.githubusercontent.com/62505555/83335671-0122e380-a2b7-11ea-9922-fbdcfb11a7f3.gif)

This implementation supports things like `dyn Trait<SomeType>`, `-> impl Trait`, etc.

Co-authored-by: vsrs <vit@conrlab.com>
2020-06-19 13:34:24 +00:00
Aleksey Kladov
b9f3c5d585 Speedup VFS::partition
The task of `partition` function is to bin the flat list of paths into
disjoint filesets. Ideally, it should be incremental -- each new file
should be added to a specific fileset.

However, preliminary measurnments show that it is actually fast enough
if we just optimize this to use a binary search instead of a linear
scan.
2020-06-19 15:07:32 +02:00
Jonas Schievink
ebd8233b3e Replace impls_in_trait with CrateImplDefs 2020-06-19 01:29:34 +02:00
Benjamin Coenen
4c89d32f7a do not suggest assist for return type to result in bad case #4826
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 22:16:39 +02:00
bors[bot]
902a9c6da7
Merge #4930
4930: Avoid all unchecked indexing in match checking r=flodiebold a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/4416, but replaces it with a false positive.

r? @flodiebold 

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-18 19:43:05 +00:00
Benjamin Coenen
3f26c5758d don't complete top level attrs inside nested attrs and add better labels #4890
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 21:31:49 +02:00
oxalica
f9ce7cd961
Fix fmt 2020-06-19 02:25:07 +08:00
oxalica
bed0b794e5
Allow overriding rust-analyzer display revision 2020-06-18 22:33:23 +08:00
bors[bot]
1e35c74055
Merge #4941
4941: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-18 14:05:54 +00:00
Aleksey Kladov
42be05a335 Simplify 2020-06-18 16:02:45 +02:00
bors[bot]
f7f627d342
Merge #4903
4903: Add highlighting support for doc comments r=matklad a=Nashenas88

The language server protocol includes a semantic modifier for documentation. This change exports that modifier for doc comments so users can choose to highlight them differently compared to regular comments.

Example:
<img width="375" alt="Screen Shot 2020-06-16 at 10 34 14 AM" src="https://user-images.githubusercontent.com/1673130/84788271-f6599580-afbc-11ea-96e5-7a0215da620b.png">

CC @woody77 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
2020-06-18 13:23:14 +00:00
Paul Daniel Faria
66fc084a86 Remove logic to mark all doctest code as 2020-06-18 09:14:02 -04:00
Veetaha
6e81c9a921 Flatten Task enum ¯\_(ツ)_/¯ 2020-06-18 15:02:36 +03:00
veetaha
76c1160ffa Migrate flycheck to fully-lsp-compatible progress reports (introduce ra_progress crate) 2020-06-18 14:50:56 +03:00
veetaha
2f8126fcac Migrate flycheck to fully-lsp-compatible progress reports (introduce ra_progress crate) 2020-06-18 14:50:17 +03:00
bors[bot]
0262dba97e
Merge #4935
4935: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-18 10:41:37 +00:00
Aleksey Kladov
61a3f6d463 Simplify 2020-06-18 12:39:41 +02:00
bors[bot]
13adfedf82
Merge #4821
4821: display Doctest code lens before comment r=matklad a=bnjjj

close #4785

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 10:34:21 +00:00
Benjamin Coenen
2732fdb595 display Doctest code lens before comment #4785
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-18 11:31:15 +02:00
vsrs
022fbefffa Apply suggestions from code review 2020-06-18 10:15:43 +03:00
vsrs
4b07c1e775 Add Type::walk method 2020-06-18 10:15:43 +03:00
vsrs
7ec0064409 Remove AdtOrTrait 2020-06-18 10:15:43 +03:00
vsrs
d4e75312ba Add associated type test. 2020-06-18 10:15:43 +03:00
vsrs
283ec13fc0 Fix type "items" order. 2020-06-18 10:15:43 +03:00
vsrs
c50157f330 Add Go to Type Definition hover action. 2020-06-18 10:15:43 +03:00
vsrs
102b7f0f56 Fix empty hover action group for a runnable. 2020-06-18 10:15:42 +03:00
bors[bot]
28077f971a
Merge #4872
4872: Reduce the usage of bare subscript operator r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-18 06:48:12 +00:00
bors[bot]
99e3acd1fe
Merge #4934
4934: Remove special casing for library symbols r=matklad a=matklad

We might as well handle them internally, via queries.

I am not sure, but it looks like the current LibraryData setup might
even predate salsa? It's not really needed and creates a bunch of
complexity.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-18 06:31:24 +00:00
Aleksey Kladov
d1d0b5a88c Remove special casing for library symbols
We might as well handle them internally, via queries.

I am not sure, but it looks like the current LibraryData setup might
even predate salsa? It's not really needed and creates a bunch of
complexity.
2020-06-18 08:29:34 +02:00
Veetaha
9bb028189a Simplify 2020-06-18 02:00:48 +03:00
Jonas Schievink
4d6d7aec50 Avoid all unchecked indexing in match checking 2020-06-17 21:41:07 +02:00
unexge
ce29d172a5 Fix renaming mod in use tree 2020-06-17 20:16:04 +03:00
bors[bot]
1ce8c2b5a0
Merge #4927
4927: Better encapsulate reverse-mapping of files to cargo targets r=matklad a=matklad

We need to find a better way to do it...

CrateGraph by itself is fine, CargoWorkspace as well, but the mapping
between the two seems arbitrary...



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-17 15:53:07 +00:00
Aleksey Kladov
dc90e0b5a5 Better encapsulate reverse-mapping of files to cargo targets
We need to find a better way to do it...

CrateGraph by itself is fine, CargoWorkspace as well, but the mapping
between the two seems arbitrary...
2020-06-17 17:51:46 +02:00
Paul Daniel Faria
a951108173 Ensure all existing doctest code highlights have documentation modifier 2020-06-17 09:33:21 -04:00
Leander Tentrup
2145e2d878 Syntax highlighting for escape sequences in strings 2020-06-17 15:27:13 +02:00
Paul Daniel Faria
aae26bc5b8 Add highlighting support for doc comments 2020-06-17 08:29:13 -04:00
bors[bot]
931f317399
Merge #4913 #4915 #4916
4913: Remove debugging code for incremental sync r=matklad a=lnicola



4915: Inspect markdown code fences to determine whether to apply syntax highlighting r=matklad a=ltentrup

Fixes #4904 

4916: Warnings as hint or info r=matklad a=GabbeV

Fixes #4229 

This PR is my second attempt at providing a solution to the above issue. My last PR(#4721) had to be rolled back(#4862) due to it overriding behavior many users expected. This PR solves a broader problem while trying to minimize surprises for the users. 

### Problem description
The underlying problem this PR tries to solve is the mismatch between [Rustc lint levels](https://doc.rust-lang.org/rustc/lints/levels.html) and [LSP diagnostic severity](https://microsoft.github.io/language-server-protocol/specification#diagnostic). Rustc currently doesn't have a lint level less severe than warning forcing the user to disable warnings if they think they get to noisy. LSP however provides two severitys below warning, information and hint. This allows editors like VSCode to provide more fine grained control over how prominently to show different diagnostics.

Info severity shows a blue squiggly underline in code and can be filtered separately from errors and warnings in the problems panel.
![image](https://user-images.githubusercontent.com/13839236/84830640-0bb8d900-b02a-11ea-9e2f-0561b0e8f1ef.png)
![image](https://user-images.githubusercontent.com/13839236/84826931-ffca1880-b023-11ea-8080-5e5b91a6ac0d.png)

Hint severity doesn't show up in the problems panel at all and only show three dots under the affected code or just faded text if the diagnostic also has the unnecessary tag.
![image](https://user-images.githubusercontent.com/13839236/84827165-55062a00-b024-11ea-8bd6-bdbf1217c4c5.png)

### Solution
The solution provided by this PR allows the user to configure lists of of warnings to report as info severity and hint severity respectively. I purposefully only convert warnings and not errors as i believe it's a good idea to have the editor show the same severity as the compiler as much as possible.
![image](https://user-images.githubusercontent.com/13839236/84829609-50437500-b028-11ea-80a8-1bbd05680ba7.png)

### Open questions
#### Discoverability
How do we teach this to new and existing users? Should a section be added to the user manual? If so  where and what should it say?

#### Defaults
Other languages such as TypeScript report unused code as hint by default. Should rust-analyzer similarly report some problems as hint/info by default?

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
Co-authored-by: Gabriel Valfridsson <gabriel.valfridsson@gmail.com>
2020-06-17 11:01:37 +00:00
bors[bot]
09c5cfedff
Merge #4914
4914: Fix panic in match checking r=flodiebold a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-17 10:53:22 +00:00
David Lattimore
ac9166a7af Remove :expr from placeholders
Reasoning discussed at #3186
2020-06-17 18:28:24 +10:00
Gabriel Valfridsson
656e95211e Warnings as hint or info 2020-06-17 00:00:43 +02:00
Leander Tentrup
8ff91cf6b6 Inspect markdown code fences to determine whether to apply syntax highlighting 2020-06-16 23:03:59 +02:00
Jonas Schievink
d8af7983b1 Use ra_fixture and reformat tests 2020-06-16 22:54:41 +02:00
Jonas Schievink
9ecbadcedb Fix index-out-of-bounds panic in match checking 2020-06-16 22:45:34 +02:00
Laurențiu Nicola
2fa0b20ce0 Remove debugging code for incremental sync 2020-06-16 22:06:24 +03:00
Aleksey Kladov
3c72fc0573 Anchor file-system operations to the file, and not to the source root.
Anchoring to the SourceRoot wont' work if the path is absolute:

  #[path = "/tmp/foo.rs"]
  mod foo;

Anchoring to a file will.

However, we *should* anchor, instead of just producing an abs path.

I can imagine a situation where, for example, rust-analyzer processes
crates from different machines (or, for example, from in-memory git
branch), where the same absolute path in different crates might refer
to different files in the end!
2020-06-16 18:45:58 +02:00
bors[bot]
6b2175878d
Merge #4891
4891: New VFS API r=matklad a=matklad

cc @flodiebold , @jonas-schievink 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-16 11:48:36 +00:00
Aleksey Kladov
c002322bde New VFS API 2020-06-16 13:42:29 +02:00
bors[bot]
4342b71715
Merge #4876
4876: Syntactic highlighting of NAME_REF for injections r=matklad a=ltentrup

This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.

Follow up of #4683.
Fixes #4809.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-16 11:40:51 +00:00
bors[bot]
83a16e825d
Merge #4878
4878: Make "Replace qualified name with use" replace *all* mentions of the path r=matklad a=jonas-schievink

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

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-16 05:29:05 +00:00
Jonas Schievink
4295a004ed Operate only on AST paths instead of HIR 2020-06-16 00:49:59 +02:00
Benjamin Coenen
9aad07dbea don't complete top level attrs inside nested attrs and add better labels #4890
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-15 23:11:08 +02:00
Jonas Schievink
aaaa68b56c Simplify 2020-06-15 22:59:49 +02:00
Jonas Schievink
71c002e589 It's fookin' raw 2020-06-15 22:39:26 +02:00
Leander Tentrup
c4b3db0c2f Syntactic highlighting of NAME_REF for injections
This commit adds a function that tries to determine the syntax highlighting class of NAME_REFs based on the usage.
It is used for highlighting injections (such as highlighting of doctests) as the semantic logic will most of the time result in unresolved references.
It also adds a color to unresolved references in HTML encoding.
2020-06-15 22:13:53 +02:00
bors[bot]
f4f51171ca
Merge #4860
4860: Accept relative paths in rust-project.json r=matklad a=tweksteen

If a relative path is found as part of Crate.root_module or Root.path, interpret it as relative to the location of the rust-project.json file.

Fixes: #4816 

Co-authored-by: Thiébaud Weksteen <tweek@google.com>
2020-06-15 15:03:31 +00:00
bors[bot]
5b013e5665
Merge #4877
4877: Fix syntax highlighting of recursive macros r=matklad a=ltentrup

Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.

Before:
<img width="514" alt="before" src="https://user-images.githubusercontent.com/201808/84595030-11f65c00-ae56-11ea-9bb2-b1abe2236990.png">

After:
<img width="516" alt="recursive-macro" src="https://user-images.githubusercontent.com/201808/84594981-d196de00-ae55-11ea-8636-f877d5d795ff.png">


Fixes #4694.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-15 13:44:46 +00:00
Leander Tentrup
06f89e5f3a Fix syntax highlighting of recursive macros
Add syntax highlighting for the BANG (`!`) token if the parent is `MACRO_CALL`.
2020-06-15 15:03:13 +02:00
David Lattimore
fe7d35d477 Make ra_syntax::{SyntaxNodeChildren, SyntaxElementChildren} public.
SyntaxNode::children and SyntaxNode::children_with_tokens return these types, but there's currently no way AFAIK to name them.
2020-06-15 21:36:30 +10:00
Thiébaud Weksteen
44f28f65af Accept relative paths in rust-project.json
If a relative path is found as part of Crate.root_module or Root.path,
interpret it as relative to the location of the rust-project.json file.
2020-06-15 13:11:53 +02:00
bors[bot]
db6100dbaa
Merge #4889
4889: Deprecate hir::Path::from_ast r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-15 09:02:53 +00:00
Aleksey Kladov
b5c4f2faa2 Update parser tests with env var 2020-06-15 11:02:17 +02:00
Aleksey Kladov
d739731830 Allow attributes on expressions
https://github.com/rust-lang/rust/pull/69201/
2020-06-15 10:59:05 +02:00
Aleksey Kladov
52a220cece Deprecate hir::Path::from_ast 2020-06-15 10:55:48 +02:00
bors[bot]
6609e71b16
Merge #4882
4882: _match.rs: improve comment formatting r=matklad a=jonas-schievink

This results in much nicer rustdoc output

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-06-15 08:25:05 +00:00
Toby Dimmick
41f5471f3e fill_match_arms bind pattern implementation 2020-06-14 22:44:51 +01:00
Toby Dimmick
34db4edb80 fill_match_arms bind pattern test 2020-06-14 22:43:16 +01:00
Benjamin Coenen
36d9105d0e display Doctest code lens before comment #4785
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-14 21:50:24 +02:00
Jonas Schievink
4ebafb9005 _match.rs: improve comment formatting 2020-06-14 15:56:02 +02:00
Aleksey Kladov
a32cff333d Introduce paths crate
It's a good idea to distinguish between absolute and relative paths at
the type level, to avoid accidental dependency on the cwd, which
really shouldn't matter for rust-analyzer service
2020-06-14 14:15:36 +02:00
Veetaha
667d224fcc Reduce the usage of bare subscript operator 2020-06-14 13:12:52 +03:00
Jonas Schievink
5d66bfe163 Shorten *all* qualified paths when adding use 2020-06-13 19:12:05 +02:00
Jonas Schievink
b65c0a5893 Expose find_insert_use_container 2020-06-13 19:05:46 +02:00
Jonas Schievink
e9eb54c617 Fix rewrite_root when there's only 1 replacement 2020-06-13 19:05:46 +02:00
bors[bot]
246c66a7f7
Merge #4867
4867: Cleanup URL handling r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:35:44 +00:00
Aleksey Kladov
50bbf7233d Cleanup URL handling 2020-06-13 14:15:38 +02:00
bors[bot]
d00ca86da4
Merge #4868
4868: Fix if and while postfix completions r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:12:08 +00:00
Aleksey Kladov
7dafe951d4 Fix if and while postfix completions 2020-06-13 14:06:13 +02:00
bors[bot]
c87c4a0a40
Merge #4700
4700: Add top level keywords completion r=matklad a=mcrakhman

This fixes the following issue: https://github.com/rust-analyzer/rust-analyzer/issues/4566. 

Also added simple logic which filters the keywords which can be used with unsafe on the top level.   

Co-authored-by: Mikhail Rakhmanov <rakhmanov.m@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-13 12:02:59 +00:00
Aleksey Kladov
b99b4953c9 More concise completion tests 2020-06-13 13:57:18 +02:00
Aleksey Kladov
ef70076f1d Cleanup 2020-06-13 13:47:30 +02:00
Mikhail Rakhmanov
912f38200f Add keywords completions on source file position 2020-06-13 10:43:39 +02:00
Mikhail Rakhmanov
16bbf4ab7f Merge branch 'master' into keyword_completion
# Conflicts:
#	docs/user/generated_features.adoc
2020-06-13 08:42:15 +02:00
Mikhail Rakhmanov
eeb8b9e236 Fix tests and remove unused methods 2020-06-13 01:21:48 +02:00
Mikhail Rakhmanov
6feb52c12a Add more patterns, tests and fix keywords 2020-06-13 00:55:21 +02:00
Mikhail Rakhmanov
3576671043 Rewrite snapshot checks 2020-06-12 20:30:57 +02:00
Timo Freiberg
f5ac313000 Add quickfix to add a struct field 2020-06-12 18:52:44 +02:00
Gabriel Valfridsson
66291d19f9 Revert "Hide squiggly for unused and unnecessary"
This reverts commit 599c105e6f.
2020-06-12 18:39:50 +02:00
bors[bot]
b56ad148db
Merge #4857
4857: Fix invalid shorthand initialization diagnostic for tuple structs r=jonas-schievink a=OptimalStrategy

Initializing tuple structs explicitly, like in the example below, produces a "Shorthand struct initialization" diagnostic that leads to a compilation error when applied:
```rust
struct S(usize);

fn main() { 
    let s = S { 0: 0 };  // OK, but triggers the diagnostic
    // let s = S { 0 };  // Compilation error
}
```

This PR adds a check that the field name is not a literal.

Co-authored-by: OptimalStrategy <george@usan-podgornov.com>
Co-authored-by: OptimalStrategy <17456182+OptimalStrategy@users.noreply.github.com>
2020-06-12 14:28:40 +00:00
OptimalStrategy
591b5ec2c1 simplify determining whether the field is a tuple field 2020-06-12 10:16:19 -04:00
bors[bot]
f3d73865d6
Merge #4855
4855: Use more idiomatic style for lifetimes in generated code r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-12 12:49:30 +00:00
bors[bot]
1906655070
Merge #4856
4856: Simplify r=matklad a=Veetaha



Co-authored-by: Veetaha <veetaha2@gmail.com>
2020-06-12 12:41:52 +00:00
Mikhail Rakhmanov
42a719ad25 Remove comment and incorrect assert 2020-06-12 13:14:53 +02:00
Mikhail Rakhmanov
d38bf1624d Return snapshots to tests 2020-06-12 13:09:42 +02:00
Jonas Schievink
0231e4ac77 find_path: return shorter paths for external items
If a containing module is already in scope, there's no need to
use the full path to the item.
2020-06-12 13:01:20 +02:00
Mikhail Rakhmanov
f123539ad2 More assert refactoring 2020-06-12 12:15:53 +02:00
Mikhail Rakhmanov
4c92f2d190 Add more pattern tests 2020-06-12 10:12:15 +02:00
Mikhail Rakhmanov
396167eadb New testing approach for keywords 2020-06-12 08:49:12 +02:00
OptimalStrategy
59f195a323 Fix invalid shorthand initialization diagnostic for tuple structs 2020-06-12 01:11:54 -04:00
Veetaha
4fefc7d06c Simplify 2020-06-12 02:56:06 +03:00
Veetaha
c514060600 Apply codegen with idiomatic lifetimes 2020-06-12 01:26:58 +03:00
Mikhail Rakhmanov
a2b4385f16 Add few smoke tests for patterns and refactoring 2020-06-12 00:17:30 +02:00
Mikhail Rakhmanov
f46bc12199 Add more patterns and keywords 2020-06-11 23:25:58 +02:00
bors[bot]
36353bb182
Merge #4833
4833: Separating parsing of `for` in predicates and types r=matklad a=matthewjasper

We now correctly accept `for<'a> (&'a F): Fn(&'a str)` in a where clause and correctly reject `for<'a> &'a u32` as a type.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
2020-06-11 17:33:20 +00:00
Matthew Jasper
8622e4cc1b Add example of old trait object syntax 2020-06-11 18:15:03 +01:00
Matthew Jasper
879693e63c Move complex inline test to own file 2020-06-11 18:14:57 +01:00
bors[bot]
bd61ad756c
Merge #4849
4849: Make known paths use `core` instead of `std` r=matklad a=jonas-schievink

I'm not sure if this causes problems today, but it seems like it easily could, if rust-analyzer processes the libstd sources for the right `--target` and that target is a `#![no_std]`-only target.

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-11 15:30:05 +00:00
Jonas Schievink
215e229dd1 Update wrap return tests
Update "no diagnostic" tests, use `()` instead of `String`
2020-06-11 17:28:32 +02:00
bors[bot]
7c617000b8
Merge #4850
4850: Indent chain `.` even if there's more stuff afterwards r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-11 15:20:24 +00:00
Aleksey Kladov
279a1ae564 Indent chain . even if there's more stuff afterwards 2020-06-11 17:13:24 +02:00
Jonas Schievink
90331ea035 Make known paths use core instead of std 2020-06-11 16:23:20 +02:00
Mikhail Rakhmanov
eb4004fdb8 Add todo 2020-06-11 14:32:14 +02:00
Mikhail Rakhmanov
9f91901f7e Add more keywords 2020-06-11 14:16:35 +02:00
Aleksey Kladov
663ce0e99d Remove dead code 2020-06-11 13:34:09 +02:00
bors[bot]
32157d48f4
Merge #4843
4843: Don't guess macro expansion crate r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-11 10:18:53 +00:00
Aleksey Kladov
fac7b0e252 Don't guess macro expansion crate 2020-06-11 12:13:14 +02:00
bors[bot]
f320c38aec
Merge #4819
4819: Add an FST index to `ImportMap` and use it to speed up auto import r=matklad a=jonas-schievink

For the importing crate, we still use the symbol index, but I've modified it to only look at files that comprise that crate (instead of the whole workspace).

Oh, and since now the symbol query limit is respected correctly, it's possible that some results from the local crate now disappear if there are many matches.

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

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-11 10:07:52 +00:00
Jonas Schievink
6766a6b0e1 Add symbol index FIXME 2020-06-11 12:03:08 +02:00
Aleksey Kladov
d8a5d39c2d Make relevant_crates return a Set 2020-06-11 11:30:06 +02:00
Jonas Schievink
dd22657407 ImportMap: use IndexMap internally
It iterates in insertion order, which makes the ordering more
predictable.
2020-06-10 16:15:49 +02:00
Jonas Schievink
7e83ed99a8 Respect casing when searching for imports 2020-06-10 16:04:55 +02:00
Jonas Schievink
ed2817e599 Move limit check down 2020-06-10 12:40:33 +02:00
Jonas Schievink
56c7145993 Limit import map queries 2020-06-10 12:40:33 +02:00
Jonas Schievink
bcf875f46a Clean up import_map.rs 2020-06-10 12:38:58 +02:00
Jonas Schievink
781b514e58 Add test for macro generated items 2020-06-10 12:38:58 +02:00
Jonas Schievink
a70a0ca73c ImportsLocator: use ImportMap for non-local crates 2020-06-10 12:38:58 +02:00
Jonas Schievink
b01fb22494 ra_hir: expose import_map::search_dependencies 2020-06-10 12:38:58 +02:00
Jonas Schievink
6463d3ac63 symbol_index: allow querying a single crate 2020-06-10 12:38:58 +02:00
Jonas Schievink
4bcf8c8c68 Add an FST index to ImportMap 2020-06-10 12:38:58 +02:00
Jonas Schievink
54936e8aa2 Fix the symbol query limit 2020-06-10 12:38:58 +02:00
Jonas Schievink
d50a1a0fe9 Profile world_symbols 2020-06-10 12:38:58 +02:00
bors[bot]
f632727b2a
Merge #4834
4834: In field patterns, don't highlight local binding as a field r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-10 10:37:27 +00:00
Aleksey Kladov
db1cadd444 In field patterns, don't highlight local binding as a field 2020-06-10 12:34:23 +02:00
Matthew Jasper
506e1ddbfa Separating parsing of for in predicates and types 2020-06-10 11:30:58 +01:00
Aleksey Kladov
27ebe5d33e Reduce OUT_DIR special casing 2020-06-10 12:08:35 +02:00
bors[bot]
560b98bc50
Merge #4822
4822: Let checkOnSafe default to some of the options of cargo r=matklad a=clemenswasser

This will fix #4631
The implementation works (as far as I have tested) but is suboptimal because I am copying the "cargo.features".

Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
2020-06-10 07:39:44 +00:00
Clemens Wasser
fe21fc2d25 checkOnSafe.features and checkOnSafe.allFeatures now work identically. 2020-06-10 09:37:26 +02:00
Clemens Wasser
33b9058838 Most of the checkOnSafe options now default to the cargo equivalent. 2020-06-10 09:27:25 +02:00
Clemens Wasser
47ef544fa5 Added the rust-analyzer.checkOnSave.features option. 2020-06-10 08:51:11 +02:00
bors[bot]
c9fc7251ca
Merge #4824
4824: Correct "debug_assertion" to "debug_assertions" to match the cfg that the rust debug assert macros use. r=matklad a=woody77

This is for #4823.

Co-authored-by: Aaron Wood <aaronwood@google.com>
2020-06-10 05:24:18 +00:00
Aaron Wood
f4ed2da966 Correct "debug_assertion" to "debug_assertions" to match the cfg
option that the rust debug assert macros use.
2020-06-09 19:58:39 -07:00
Clemens Wasser
684b6fa1b8 flycheck now uses the configured features 2020-06-09 21:47:54 +02:00
Benjamin Coenen
9d0a6aaee3 display Doctest code lens before comment #4785
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-06-09 21:28:51 +02:00
Aleksey Kladov
e8d50578ab Correctly parse <_> paths in patterns
closes #3659
2020-06-09 13:45:18 +02:00
Aleksey Kladov
16943e533c Minor, use T! 2020-06-09 13:45:11 +02:00
bors[bot]
d4d384e4c8
Merge #4813
4813: Simplify r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-09 11:22:38 +00:00
Aleksey Kladov
d8571e076c Simplify 2020-06-09 13:17:22 +02:00
bors[bot]
eb53f5a9e5
Merge #4812
4812: Use correct indent when replacing with match r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-09 11:14:30 +00:00
Aleksey Kladov
8cad7d1a2b Use correct indent when replacing with match 2020-06-09 12:38:47 +02:00
bors[bot]
382d10ea60
Merge #4811
4811: Unwrap block works with match arms r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-09 10:12:50 +00:00
Aleksey Kladov
53cc2c16e7 Unwrap block works with match arms 2020-06-09 11:52:45 +02:00
bors[bot]
4cacedd3de
Merge #4810
4810: Simplify unwrapping of blocks r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-09 09:33:56 +00:00
Aleksey Kladov
5233766ce5 Simplify unwrapping of blocks 2020-06-09 11:33:28 +02:00
bors[bot]
6f0cc91c88
Merge #4803
4803: Parse default unsafe fn r=matklad a=Avi-D-coder



Co-authored-by: Avi Dessauer <avi.the.coder@gmail.com>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-09 08:56:28 +00:00
Aleksey Kladov
2785362a1f
Update crates/ra_parser/src/grammar/items.rs 2020-06-09 10:50:25 +02:00
Aaron Wood
055b9b64bc Finish transition to cfgs from the separate atoms and features. 2020-06-08 16:19:39 -07:00
Aleksey Kladov
38fa4d17fb Simplify API 2020-06-09 00:01:53 +02:00
Avi Dessauer
e38685cb48 Parse default unsafe fn 2020-06-08 17:49:06 -04:00
Aleksey Kladov
2a42904680 Simplify 2020-06-08 21:48:23 +02:00
bors[bot]
3a7c218fd4
Merge #4576
4576: Add implementation of extract struct from enum variant r=matklad a=mcrakhman

Hi guys! I implemented the extraction functionality including modifying multiple files. The only thing I didn't change the cursor position. I've done it with a previous API, but now snippets have been introduced and I need to figure out how to do it.

Please bear in mind that I am a newcomer in the rust-analyzer (and also Rust) world, so I tried to implement the feature to the best of my knowledge, but the API is very new to me, so I am very welcome to introducing changes etc. 

Co-authored-by: Mikhail Rakhmanov <rakhmanov.m@gmail.com>
2020-06-08 16:28:48 +00:00
bors[bot]
38ac331f7d
Merge #4784
4784: Change management of test cfg to better support json projects r=Nashenas88 a=Nashenas88

This helps support json projects where they can decide whether to add the `test` cfg or not. One alternative is to add support for marking json project crates as a sysroot crate, and adding logic to remove the `test` cfg in those cases. In my opinion, that option gives less flexibility to json projects and leads to more functionality that needs to be maintained.

Fixes #4508 
cc @woody77 

Co-authored-by: Paul Daniel Faria <Nashenas88@users.noreply.github.com>
Co-authored-by: Paul Daniel Faria <nashenas88@users.noreply.github.com>
2020-06-08 16:20:45 +00:00
Paul Daniel Faria
dbceaf522b Use Option<&str> for target instead of Option<&String> 2020-06-08 12:10:23 -04:00
Paul Daniel Faria
9c35f135b9 Remove default_cfg_options, pass target instead so it can be used for building cargo workspaces 2020-06-08 10:23:29 -04:00
Aleksey Kladov
3b4d000250 Better unsafe highlihgting tests 2020-06-08 15:23:03 +02:00
Aleksey Kladov
c476f71bdf Highlight only the unsafe operator itself 2020-06-08 15:03:14 +02:00
bors[bot]
83fd0fb355
Merge #4775
4775: Add goto def for enum variant field r=matklad a=unexge

Closes #4764. I'm not familiar with ra codebase, there might be better ways to do that 😄 

Co-authored-by: unexge <unexge@gmail.com>
2020-06-08 12:46:12 +00:00
unexge
48b6dd0b33 Use explicit match for extracting def from classify_name 2020-06-08 15:38:10 +03:00
unexge
4edf736eb2 Swap into_definition and definition semantics for FieldShorthand variant 2020-06-08 15:37:12 +03:00
bors[bot]
db36a25839
Merge #4683
4683: Implement syntax highlighting for doctests r=ltentrup a=ltentrup

The implementation is more complicated than the previous injection logic as the doctest comments consist of multiple ranges. The implementation extracts the doctests together with an offset-mapping, applies the syntax highlighting, and updates the text ranges.

<img width="478" alt="Bildschirmfoto 2020-06-01 um 15 45 25" src="https://user-images.githubusercontent.com/201808/83415249-1f0b5800-a41f-11ea-8fa6-c282434d6ff7.png">

Part of #4170.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-08 12:26:33 +00:00
Leander Tentrup
4a2efb2f42 Implement syntax highlighting for doctests 2020-06-08 14:18:16 +02:00
unexge
c5d5d21858 Add FieldShorthand variant to NameClass 2020-06-08 14:46:58 +03:00
bors[bot]
6e4fca5882
Merge #4773
4773: Run|Debug hover actions. r=matklad a=vsrs

![hover_actions_run](https://user-images.githubusercontent.com/62505555/83335644-dfc1f780-a2b6-11ea-820b-ccaa82290e7d.gif)

This hover actions work exactly like corresponding lenses.

Co-authored-by: vsrs <vit@conrlab.com>
2020-06-08 11:29:35 +00:00
vsrs
b7db9f058a Apply suggestions from code review 2020-06-08 14:19:40 +03:00
bors[bot]
d8552d114c
Merge #4781
4781: Remove redundancy in syntax highlighting tests r=matklad a=ltentrup

Follow up from #4683. Improves syntax highlighting testing by introducing a function that contains the boilerplate comparison code. Keeps the `ra_fixture` argument in the first position, thus, the editor syntax highlighting injection still works.

Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
2020-06-08 09:48:38 +00:00
bors[bot]
bb0d4600ff
Merge #4770
4770: Clean up handling of int/float literal types r=matklad a=flodiebold

'Unknown' int/float types actually never exist as such, they get replaced by type variables immediately. So the whole `Uncertain<IntTy>` thing was unnecessary and just led to a bunch of match branches that were never hit.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-06-08 09:37:37 +00:00
Leander Tentrup
3aaaf924cb Fix bug in lexer for format specifier where the type and width were not correctly distinguished 2020-06-07 22:57:24 +02:00
Paul Daniel Faria
3937b225e7 Change management of test cfg to better support json projects 2020-06-07 10:29:03 -04:00
Leander Tentrup
65943c0585 Remove redundancy in syntax highlighting tests 2020-06-07 14:50:02 +02:00
unexge
73684a4ae2 Add goto def for enum variant field 2020-06-06 22:16:59 +03:00
vsrs
9b4256dc4d Add lib target filtering. 2020-06-06 22:11:17 +03:00
vsrs
46084f8a96 Disable runnables lookup in macro-generated code. 2020-06-06 20:10:36 +03:00
Florian Diebold
d66daee849 Clean up handling of int/float literal types
'Unknown' int/float types actually never exist as such, they get replaced by
type variables immediately. So the whole `Uncertain<IntTy>` thing was
unnecessary and just led to a bunch of match branches that were never hit.
2020-06-06 17:52:00 +02:00
vsrs
3434f1dd2c Add Run|Debug hover actions 2020-06-06 18:17:52 +03:00
vsrs
de74c0dcab Preliminary runnables refactoring 2020-06-06 18:17:52 +03:00
Florian Diebold
a4a4a1854e Fix type parameter defaults
They should not be applied in expression or pattern contexts, unless there are
other explicitly given type args.
2020-06-05 20:09:13 +02:00
bors[bot]
02f7b5d7ab
Merge #4761
4761: Upgrade Chalk to published version r=matklad a=flodiebold

CC @pksunkara 

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-05 16:05:06 +00:00
bors[bot]
2a3ab7f3b4
Merge #4689
4689: Implement return position impl trait / opaque type support r=matklad a=flodiebold

This is working, but I'm not that happy with how the lowering works. We might need an additional representation between `TypeRef` and `Ty` where names are resolved and `impl Trait` bounds are separated out, but things like inference variables don't exist and `impl Trait` is always represented the same way.

Also note that this doesn't implement correct handling of RPIT *inside* the function (which involves turning the `impl Trait`s into variables and creating obligations for them). That intermediate representation might help there as well.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
2020-06-05 15:46:28 +00:00
Florian Diebold
0d2328f3ea Review fixes 2020-06-05 17:41:58 +02:00
bors[bot]
f133159ec0
Merge #4760
4760: Minimize FileLoader interface r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-05 15:23:22 +00:00
Aleksey Kladov
bbb40d7463 Minimize FileLoader interface 2020-06-05 17:22:56 +02:00
bors[bot]
4029628f15
Merge #4729 #4748
4729: Hover actions r=matklad a=vsrs

This PR adds a `hoverActions` LSP extension and a `Go to Implementations` action as an example:
![hover_actions_impl](https://user-images.githubusercontent.com/62505555/83335732-6d9de280-a2b7-11ea-8cc3-75253d062fe0.gif)



4748: Add an `ImportMap` and use it to resolve item paths in `find_path` r=matklad a=jonas-schievink

Removes the "go faster" queries I added in https://github.com/rust-analyzer/rust-analyzer/pull/4501 and https://github.com/rust-analyzer/rust-analyzer/pull/4506. I've checked this PR on the rustc code base and the assists are still fast.

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

Note that this does introduce a change in behavior: We now always refer to items defined in external crates using paths through the external crate. Previously we could also use a local path (if for example the extern crate was reexported locally), as seen in the changed test. If that is undesired I can fix that, but the test didn't say why the previous behavior would be preferable.

Co-authored-by: vsrs <vit@conrlab.com>
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2020-06-05 15:14:35 +00:00
Florian Diebold
02962b374e Implement return position impl trait / opaque type support
This is working, but I'm not that happy with how the lowering works. We might
need an additional representation between `TypeRef` and `Ty` where names are
resolved and `impl Trait` bounds are separated out, but things like inference
variables don't exist and `impl Trait` is always represented the same
way.

Also note that this doesn't implement correct handling of RPIT *inside* the
function (which involves turning the `impl Trait`s into variables and creating
obligations for them). That intermediate representation might help there as
well.
2020-06-05 17:08:27 +02:00
Florian Diebold
69854f7795 Upgrade Chalk to published version 2020-06-05 17:06:07 +02:00
Aleksey Kladov
c9a41bd92d Actually test include!(concant!(env!()));
It triggered index-based goto definition before :-(
2020-06-05 15:49:12 +02:00
Aleksey Kladov
cb9d9040f7 Cleanup test 2020-06-05 15:14:47 +02:00
Aleksey Kladov
bba374bab2 More direct signature for resolve_path 2020-06-05 15:07:30 +02:00
Aleksey Kladov
e63c00f100 Rename resolve_relative_path -> resolve_path
For things like `concant!(env!("OUT_DIR"))`, we need to support abs paths
2020-06-05 14:58:30 +02:00
vsrs
bd9d7b6ad8 Remove hover actions heavy tests. 2020-06-05 15:26:46 +03:00
vsrs
78c9223b7b Remove hover contents marking as trusted.
Hover contents might be extracted from raw
doc comments and need some validation.
2020-06-05 15:25:01 +03:00
Jonas Schievink
bc2d172995 Clarify when we visit modules multiple times 2020-06-05 14:24:51 +02:00
vsrs
0fe43a124b Add capabilities tests. 2020-06-05 15:00:31 +03:00
vsrs
e35418ceb9 Apply suggestions from @kjeremy review 2020-06-05 15:00:31 +03:00
vsrs
92cfc0f2a1 Add enum hover action test. 2020-06-05 15:00:31 +03:00
vsrs
5d0c1aa162 Rebase on the latest master. 2020-06-05 15:00:30 +03:00
vsrs
b147e6eb95 Code formatting 2020-06-05 15:00:30 +03:00
vsrs
7d0dd17b09 Add hover actions as LSP extension 2020-06-05 14:59:26 +03:00
Aleksey Kladov
522d24a607 Inlay Hints: more directly account for self param 2020-06-05 13:58:52 +02:00
Jonas Schievink
2fb3d87bf7 impl Debug for ImportMap 2020-06-05 13:36:19 +02:00
Mikhail Rakhmanov
5dda995538 Fix review comments 2020-06-05 13:17:17 +02:00
Jonas Schievink
8395396782 Reorder imports 2020-06-05 13:15:16 +02:00
Jonas Schievink
5f23f8ca44 Make find_path_inner private again 2020-06-05 13:11:53 +02:00
Jonas Schievink
f085e592fe Measure memory usage of ImportMap 2020-06-05 13:10:43 +02:00
Jonas Schievink
86fbd8cc2b defining_crate -> krate 2020-06-05 13:05:19 +02:00
Jonas Schievink
e0e9c6d1a4 Fix wrong comment 2020-06-05 13:04:35 +02:00
Mikhail Rakhmanov
74c3e7a1ad Remove unnecessary return 2020-06-05 11:45:41 +02:00
bors[bot]
913a623281
Merge #4750
4750: introduce_named_lifetime assist wasn't applicable when type parameter r=matklad a=jbalint

followed anonymous lifetime token

(fixes #4684)

Co-authored-by: Jess Balint <jbalint@gmail.com>
2020-06-05 07:56:11 +00:00
Jess Balint
921306757b introduce_named_lifetime assist wasn't applicable when type parameter
followed anonymous lifetime token

(fixes #4684)
2020-06-04 17:31:21 -05:00
bors[bot]
e66c7b3a45
Merge #4737
4737: Parse default unsafe & default const r=matklad a=Avi-D-coder

Closes: #4718 #4264

Co-authored-by: Avi Dessauer <avi.the.coder@gmail.com>
2020-06-04 17:51:03 +00:00
Jonas Schievink
3c496f7fa7 Use ImportMap in find_path, remove old queries 2020-06-04 19:33:01 +02:00
Jonas Schievink
d08c63cb9e Add an ImportMap 2020-06-04 19:33:01 +02:00
Avi Dessauer
c4fd463981 Move default const test out of line 2020-06-04 13:06:57 -04:00
Avi Dessauer
3ec2dcfc0d Address review 2020-06-04 13:00:21 -04:00
bors[bot]
c19496f845
Merge #4740
4740: Remove unneeded "./" prefix affecting error messages r=kjeremy a=dtolnay

I noticed this in the error in the commit message of https://github.com/rust-analyzer/rust-analyzer/pull/4739.

Before:

```console
error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

After:

```console
error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

```diff
-   --> crates/rust-analyzer/./src/bin/main.rs:99:16
+   --> crates/rust-analyzer/src/bin/main.rs:99:16
```

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-04 13:04:24 +00:00
bors[bot]
a1ca1e7598
Merge #4739
4739: Declare required lsp-server dependency of rust-analyzer crate r=jonas-schievink a=dtolnay

My codebase already depended on lsp-server and introducing a dependency on rust-analyzer failed at first because it assumes some functions that were first present in lsp-server 0.3.2.

Without this change:

```console
error[E0599]: no method named `initialize_start` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:83:57
   |
83 |     let (initialize_id, initialize_params) = connection.initialize_start()?;
   |                                                         ^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`

error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
  --> crates/rust-analyzer/./src/bin/main.rs:99:16
   |
99 |     connection.initialize_finish(initialize_id, initialize_result)?;
   |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
```

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-06-04 10:45:06 +00:00
Mikhail Rakhmanov
b0c8a2be7b Remove AsName import 2020-06-04 10:03:44 +02:00
David Tolnay
4461796f33
Fix type inference failure when built with log/kv_unstable
This code is broken by an `impl From<kv::Error> for fmt::Error` in the
log crate when building in a codebase that has the log/kv_unstable
feature enabled.

    $ cargo check --manifest-path crates/ra_hir_def/Cargo.toml
        Checking ra_hir_def v0.1.0
        Finished dev [unoptimized] target(s) in 0.75s

    $ cargo check --manifest-path crates/ra_hir_def/Cargo.toml --features log/kv_unstable
        Checking ra_hir_def v0.1.0
    error[E0282]: type annotations needed for the closure `fn(&str) -> std::result::Result<(), _>`
       --> crates/ra_hir_def/src/path.rs:278:17
        |
    278 |                 f.write_str("::")?;
        |                 ^^^^^^^^^^^^^^^^^^ cannot infer type
        |
    help: give this closure an explicit return type without `_` placeholders
        |
    276 |         let mut add_segment = |s| -> std::result::Result<(), _> {
        |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020-06-03 19:06:02 -07:00
David Tolnay
7348040944
Remove unneeded "./" prefix affecting error messages
Before:

    error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
      --> crates/rust-analyzer/./src/bin/main.rs:99:16
       |
    99 |     connection.initialize_finish(initialize_id, initialize_result)?;
       |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`

After:

    error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
      --> crates/rust-analyzer/src/bin/main.rs:99:16
       |
    99 |     connection.initialize_finish(initialize_id, initialize_result)?;
       |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
2020-06-03 18:02:09 -07:00
David Tolnay
19b27f2ec9
Declare required lsp-server dependency of rust-analyzer crate
My codebase already depended on lsp-server and introducing a dependency
on rust-analyzer failed at first because it assumes some functions that
were first present in lsp-server 0.3.2.

Without this change:

    error[E0599]: no method named `initialize_start` found for struct `lsp_server::Connection` in the current scope
      --> crates/rust-analyzer/./src/bin/main.rs:83:57
       |
    83 |     let (initialize_id, initialize_params) = connection.initialize_start()?;
       |                                                         ^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`

    error[E0599]: no method named `initialize_finish` found for struct `lsp_server::Connection` in the current scope
      --> crates/rust-analyzer/./src/bin/main.rs:99:16
       |
    99 |     connection.initialize_finish(initialize_id, initialize_result)?;
       |                ^^^^^^^^^^^^^^^^^ method not found in `lsp_server::Connection`
2020-06-03 17:55:48 -07:00
Avi Dessauer
a5588b9e19 Update tests 2020-06-03 20:39:57 -04:00
Avi Dessauer
fb632c747d Parse default unsafe & default const 2020-06-03 20:16:38 -04:00
Mikhail Rakhmanov
a6d3c77bdd Fixed tests 2020-06-03 20:43:57 +02:00
Mikhail Rakhmanov
eefa10bc6b Merge branch 'master' into assists_extract_enum 2020-06-03 20:10:54 +02:00
Mikhail Rakhmanov
a9d5675848 Fix incorrect behaviour if not resolved 2020-06-03 20:10:33 +02:00
Mikhail Rakhmanov
6cd2e04bd2 Fix more comments 2020-06-03 19:33:57 +02:00
Mikhail Rakhmanov
6a0083a519 Merge branch 'master' into compute-lazy-assits
# Conflicts:
#	crates/rust-analyzer/src/main_loop/handlers.rs
#	crates/rust-analyzer/src/to_proto.rs
2020-06-03 19:26:01 +02:00
Mikhail Rakhmanov
bacd0428fa Fix review comments 2020-06-03 18:39:01 +02:00
bors[bot]
a33cfcb55d
Merge #4502
4502: Mark fixes from diagnostics as quick fixes r=kjeremy a=kjeremy

Populates the diagnostic UI with fixes:

Before: 
![quickfix-before](https://user-images.githubusercontent.com/4325700/82165183-0e38df00-9882-11ea-96cf-7dab5faec4d4.PNG)

After:
![image](https://user-images.githubusercontent.com/4325700/82165193-1a24a100-9882-11ea-97d7-be1b64b135e0.png)


Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-06-03 13:39:30 +00:00
Jeremy Kolb
9e71fc0314 Mark fixes from diagnostics as quick fixes 2020-06-03 09:31:32 -04:00
bors[bot]
1edf6d2d4f
Merge #4730
4730: Document rust-project.json r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-03 13:18:12 +00:00
Aleksey Kladov
fa019c8f56 Document rust-project.json 2020-06-03 15:17:26 +02:00
bors[bot]
e644f64f2a
Merge #4678
4678: Unsquish parameter types in tooltips for macro-generated functions r=aloucks a=aloucks

Note the missing whitespace between `:` and the parameter type.

Before:
![image](https://user-images.githubusercontent.com/221559/83364680-faf13d80-a370-11ea-96b7-a041969a4954.png)

After:
![image](https://user-images.githubusercontent.com/221559/83364685-03e20f00-a371-11ea-9668-4e6ebcb81947.png)


Co-authored-by: Aaron Loucks <aloucks@cofront.net>
2020-06-03 11:27:10 +00:00
Aaron Loucks
f06b2bcd91 Use split1 when formatting function signature params 2020-06-03 07:26:15 -04:00
bors[bot]
c6b739bad0
Merge #4660
4660: Enable hover and autocomplete docs on macro generated items r=aloucks a=aloucks

Enable hover and autocomplete docs on macro generated items. This de-sugars doc comments into `doc` attributes in some cases, but not all. Comments and `doc` attributes are then merged together. 

This PR is essentially a partial implementation of what's being suggested #3182, but it's not all the way there yet. ~I still need to add unit tests~, but I wanted to first get feedback on whether or not this was an acceptable path forward.

Fixes #4564
Fixes #3984
Fixes #3180
Related #3182

![macro_item_docs](https://user-images.githubusercontent.com/221559/83336760-15012200-a284-11ea-8d0d-b6a615850044.gif)



Co-authored-by: Aaron Loucks <aloucks@cofront.net>
2020-06-03 11:05:52 +00:00
Aaron Loucks
85c4edb0af Consolidate documentation expansion and merging
Removes the duplicated `expand_doc_attrs` and `merge_doc_comments_and_attrs`
functions from `ra_ide` and exposes the same functionality via
`ra_hir::Documentation::from_ast`.
2020-06-03 06:54:41 -04:00
Aaron Loucks
5837acce53 Add basic hover and completion doc tests for macro generated items 2020-06-03 06:46:07 -04:00
Aaron Loucks
4c655c01f3 Enable hover and autocomplete docs on macro generated items 2020-06-03 06:46:07 -04:00
Aleksey Kladov
2e7d12d2f3 Drop test for old format 2020-06-03 12:39:11 +02:00
Aleksey Kladov
8baa4c5d07 Groundwork for specifying the set of projects via config 2020-06-03 12:22:01 +02:00
Aleksey Kladov
03a76191a1 Rename ProjectRoot -> ProjectManifest 2020-06-03 12:05:50 +02:00
Aleksey Kladov
0a88de809f Move project discovery 2020-06-03 12:04:27 +02:00
Aleksey Kladov
a87cd8ecc6 Rename WorldState -> GlobalState 2020-06-03 11:20:01 +02:00
Aleksey Kladov
ee181cf683 Drop no-project test
Eventually, we should support "just open random rust file" use case,
we don't really do this now, so let's avoid spending time on it until
we fix it properly.
2020-06-03 11:07:04 +02:00
Aleksey Kladov
d4b21476a8 Derive local roots from Workspaces 2020-06-03 10:52:35 +02:00
Aleksey Kladov
ca80544f4b Put important things on top 2020-06-03 10:33:01 +02:00
Aleksey Kladov
ac4782ef11
Merge pull request #4382 from woody77/json_cfgs
Begin transition to new fields for JsonProject crate cfgs
2020-06-03 10:28:15 +02:00
bors[bot]
68f26dc1bb
Merge #4679
4679: Update a comment for the new source organization r=matklad a=nelhage



Co-authored-by: Nelson Elhage <nelhage@nelhage.com>
2020-06-03 06:47:18 +00:00
bors[bot]
6d38351db4
Merge #4721
4721: Hide squiggly for unused and unnecessary diagnostics r=matklad a=GabbeV

Fixes #4229 

When working with JavaScript or TypeScript in VSCode unused valiables are faded but don't have a squiggle. This PR makes rust-analyzer work similarly by setting the severity to hint when applying the unnecessary tag.

VSCode usually shows a squiggle for error, warning and information and shows three dots for hint. When the unnecessary tag is present the squiggles will still show up but the three dots will not.

This is my first contribution to open source. Please tell me if i need to do anything more to get this PR considered.

Co-authored-by: Gabriel Valfridsson <gabriel.valfridsson@gmail.com>
2020-06-03 06:16:45 +00:00
Gabriel Valfridsson
599c105e6f Hide squiggly for unused and unnecessary 2020-06-03 01:57:28 +02:00
Paul Daniel Faria
a9cb2933fb Add highlight support for unsafe fn calls and raw ptr deref 2020-06-02 18:54:00 -04:00
Mikhail Rakhmanov
cb482e6351 Merge remote-tracking branch 'upstream/master' into compute-lazy-assits
# Conflicts:
#	crates/rust-analyzer/src/to_proto.rs
2020-06-02 23:22:45 +02:00
Mikhail Rakhmanov
57cd936c52 Preliminary implementation of lazy CodeAssits 2020-06-02 23:10:53 +02:00
bors[bot]
2f6ab77708
Merge #4710
4710: New runnables r=matklad a=matklad

bors d=@vsrs

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-06-02 20:44:56 +00:00
bors[bot]
0035dafbfa
Merge #4711
4711: Disable rust-analyzer.{cargo,checkOnSave}.allFeatures by default r=matklad a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-06-02 16:16:38 +00:00
Laurențiu Nicola
7a66d99897 Disable rust-analyzer.{cargo,checkOnSave}.allFeatures by default 2020-06-02 19:14:34 +03:00
Aleksey Kladov
bc3db7c1de Fix tests 2020-06-02 18:09:12 +02:00
Aleksey Kladov
a83ab820a4 Spec better runnables 2020-06-02 17:34:18 +02:00
Aleksey Kladov
0303982119 New runnables API 2020-06-02 17:22:42 +02:00
Aleksey Kladov
31f282636b Minor 2020-06-02 16:30:47 +02:00
bors[bot]
fe6508bd78
Merge #4658
4658: Fix problem with format string tokenization r=matklad a=ruabmbua

Fixed by just not handling closing curlybrace escaping.

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

Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
2020-06-02 12:13:02 +00:00
bors[bot]
131ccd9540
Merge #4580
4580: Fix invoking cargo without consulting CARGO env var or standard installation paths r=matklad a=Veetaha

Followup for #4329

The pr essentially fixes [this bug](https://youtu.be/EzQ7YIIo1rY?t=2189)

cc @lefticus

Co-authored-by: veetaha <veetaha2@gmail.com>
2020-06-02 11:58:28 +00:00
veetaha
fb971c3bce Simplify 2020-06-02 02:50:05 +03:00
Mikhail Rakhmanov
b4af02d110 Add top level keywords completion 2020-06-02 01:29:54 +02:00