Commit Graph

3274 Commits

Author SHA1 Message Date
Aleksey Kladov
e4646ce0d5 reduce visibility 2019-03-26 13:53:50 +03:00
Aleksey Kladov
5270bca5f7 store macro def inside macro id
This solves the problem of "macro expansion can't call into name
resolution, because name resolution calls back into macro expansion"

Because we store macro def as a part of call id, macro expansion just
knows the def!
2019-03-26 13:20:54 +03:00
bors[bot]
dc94f36125 Merge #1040
1040: Trait beginnings r=matklad a=flodiebold

This adds some very simple trait method resolution, going through traits in scope, looking for methods of the given name, and checking very naively whether there's an impl for the given type and trait.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2019-03-25 21:00:16 +00:00
Florian Diebold
99711c1863 Clean up comments / use nicer Iterator methods 2019-03-25 21:28:36 +01:00
Florian Diebold
0f7e4a7d24 Implement a very naive implements check
... to make the infer_trait_method_simple test have the correct result.
2019-03-25 21:28:36 +01:00
Florian Diebold
c947c15ce1 Basics for trait method resolution 2019-03-25 21:28:36 +01:00
bors[bot]
bb77bc5c2f Merge #1049
1049: Add description & example for inlining local variable r=matklad a=gfreezy



Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-03-25 19:46:40 +00:00
gfreezy
8cb3041a0c markdown syntax 2019-03-25 23:15:52 +08:00
gfreezy
2ca1b2bc8f add desc and examples for inline variable action 2019-03-25 23:14:30 +08:00
bors[bot]
d88a96bd05 Merge #1037
1037: inline immutable local varialbe r=matklad a=gfreezy

resolved #1033 

Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-03-25 14:11:18 +00:00
gfreezy
61315e4a89 use | instead of multiple match arms 2019-03-25 20:57:43 +08:00
bors[bot]
c4ead49361 Merge #1034
1034: HIR diagnostics API r=matklad a=matklad

This PR introduces diagnostics API for HIR, so we can now start issuing errors and warnings! Here are requirements that this solution aims to fulfill:

* structured diagnostics: rather than immediately rendering error to string, we provide a well-typed blob of data with error-description. These data is used by IDE to provide fixes
* open set diagnostics: there's no single enum with all possible diagnostics, which hopefully should result in better modularity

The `Diagnostic` trait describes "a diagnostic", which can be downcast to a specific diagnostic kind. Diagnostics are expressed in terms of macro-expanded syntax tree: they store pointers to syntax nodes. Diagnostics are self-contained: you don't need any context, besides `db`, to fully understand the meaning of a diagnostic. 

Because diagnostics are tied to the source, we can't store them in salsa. So subsystems like type-checking produce subsystem-local diagnostic (which is a closed `enum`), which is expressed in therms of subsystem IR. A separate step converts these proto-diagnostics into `Diagnostic`, by merging them with source-maps.

Note that this PR stresses type-system quite a bit: we now type-check every function in open files to compute errors!

Discussion on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Diagnostics.20API

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 11:38:46 +00:00
Aleksey Kladov
309716cffe move tests to where they belong 2019-03-25 14:29:24 +03:00
bors[bot]
8aedf9603d Merge #1047
1047: ⬆️ deps r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 11:12:26 +00:00
Aleksey Kladov
65a5c6859f ⬆️ deps 2019-03-25 14:12:03 +03:00
bors[bot]
958df1276e Merge #1019
1019: structure moved to ra_ide_api r=matklad a=pasa

structure subtask for #1009 

Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
2019-03-25 09:02:54 +00:00
Sergey Parilin
36cb58f76d structure moved to ra_ide_api
ra_ide_api_light removed completely
2019-03-25 11:41:21 +03:00
bors[bot]
afe96b75ea Merge #1045
1045: simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 08:00:10 +00:00
Aleksey Kladov
6c4b06e2e3 simplify 2019-03-25 10:59:42 +03:00
Aleksey Kladov
e9af69d9db simplify 2019-03-25 10:56:55 +03:00
Aleksey Kladov
5ce84f3cbc tweak diagnostics API 2019-03-25 10:52:50 +03:00
Aleksey Kladov
4c4a714328 test diagnostics 2019-03-25 10:52:50 +03:00
Aleksey Kladov
c7ffd939f6 more enterprisey diagnostics setup 2019-03-25 10:52:50 +03:00
Aleksey Kladov
7ee2887d1e fixes 2019-03-25 10:52:50 +03:00
Aleksey Kladov
45fbab2b1a check impls as well 2019-03-25 10:52:50 +03:00
Aleksey Kladov
79df62bc74 cleanup 2019-03-25 10:52:50 +03:00
Aleksey Kladov
3fb88e95aa switch modules to new diagnostics 2019-03-25 10:52:50 +03:00
Aleksey Kladov
fcca35969d allow dyn diagnostics 2019-03-25 10:52:12 +03:00
Aleksey Kladov
7e8f17188e diagnostics 2019-03-25 10:52:12 +03:00
bors[bot]
6f995f47ea Merge #1044
1044: fix build r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 07:49:50 +00:00
Aleksey Kladov
77fb6354c3 fix build 2019-03-25 10:48:24 +03:00
bors[bot]
4132fbf3a0 Merge #1041
1041: Add convenience functions to SourceChange for creating single edits r=matklad a=vipentti

Fixes #1018 

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-03-25 07:42:30 +00:00
bors[bot]
8fd18fddea Merge #1043
1043: link docs from dev docs, not from the main readme r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 07:29:06 +00:00
Aleksey Kladov
b92a5222af link docs from dev docs, not from the main readme
If you want to **use** ra, you don't need api docs
2019-03-25 10:27:43 +03:00
bors[bot]
d0d644b8c4 Merge #1042
1042: Remove windows from CI r=matklad a=matklad

We don't actually look at the CI results for windows anyway!

In general, rust-analyzer should be written in a completely
OS-independent way. That is, testing on one OS should be enough. If
this is not the case, that means something is seriously broken.

No doubt there are components which actually talk to the outside
world, and they may be platform dependent. We should extract such
components to a separate repo with an extensive multi platform CI,
like we did for VFS

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-03-25 07:17:57 +00:00
Ville Penttinen
4d26bae46d Rename source_edit to source_file_edit to match file_system_edit 2019-03-25 09:13:58 +02:00
Aleksey Kladov
db9a3cbfb9 Remove windows from CI
We don't actually look at the CI results for windows anyway!

In general, rust-analyzer should be written in a completely
OS-independent way. That is, testing on one OS should be enough. If
this is not the case, that means something is seriously broken.

No doubt there are components which actually talk to the outside
world, and they may be platform dependent. We should extract such
components to a separate repo with an extensive multi platform CI,
like we did for VFS
2019-03-25 10:13:44 +03:00
bors[bot]
965363db15 Merge #1036
1036: Assist to flip equality (==) and negated equality (!=) operands. r=matklad a=marcogroppo

This PR adds an assist to flip the equality operands.

I hope this is the right way to do this (I'm a newbie...)

Fixes #1023.


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-03-25 07:04:47 +00:00
Ville Penttinen
b92fcbc956 Further improvements to the SourceChange convenience methods
Rename system_edit to file_system_edit, add more documentation, add
source_file_edit_from to create a SourceChange from `FileId` and `TextEdit`.
2019-03-25 09:03:10 +02:00
bors[bot]
219b157337 Merge #1035
1035: Add master branch docs build and publish r=matklad a=robojumper

Closes #1024.

Additional setup required: 

* The rust-analyzer travis repo needs an [environment variable](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings) `DOCS_TOKEN` that will be used to publish docs to the `gh-pages` branch. This is a GitHub access token with the appropriate permissions to push to this repository. Travis will keep this a secret.
* In the GitHub repository settings, the GitHub pages source needs to be set to the `gh-pages` branch. This option will only appear once a branch is created with this exact name -- created either through the `deploy` step or manually.
* In the GitHub repository settings, a GitHub pages theme will need to be chosen. What theme to use is unimportant, but [you must choose a theme](https://github.community/t5/GitHub-Pages/Github-Pages-are-not-published-after-following-the-documentation/m-p/18676#M1398).

Docs are built as part of any rust build (on linux and windows, though all my Travis windows builds have timed out), but only published on master builds on linux.

The docs badge links to `https://rust-analyzer.github.io/rust-analyzer/ra_ide_api/index.html` -- since this project is a cargo workspace, there isn't a global index page, hence just the link to an arbitrarily chosen crate. If this project had a canonical main crate with good documentation, one could link to that. All other crates are accessible through the sidebar.

Co-authored-by: robojumper <robojumper@gmail.com>
2019-03-25 06:54:15 +00:00
gfreezy
fd1585a071 inline immutable local varialbe 2019-03-25 10:18:20 +08:00
Marco Groppo
67055c47da Target only the actual operator.
Renamed `BinExpr::op()` and `PrefixExpr::op()` to `op_kind`.
Now `op()` returns the `SyntaxNode`.
2019-03-24 22:21:22 +01:00
bors[bot]
94cf23bfc4 Merge #1029
1029: Add impl members assist shold not copy docstrings, attrs and default methods r=matklad a=gfreezy

1. `add missing impl members` assist should not copy docstrings, attrs and default methods
2. Add `add impl default members` assist

fixed #1022

Co-authored-by: gfreezy <gfreezy@gmail.com>
2019-03-24 21:04:53 +00:00
Ville Penttinen
22e1c7a112 Add convenience functions to SourceChange for creating single edits 2019-03-24 22:53:41 +02:00
bors[bot]
449eea1161 Merge #1039
1039: Support references in higher-ranked trait bounds r=matklad a=vipentti

Fixes #1020

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
2019-03-24 19:49:53 +00:00
Ville Penttinen
95505e80fc Support references in higher-ranked trait bounds
Fixes #1020
2019-03-24 20:51:55 +02:00
Marco Groppo
acac7415a6 Minor formatting changes. 2019-03-24 15:12:39 +01:00
Marco Groppo
481d3f56cf Assist to flip equality (==) and negative equality (!=) operands. 2019-03-24 14:42:11 +01:00
robojumper
022d88cf4c Add docs build 2019-03-23 22:03:41 +01:00
bors[bot]
18a8f48039 Merge #1031
1031: Move most things out of ra_ide_api_light r=matklad a=detrumi

This moves everything except `structure` out of `ra_ide_api_light`. So this PR and #1019 finish up #1009, whichever is merged last should probably remove the `ra_ide_api_light` crate.

Also, `LocalEdit` was removed since it wasn't used any more.

Co-authored-by: Wilco Kusee <wilcokusee@gmail.com>
2019-03-23 17:25:40 +00:00