Commit graph

4223 commits

Author SHA1 Message Date
Aleksey Kladov
4e415a269e Remove ns-polymorphic type_for_def 2019-11-26 21:04:24 +03:00
Edwin Cheng
447268ceac Hide MacroCallLoc 2019-11-27 01:33:08 +08:00
Aleksey Kladov
6fb4871f31 Add note 2019-11-26 19:30:57 +03:00
Aleksey Kladov
475367d08a Cleanup imports 2019-11-26 18:07:40 +03:00
Aleksey Kladov
b60b26b8ab Reduce visibility 2019-11-26 18:02:50 +03:00
Aleksey Kladov
72d8e7e69a Use TraitId in TraitRef 2019-11-26 18:01:34 +03:00
Aleksey Kladov
24b1e79af5 Remove another helper 2019-11-26 17:45:06 +03:00
Aleksey Kladov
25b32f9d68 Doc 2019-11-26 17:44:43 +03:00
Aleksey Kladov
d118997b93 Remove assoc_type_by_name helper 2019-11-26 17:44:43 +03:00
Aleksey Kladov
9bc8f1f4f8 Store names in TraitData 2019-11-26 17:44:43 +03:00
Aleksey Kladov
4a0792362e Detangle ty from traits a bit 2019-11-26 17:44:43 +03:00
bors[bot]
4d753fa6f5
Merge #2412
2412: Fix stale crates that snuck in r=kjeremy a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-11-26 13:26:23 +00:00
Jeremy Kolb
b81548c73a Fix stale crates that snuck in 2019-11-26 08:20:40 -05:00
bors[bot]
4822d26540
Merge #2406
2406: Add hygiene information to SourceAnalyzer r=matklad a=edwin0cheng

This should fix https://github.com/rust-analyzer/rust-analyzer/pull/2392#issuecomment-557964686

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-26 13:18:03 +00:00
Edwin Cheng
0623164c1d Remove dbg! 2019-11-26 21:13:36 +08:00
bors[bot]
36dca8de93
Merge #2410
2410: Introduce hir_ty r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-26 12:42:15 +00:00
Aleksey Kladov
4e17718a9a Doc primitives 2019-11-26 15:41:48 +03:00
Aleksey Kladov
45d05ed783 id-ify impls_in_crate_query 2019-11-26 15:36:25 +03:00
Jeremy Kolb
8b1f2cd14e Update parking_lot and smallvec to drop some dependencies 2019-11-26 07:29:28 -05:00
Aleksey Kladov
4c43631829 Introduce hir_ty 2019-11-26 15:06:06 +03:00
Aleksey Kladov
a443b5033c Id-ify Ty::Adt 2019-11-26 14:29:12 +03:00
Aleksey Kladov
e5eadb3390 Introduce hir::Type
It should provide a convenient API over more low-level Ty
2019-11-26 14:02:57 +03:00
Aleksey Kladov
0a7ef09331 Use chalk fork to paper over #2052 2019-11-26 11:46:09 +03:00
Aleksey Kladov
131c2da6bf ⬆️ salsa 2019-11-26 11:29:20 +03:00
Edwin Cheng
245a9b165a Add hygiene information to SourceAnalyzer 2019-11-26 15:05:53 +08:00
Aleksey Kladov
1a0da6d4da Use TypeAliasId in Ty, pt 2 2019-11-25 18:58:17 +03:00
Aleksey Kladov
6d2ec8765d Use TypeAliasId in Ty, pt 1 2019-11-25 18:44:36 +03:00
Aleksey Kladov
3e32ac4f86 More ids in Ty 2019-11-25 18:31:48 +03:00
Aleksey Kladov
1455663ea1 Fixme for union fields 2019-11-25 17:50:49 +03:00
Aleksey Kladov
5fd68b5929 Fix hir for ast::UnionDef 2019-11-25 17:50:49 +03:00
Aleksey Kladov
e1c0bdaf75 Introduce dedicated AST node for union
Although structs and unions have the same syntax and differ only in
the keyword, re-using the single syntax node for both of them leads to
confusion in practice, and propagates further down the hir in an
upleasent way.

Moreover, static and consts also share syntax, but we use different
nodes for them.
2019-11-25 17:50:49 +03:00
bors[bot]
be00d74c7b
Merge #2388
2388: Show missing struct fields in the error message r=matklad a=Frizi

This provides the most interesting information about the "missing structure fields" error directly to the user.

Co-authored-by: Frizi <frizi09@gmail.com>
2019-11-25 13:42:36 +00:00
Aleksey Kladov
78791d6fac Use ids for Callable 2019-11-25 16:26:52 +03:00
Aleksey Kladov
9047a4ad46 Use more IDs 2019-11-25 16:16:41 +03:00
Aleksey Kladov
5f39c5794e Use GenericDefIdMore 2019-11-25 15:54:03 +03:00
Aleksey Kladov
c2a16632d0 Use GenericDefId more 2019-11-25 15:39:12 +03:00
Aleksey Kladov
8c3e372835 Remove Resolver from autoderef
Resolver holds onto too much context, including local scopes. Let's
try to pass in only what is necessary -- the trait environment.
2019-11-25 13:10:26 +03:00
Aleksey Kladov
bd53bd80bf Push resolver up 2019-11-25 12:45:45 +03:00
bors[bot]
e00e6554dd
Merge #2362
2362: Expand compile_error! r=edwin0cheng a=kjeremy

Does not validate that the input is a string literal. I thought that I could `match_ast!` against the `macro_args` but that did not work. Even if it had I am not sure which error would be appropriate.

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2019-11-25 04:51:42 +00:00
bors[bot]
a888441c47
Merge #2392
2392: Fix panic during the expansion of `column!` r=edwin0cheng a=marcogroppo

Fixes #2379. Well, this isn't the "proper" fix but it doesn't hurt, IMHO.

The problem is that `to_col_number`, called by `column_expand`, receives a position number that isn't included in the text range of the file. My (very limited) understanding is that the text is the one of the original file, while `pos` is relative to something else, probably the text of the macro. Notice that in this case the `column!` expansion seems to be triggered by `assert_eq!`, so we're in the middle of another expansion. This PR simply avoids the panic by checking the length of the text.

r? @edwin0cheng 


Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-11-25 02:42:17 +00:00
Jeremy Kolb
67d3600f59 Expand compile_error! 2019-11-24 19:01:51 -05:00
Marco Groppo
ceb13a0494 Fix panic during the expansion of column! 2019-11-24 23:49:58 +01:00
bors[bot]
f7f9757b6b
Merge #2396
2396: Switch to variant-granularity field type inference r=flodiebold a=matklad

r? @flodiebold 

Previously, we had a `ty` query for each field. This PR switcthes to a query per struct, which returns an `ArenaMap` with `Ty`s. 

I don't know which approach is better. What is bugging me about the original approach is that, if we do all queries on the "leaf" defs, in practice we get a ton of queries which repeatedly reach into the parent definition to compute module, resolver, etc. This *seems* wasteful (but I don't think this is really what causes any perf problems for us). 

At the same time, I've been looking at Kotlin, and they seem to use the general pattern of analyzing the *parent* definition, and storing info about children into a `BindingContext`. 

I don't really which way is preferable. I think I want to try this approach, where query granularity generally mirrors the data granularity. The primary motivation for me here is probably just hope that we can avoid adding a ton of helpers to a `StructField`, and maybe in general avoid the need to switch to a global `StructField`, using `LocalStructFieldId` most of the time internally. 

For external API (ie, for `ra_ide_api`), I think we should continue with fine-grained `StructField::ty` approach, which internally fetches the table for the whole struct and indexes into it.

In terms of actual memory savings, the results are as follows:

```
This PR:
   142kb FieldTypesQuery (deps)
    38kb FieldTypesQuery

Status Quo:
   208kb TypeForFieldQuery (deps)
    18kb TypeForFieldQuery
```

Note how the table itself occupies more than twice as much space! I don't have an explanation for this: a plausible hypothesis is that single-field structs are very common and for them the table is a pessimisation. 

THere's noticiable wallclock time difference.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-24 21:45:26 +00:00
Aleksey Kladov
d06904e90c Switch to variant-granularity field type inference 2019-11-25 00:12:36 +03:00
Aleksey Kladov
a0e1dbb450 Implement HasModule for AdtId 2019-11-24 22:48:37 +03:00
Aleksey Kladov
586acef528 Simplify ADT fields 2019-11-24 22:44:24 +03:00
Aleksey Kladov
191b1d238f Remove impl_block module 2019-11-24 21:17:37 +03:00
Aleksey Kladov
d87c16bea6 hir_def is fully doc'ed! 2019-11-24 21:00:50 +03:00
Aleksey Kladov
e48430cbae Simplify 2019-11-24 20:53:42 +03:00
Aleksey Kladov
d157812cd1 Docs 2019-11-24 20:39:48 +03:00
Aleksey Kladov
63e3ea38d3 Don't redo field resolution in the IDE 2019-11-24 20:06:55 +03:00
Frizi
66f04e6be5 Show missing struct fields in the error message 2019-11-24 17:45:30 +01:00
bors[bot]
ac9ba5eb32
Merge #2387
2387: Simplify r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-24 16:06:58 +00:00
Aleksey Kladov
434f108ada Simplify 2019-11-24 19:01:19 +03:00
bors[bot]
b0581c2403
Merge #2381
2381: Add proc-macro crate type handling r=JasperDeSutter a=JasperDeSutter

Resolves the libproc_macro crate in crates that are the proc-macro type.
This doesn't seem the ideal implementation though, since the compiler still requires you to write `extern crate proc_macro;` (even in 2018 edition).

Co-authored-by: JasperDeSutter <jasper.desutter@gmail.com>
2019-11-24 15:59:47 +00:00
JasperDeSutter
6a8b4f873a add proc-macro crate type handling 2019-11-24 16:55:56 +01:00
Aleksey Kladov
f5e0a31eaf Cleanup nameres 2019-11-24 18:05:12 +03:00
Aleksey Kladov
855a629b14 Use Trace in raw_items 2019-11-24 17:49:49 +03:00
Aleksey Kladov
21cfa6d529 Some docs 2019-11-24 17:36:06 +03:00
Aleksey Kladov
99af523b68 Cleanup 2019-11-24 17:36:06 +03:00
Aleksey Kladov
326f066aa2 Reduce visibility 2019-11-24 17:36:06 +03:00
bors[bot]
5cc634fa60
Merge #2383
2383: Add alloc to the crate graph r=matklad a=marcogroppo

`alloc` has been added to the crate graph.

Completions work, but they are available even when the user has **not** declared an `extern crate alloc`. Is this the correct approach?

Fixes #2376.

Co-authored-by: Marco Groppo <marco.groppo@gmail.com>
2019-11-24 13:26:54 +00:00
Aleksey Kladov
4b74fb1d89 Nicer API for attrs 2019-11-24 16:03:02 +03:00
Aleksey Kladov
1956d57ed4 Slightly reduce code duplication 2019-11-24 15:50:45 +03:00
Aleksey Kladov
8e36cb5860 Simplify 2019-11-24 15:28:45 +03:00
Aleksey Kladov
151180057b Simplify 2019-11-24 15:20:59 +03:00
Marco Groppo
e3f8e7d13d Add alloc to the sysroot 2019-11-24 13:19:47 +01:00
Aleksey Kladov
e0b06cb672 Switch to StaticLoc for statics 2019-11-24 15:18:12 +03:00
Aleksey Kladov
9c766db5ff Remove ids module 2019-11-24 14:25:48 +03:00
Aleksey Kladov
53506a7552 Pull macro up 2019-11-24 14:13:51 +03:00
Aleksey Kladov
f11237561c Cleanup imports 2019-11-24 14:02:08 +03:00
Aleksey Kladov
cfffea6dc8 Push poison_macros down 2019-11-24 13:57:45 +03:00
Aleksey Kladov
f0e0a40a61 Reduce visbility 2019-11-24 13:34:27 +03:00
bors[bot]
ea3124c12a
Merge #2378
2378: Fix panic in batch analysis r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-24 09:12:12 +00:00
Aleksey Kladov
730664f646 Fix panic in batch analysis
Closes #2272
2019-11-24 12:06:00 +03:00
bors[bot]
cf47ea2877
Merge #2365
2365: Make expand-macro more flexible r=matklad a=edwin0cheng

Due to lack of implementation or other types of errors, some macros do not expand correctly in the current situation. The PR attempts to make `expand-macro` more flexible in error situations by ignoring internal failed macro expansion.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-24 08:39:29 +00:00
bors[bot]
7b6aa7c34e
Merge #2343
2343: implement assist invert_if r=matklad a=bravomikekilo

fix [issue 2219 invert if condition](https://github.com/rust-analyzer/rust-analyzer/issues/2219)
I put the assist cursor range to `if` of the if expression, because both condition and body will be replaced. Is there any way to replace them without cover the cursor position?
@matklad 

Co-authored-by: bravomikekilo <bmk1221@126.com>
2019-11-24 08:32:07 +00:00
bors[bot]
f2c36e5a6f
Merge #2360
2360: Refactor builtin macro r=matklad a=edwin0cheng

Refactor builtin macro and add some local tests.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-24 08:17:02 +00:00
bravomikekilo
adac4fc2f2 do refact and fix some issue 2019-11-24 13:14:57 +08:00
Edwin Cheng
16854e28ef Use macro for all the things 2019-11-23 22:48:34 +08:00
Aleksey Kladov
ffc2325d19 Move ModuleSource back to hir 2019-11-23 17:12:49 +03:00
Aleksey Kladov
6bdd5fa461 Privatise nameres 2019-11-23 17:12:49 +03:00
Aleksey Kladov
158b1cb524 Rename CrateModuleId 2019-11-23 17:12:49 +03:00
Edwin Cheng
6940ae9eab Rename BuiltinExpander to BuiltinFnLikeExpander 2019-11-23 21:54:39 +08:00
Aleksey Kladov
dd5c2dc5bf Move ImportId 2019-11-23 16:49:05 +03:00
Aleksey Kladov
338ff052c2 Simplify HasSource 2019-11-23 16:41:04 +03:00
Aleksey Kladov
e5bcb69e4f Hide ImportId 2019-11-23 16:39:53 +03:00
Aleksey Kladov
3bdb034906 Remove unneded supertrait 2019-11-23 16:30:14 +03:00
Aleksey Kladov
6ec0b181c0 Cleanup imports 2019-11-23 15:48:45 +03:00
Aleksey Kladov
8efc41e7f2 Cleanup imports 2019-11-23 15:33:21 +03:00
Aleksey Kladov
32658a73b4 Note that debugging infra is broken 2019-11-23 14:49:45 +03:00
Aleksey Kladov
fc1e543f7a Get rid of DefDatabase2 2019-11-23 14:49:45 +03:00
Aleksey Kladov
958862093e Move docs to hir_def 2019-11-23 14:43:38 +03:00
Aleksey Kladov
8692977d27 Move lang_items to hir_def 2019-11-23 12:58:01 +03:00
Aleksey Kladov
1a99864963 Use attrs rather than syntax for lang items 2019-11-23 12:01:56 +03:00
Aleksey Kladov
552ba868af Move attrs query to hir_def 2019-11-23 11:14:40 +03:00
Edwin Cheng
9c521f00ff Improve fail case in expand_macro 2019-11-23 10:33:14 +08:00
Aleksey Kladov
0f415dd4b3 More principled sources for enums and fields 2019-11-22 23:09:17 +03:00
Aleksey Kladov
d8caf56dfc Uniformalize naming 2019-11-22 21:52:06 +03:00
Edwin Cheng
720ab0bef8 Refactor builtin macro 2019-11-23 01:47:35 +08:00
Edwin Cheng
f4e78a5f4e Add TestDB 2019-11-23 01:11:33 +08:00
Jeremy Kolb
1ee5592be2 Expand column!() 2019-11-22 11:34:48 -05:00
bors[bot]
506131e3e0
Merge #2357
2357: Expand file! to dummy "" r=edwin0cheng a=kjeremy

See https://github.com/rust-analyzer/rust-analyzer/pull/2355#issuecomment-557541873

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-11-22 16:07:37 +00:00
Aleksey Kladov
7469d2b863 Remove TraitData from API 2019-11-22 18:53:39 +03:00
Aleksey Kladov
fe119fef27 Hide data from public API 2019-11-22 18:51:53 +03:00
Aleksey Kladov
d4f4ae0dd8 Move const&static date to hir_def 2019-11-22 18:46:39 +03:00
kjeremy
786544f022 Expand file! to dummy "" 2019-11-22 10:05:04 -05:00
Aleksey Kladov
64df759418 Make ImplData's fields public 2019-11-22 17:42:56 +03:00
Aleksey Kladov
b315f05cf1 Move data to a single file 2019-11-22 17:32:10 +03:00
Aleksey Kladov
78f3b0627c Move FunctionData to hir_def 2019-11-22 17:18:04 +03:00
Aleksey Kladov
f4b1fb1554 Reorder 2019-11-22 14:12:45 +03:00
Aleksey Kladov
0861ac061e Cleanup errors 2019-11-22 14:08:18 +03:00
Aleksey Kladov
2c48fa087b Add support for environment to CrateGraph 2019-11-22 13:57:25 +03:00
bors[bot]
5be7bd605a
Merge #2348 #2352
2348: Add support for stringify! builtin macro r=matklad a=piotr-szpetkowski

Refs #2212

First time ever contributing here, hopefully it's ok.

2352: Move TypeAlias to hir_def r=matklad a=matklad



Co-authored-by: Piotr Szpetkowski <piotr.szpetkowski@pyquest.space>
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-22 10:14:41 +00:00
Aleksey Kladov
4fc900deb1 Move TypeAlias to hir_def 2019-11-22 13:13:51 +03:00
bors[bot]
5dd44a0820
Merge #2347
2347: More correct expand macro r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-22 10:00:44 +00:00
bors[bot]
f24aa7a45a
Merge #2351
2351: Rename Atts trait r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-22 09:27:13 +00:00
Aleksey Kladov
a87e9145a6 Rename Atts trait 2019-11-22 11:36:14 +03:00
Aleksey Kladov
e42f962766 Encapsulate Attrs 2019-11-22 11:27:47 +03:00
bors[bot]
d59bf33b9e
Merge #2349
2349: Ban println in lsp_server r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-22 07:48:02 +00:00
Aleksey Kladov
6fbad0619b Ban println in lsp_server 2019-11-22 10:46:56 +03:00
Aleksey Kladov
58413b22d7 Don't continue line comments 2019-11-22 10:38:33 +03:00
Piotr Szpetkowski
8ae5d6faf6
Add support for Stringify builtin macro 2019-11-22 07:56:50 +01:00
Edwin Cheng
a92ad59a02 More correct expand macro 2019-11-22 12:04:20 +08:00
bravomikekilo
1ebfa908d5 fix tidy test 2019-11-22 03:18:22 +08:00
bravomikekilo
8a8be06219 initial invert_if 2019-11-22 02:51:40 +08:00
Edwin Cheng
144dc6652c Fix insert_whitespaces 2019-11-22 02:38:14 +08:00
Edwin Cheng
67a58e4af1 Add test for match_ast 2019-11-22 02:38:14 +08:00
Edwin Cheng
59e7234546 Add to_macro_file_kind 2019-11-22 02:38:14 +08:00
Edwin Cheng
4ff400833f Add MacroFileKind::Statements 2019-11-22 02:38:14 +08:00
bors[bot]
3f1a0c3c5f
Merge #2341
2341: Fix mbe fail to parse TokenTree with endings whitespace r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-21 17:56:12 +00:00
Edwin Cheng
bf537eefb5 Fixed mbe trival subtree 2019-11-22 01:02:07 +08:00
Aleksey Kladov
a1346bba5c Fix test mark placement 2019-11-21 17:09:38 +03:00
Aleksey Kladov
952405cb41 reformat 2019-11-21 16:31:48 +03:00
Aleksey Kladov
4daf931111 Remove old hir::generics module 2019-11-21 16:23:02 +03:00
Aleksey Kladov
4f8f3393bc Reduce visibility 2019-11-21 16:00:57 +03:00
Aleksey Kladov
36758f2767 Resimplify 2019-11-21 15:56:27 +03:00
Aleksey Kladov
c37d1c5b38 Restore a mark 2019-11-21 15:49:24 +03:00
Aleksey Kladov
6d64798a23 Move resolver to hir_def 2019-11-21 15:39:09 +03:00
Aleksey Kladov
00684d708b Decouple 2019-11-21 15:24:51 +03:00
Aleksey Kladov
eb53aa37a3 Split internal and user-visible ScopeDef 2019-11-21 15:13:46 +03:00
Aleksey Kladov
ca1af86e7b Use GenericParam in ScopeDef 2019-11-21 14:22:30 +03:00
Aleksey Kladov
1312c57d34 Move ScopeDef 2019-11-21 14:21:26 +03:00
Aleksey Kladov
061e6c77b5 Decouple 2019-11-21 14:13:49 +03:00
Aleksey Kladov
621cf06156 Decouple 2019-11-21 13:48:05 +03:00
Aleksey Kladov
24964ca58e Move expr resolver to resolve 2019-11-21 13:28:04 +03:00
Aleksey Kladov
0102fb4133 Decouple Resolver 2019-11-21 13:25:03 +03:00
bors[bot]
2cb2fb1a48
Merge #2332
2332: Add HasResolver trait r=matklad a=matklad

bors merge

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-20 19:23:31 +00:00
Aleksey Kladov
1cead41510 Simplify 2019-11-20 22:22:32 +03:00
Aleksey Kladov
6241cf9a59 Add HasResolver trait 2019-11-20 22:22:32 +03:00