Commit graph

155 commits

Author SHA1 Message Date
ice1000
5c5f90ba57 Confluent ModuleSource usage 2019-12-04 18:30:42 -05:00
ice1000
38853459e3 Add ModuleSource::Block 2019-12-04 18:30:42 -05:00
ice1000
7cbedc50bc Fix test compilation 2019-12-04 18:30:42 -05:00
ice1000
1bb59a7d08 Three-state enum for module origin 2019-12-04 18:30:42 -05:00
ice1000
009437f5d9 Replace ra_hir_expand::either with crate 2019-12-03 11:07:56 -05:00
bors[bot]
ec164fbb68
Merge #2455
2455: Add BuiltinShadowMode r=flodiebold a=edwin0cheng

This PR try to fix #1905 by introduce an `BuiltinShadowMode` in name resolving functions. 

cc @flodiebold 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-01 11:13:25 +00:00
Edwin Cheng
cfc6e9e366 Remove some empty lines 2019-12-01 12:17:52 +08:00
Edwin Cheng
13c54685ff Use index instead of peekable 2019-12-01 12:14:35 +08:00
Edwin Cheng
5f11117733 Fix comment 2019-12-01 12:14:12 +08:00
Edwin Cheng
bb601e7eaf Add BuiltinShadowMode 2019-11-30 23:29:21 +08:00
oxalica
2cb684bbce
Reduce variants of Expr 2019-11-29 14:49:12 +08:00
oxalica
4992d2bf79
Infer range types 2019-11-29 03:10:16 +08:00
Aleksey Kladov
8f1f5a783a Move source-related traits to a separate module 2019-11-28 19:05:21 +03:00
Aleksey Kladov
e823c578c9 Use InFile for AstId 2019-11-28 16:02:38 +03:00
Aleksey Kladov
ccd1b0800a Rename Source -> InFile 2019-11-28 12:50:26 +03:00
Aleksey Kladov
1d14fd1737 Use Name::missing consistently 2019-11-27 23:22:20 +03:00
Aleksey Kladov
27b362b059 Reformat 2019-11-27 21:44:38 +03:00
Aleksey Kladov
d9a36a736b Rename module_id -> local_id 2019-11-27 21:31:51 +03:00
Aleksey Kladov
a87579500a Move Ty 2019-11-27 21:16:00 +03:00
Aleksey Kladov
825049bc62 Decouple 2019-11-27 12:34:26 +03:00
Aleksey Kladov
bed6869865 Cleanup 2019-11-26 22:56:07 +03:00
bors[bot]
3206b83a70
Merge #2418
2418: Hide MacroCallLoc outside hir_expand  r=matklad a=edwin0cheng

This PR refactor `MacroCallLoc` such that it  be hided to become implementation details of hir_expand. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-11-26 18:34:15 +00: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
9bc8f1f4f8 Store names in TraitData 2019-11-26 17:44:43 +03: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
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
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
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
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
d87c16bea6 hir_def is fully doc'ed! 2019-11-24 21:00:50 +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
Aleksey Kladov
434f108ada Simplify 2019-11-24 19:01:19 +03: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
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
Aleksey Kladov
e0b06cb672 Switch to StaticLoc for statics 2019-11-24 15:18:12 +03:00