aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
Commit message (Collapse)AuthorAgeFilesLines
* Merge #2484bors[bot]2019-12-066-277/+300
|\ | | | | | | | | | | | | | | | | | | 2484: DynMap r=matklad a=matklad Implement a `DynMap` a semi-dynamic, semi-static map, which helps to thread heterogeneously typed info in a uniform way. Totally inspired by https://github.com/JetBrains/kotlin/blob/df3bee30384787d8951ea548a4257c2cb52a16a3/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java. @flodiebold wdyt? Seems like a potentially useful pattern for various source-map-like things. Co-authored-by: Aleksey Kladov <[email protected]>
| * DynMapAleksey Kladov2019-12-066-277/+300
| | | | | | | | | | This might, or might not help us to reduce boilerplate associated with plumbing values from analysis to the IDE layer
* | Merge #2481bors[bot]2019-12-061-2/+0
|\ \ | |/ |/| | | | | | | | | | | 2481: Remove obsolete comment r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
| * Remove obsolete commentAleksey Kladov2019-12-051-2/+0
| |
* | Merge #2479bors[bot]2019-12-057-11/+118
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | 2479: Add expansion infrastructure for derive macros r=matklad a=flodiebold I thought I'd experiment a bit with attribute macro/derive expansion, and here's what I've got so far. It has dummy implementations of the Copy / Clone derives, to show that the approach works; it doesn't add any attribute macro support, but I think that fits into the architecture. Basically, during raw item collection, we look at the attributes and generate macro calls for them if necessary. Currently I only do this for derives, and just add the derive macro calls as separate calls next to the item. I think for derives, it's important that they don't obscure the actual item, since they can't actually change it (e.g. sending the item token tree through macro expansion unnecessarily might make completion within it more complicated). Attribute macros would have to be recognized at that stage and replace the item (i.e., the raw item collector will just emit an attribute macro call, and not the item). I think when we implement this, we should try to recognize known inert attributes, so that we don't do macro expansion unnecessarily; anything that isn't known needs to be treated as a possible attribute macro call (since the raw item collector can't resolve the macro yet). There's basically no name resolution for attribute macros implemented, I just hardcoded the built-in derives. In the future, the built-ins should work within the normal name resolution infrastructure; the problem there is that the builtin stubs in `std` use macros 2.0, which we don't support yet (and adding support is outside the scope of this). One aspect that I don't really have a solution for, but I don't know how important it is, is removing the attribute itself from its input. I'm pretty sure rustc leaves out the attribute macro from the input, but to do that, we'd have to create a completely new syntax node. I guess we could do it when / after converting to a token tree. Co-authored-by: Florian Diebold <[email protected]>
| * Add expansion infrastructure for derive macrosFlorian Diebold2019-12-057-11/+118
| |
* | Introduce ChildFromSourceAleksey Kladov2019-12-052-0/+277
|/
* Publicize `file_id` to make `test_db` compileice10002019-12-051-1/+1
|
* Use placeholder instead of `Option`ice10002019-12-052-14/+10
|
* One pub function less is good!ice10002019-12-051-5/+0
|
* Reduce visibility, use struct instead of tuplesice10002019-12-051-20/+23
|
* No block at the momentice10002019-12-041-6/+1
|
* Remove almost unused `ModuleSource::new`ice10002019-12-041-19/+1
|
* Confluent `ModuleSource` usageice10002019-12-041-13/+5
|
* Add `ModuleSource::Block`ice10002019-12-041-2/+66
|
* Fix test compilationice10002019-12-041-1/+1
|
* Three-state enum for module originice10002019-12-042-20/+78
|
* Replace `ra_hir_expand::either` with crateice10002019-12-039-35/+34
|
* Merge #2455bors[bot]2019-12-015-31/+102
|\ | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Remove some empty linesEdwin Cheng2019-12-011-2/+0
| |
| * Use index instead of peekableEdwin Cheng2019-12-011-35/+19
| |
| * Fix commentEdwin Cheng2019-12-011-2/+1
| |
| * Add BuiltinShadowModeEdwin Cheng2019-11-305-30/+120
| |
* | Reduce variants of Exproxalica2019-11-292-38/+19
| |
* | Infer range typesoxalica2019-11-283-4/+76
|/
* Move source-related traits to a separate moduleAleksey Kladov2019-11-288-58/+72
|
* Use InFile for AstIdAleksey Kladov2019-11-284-11/+11
|
* Rename Source -> InFileAleksey Kladov2019-11-289-44/+44
|
* Use Name::missing consistentlyAleksey Kladov2019-11-273-15/+16
|
* ReformatAleksey Kladov2019-11-271-2/+1
|
* Rename module_id -> local_idAleksey Kladov2019-11-278-24/+24
|
* Move TyAleksey Kladov2019-11-271-1/+1
|
* DecoupleAleksey Kladov2019-11-271-0/+10
|
* CleanupAleksey Kladov2019-11-261-2/+2
|
* Merge #2418bors[bot]2019-11-262-7/+5
|\ | | | | | | | | | | | | | | 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 <[email protected]>
| * Hide MacroCallLocEdwin Cheng2019-11-262-7/+5
| |
* | Add noteAleksey Kladov2019-11-261-0/+2
| |
* | Store names in TraitDataAleksey Kladov2019-11-261-17/+38
|/
* Merge #2406bors[bot]2019-11-261-1/+1
|\ | | | | | | | | | | | | | | 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 <[email protected]>
| * Add hygiene information to SourceAnalyzerEdwin Cheng2019-11-261-1/+1
| |
* | Id-ify Ty::AdtAleksey Kladov2019-11-261-0/+4
| |
* | Introduce hir::TypeAleksey Kladov2019-11-261-0/+10
| | | | | | | | It should provide a convenient API over more low-level Ty
* | :arrow_up: salsaAleksey Kladov2019-11-261-1/+3
|/
* Fixme for union fieldsAleksey Kladov2019-11-252-0/+6
|
* Fix hir for ast::UnionDefAleksey Kladov2019-11-259-46/+62
|
* Merge #2396bors[bot]2019-11-241-6/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Switch to variant-granularity field type inferenceAleksey Kladov2019-11-241-6/+7
| |
* | Implement HasModule for AdtIdAleksey Kladov2019-11-242-9/+13
|/
* Simplify ADT fieldsAleksey Kladov2019-11-241-3/+11
|
* hir_def is fully doc'ed!Aleksey Kladov2019-11-243-5/+8
|