Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | Merge #2479 | bors[bot] | 2019-12-05 | 1 | -2/+2 |
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 macros | Florian Diebold | 2019-12-05 | 1 | -2/+2 |
| | | |||||
* | | Reduce copy-paste | Aleksey Kladov | 2019-12-05 | 1 | -20/+30 |
| | | |||||
* | | Introduce ChildFromSource | Aleksey Kladov | 2019-12-05 | 1 | -101/+40 |
|/ | |||||
* | One pub function less is good! | ice1000 | 2019-12-05 | 1 | -5/+4 |
| | |||||
* | No block at the moment | ice1000 | 2019-12-04 | 1 | -1/+1 |
| | |||||
* | Remove almost unused `ModuleSource::new` | ice1000 | 2019-12-04 | 1 | -1/+1 |
| | |||||
* | Add `ModuleSource::Block` | ice1000 | 2019-12-04 | 1 | -4/+4 |
| | |||||
* | Rename Source -> InFile | Aleksey Kladov | 2019-11-28 | 1 | -31/+31 |
| | |||||
* | Reformat | Aleksey Kladov | 2019-11-27 | 1 | -6/+5 |
| | |||||
* | Rename module_id -> local_id | Aleksey Kladov | 2019-11-27 | 1 | -4/+4 |
| | |||||
* | Fix hir for ast::UnionDef | Aleksey Kladov | 2019-11-25 | 1 | -7/+6 |
| | |||||
* | Simplify ADT fields | Aleksey Kladov | 2019-11-24 | 1 | -2/+1 |
| | |||||
* | Simplify | Aleksey Kladov | 2019-11-24 | 1 | -4/+4 |
| | |||||
* | Simplify | Aleksey Kladov | 2019-11-24 | 1 | -1/+3 |
| | |||||
* | Switch to StaticLoc for statics | Aleksey Kladov | 2019-11-24 | 1 | -2/+13 |
| | |||||
* | Cleanup imports | Aleksey Kladov | 2019-11-24 | 1 | -2/+1 |
| | |||||
* | Move constants to new ID | Aleksey Kladov | 2019-11-20 | 1 | -3/+22 |
| | | | | This allows us to get rid of trait item index | ||||
* | Switch type aliases to new sources | Aleksey Kladov | 2019-11-20 | 1 | -41/+71 |
| | |||||
* | Next gen IDs for functions | Aleksey Kladov | 2019-11-20 | 1 | -7/+58 |
| | | | | | | | | | | | | | | | | | The current system with AstIds has two primaraly drawbacks: * It is possible to manufacture IDs out of thin air. For example, it's possible to create IDs for items which are not considered in CrateDefMap due to cfg. Or it is possible to mixup structs and unions, because they share ID space. * Getting the ID of a parent requires a secondary index. Instead, the plan is to pursue the more traditional approach, where each items stores the id of the parent declaration. This makes `FromSource` more awkward, but also more correct: now, to get from an AST to HIR, we first do this recursively for the parent item, and the just search the children of the parent for the matching def | ||||
* | Rename Source::ast -> Source::value | Aleksey Kladov | 2019-11-20 | 1 | -19/+19 |
| | |||||
* | Handle ast::MacroCall in classify_name and impl FromSource for MacroDef | kjeremy | 2019-11-15 | 1 | -4/+19 |
| | | | | Fixes #2260 | ||||
* | Sourcify some things | Aleksey Kladov | 2019-11-15 | 1 | -3/+2 |
| | | | | | If we want to support macros properly, we need to get rid of those FileIds everywhere... | ||||
* | Remove old impls infrastructure | Aleksey Kladov | 2019-11-15 | 1 | -8/+2 |
| | |||||
* | Refactor Module::from_source to properly descend from root file | Aleksey Kladov | 2019-11-15 | 1 | -32/+36 |
| | |||||
* | Move body queries to hir_def | Aleksey Kladov | 2019-11-14 | 1 | -2/+2 |
| | |||||
* | Handle macro-generated expressions slightly less wrong | Aleksey Kladov | 2019-11-14 | 1 | -1/+2 |
| | |||||
* | Add hir::Local | Aleksey Kladov | 2019-11-11 | 1 | -3/+27 |
| | |||||
* | Unfork struct and union ids | Aleksey Kladov | 2019-11-09 | 1 | -4/+6 |
| | |||||
* | Move CrateDefMap to hir_def | Aleksey Kladov | 2019-11-03 | 1 | -8/+14 |
| | |||||
* | push name down to hir_expand | Aleksey Kladov | 2019-10-30 | 1 | -1/+1 |
| | |||||
* | remove forward pointer for name | Aleksey Kladov | 2019-10-30 | 1 | -1/+1 |
| | |||||
* | move raw_items to hir_def | Aleksey Kladov | 2019-10-30 | 1 | -41/+1 |
| | |||||
* | Move ids to hir_def crate | Aleksey Kladov | 2019-10-30 | 1 | -1/+1 |
| | |||||
* | introduce ra_hir_def | Aleksey Kladov | 2019-10-30 | 1 | -1/+1 |
| | |||||
* | start ra_hir_def crate | Aleksey Kladov | 2019-10-29 | 1 | -2/+2 |
| | |||||
* | restore assert | Aleksey Kladov | 2019-10-23 | 1 | -0/+1 |
| | |||||
* | classify module from declaration | Ekaterina Babshukova | 2019-10-22 | 1 | -1/+0 |
| | |||||
* | replace trait by a bunch of functions | Ekaterina Babshukova | 2019-10-22 | 1 | -58/+2 |
| | |||||
* | return Declaration from classify_name_ref | Ekaterina Babshukova | 2019-10-22 | 1 | -1/+39 |
| | |||||
* | replace a chain of `if let` by macro | Ekaterina Babshukova | 2019-10-22 | 1 | -39/+1 |
| | |||||
* | initial classify_name | Ekaterina Babshukova | 2019-10-22 | 1 | -2/+58 |
| | |||||
* | Prepare SourceDatabase API for lazy file loading | Aleksey Kladov | 2019-10-14 | 1 | -5/+5 |
| | |||||
* | Added test for check doc strings in crates. | Alexander Andreev | 2019-09-30 | 1 | -0/+2 |
| | | | | #1856 | ||||
* | Remove redundant clone() | Shotaro Yamada | 2019-09-25 | 1 | -4/+4 |
| | |||||
* | Drive by lints | kjeremy | 2019-09-23 | 1 | -1/+1 |
| | |||||
* | introduce FromSource trait | Ekaterina Babshukova | 2019-09-19 | 1 | -0/+211 |