Commit graph

186 commits

Author SHA1 Message Date
Edwin Cheng
20f7068b68 Store proc-macro result in salsa db 2020-05-14 17:57:51 +08:00
Trevor Spiteri
3583e0fe2b fix typo unimplementated -> unimplemented
Pretty harmless typo, but it does get exposed in
lsp-rust-analyzer-expand-macro.
2020-05-12 23:51:38 +02:00
bors[bot]
fb8fb65131
Merge #4234
4234: Support local_inner_macros r=jonas-schievink a=edwin0cheng

This PR implements `#[macro_export(local_inner_macros)]` support. 

Note that the rustc implementation is quite [hacky][1] too. :)

[1]: 614f273e93/src/librustc_resolve/macros.rs (L456)

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-05-02 10:30:49 +00:00
Aleksey Kladov
4f2134cc33 Introduce EffectExpr 2020-05-02 11:21:39 +02:00
Edwin Cheng
443762cda9
Update crates/ra_hir_expand/src/builtin_derive.rs
Fix spacing

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-05-02 09:56:38 +08:00
Edwin Cheng
bdcf6f5658 Introduce LowerCtx for path lowering 2020-05-01 20:01:17 +08:00
Edwin Cheng
e4267967a8 Support local_inner_macros 2020-05-01 11:23:03 +08:00
Edwin Cheng
c69f9c1b0a Check dep name to detect it is core 2020-04-28 04:11:24 +08:00
Edwin Cheng
6d3b0af900 Use empty-deps tricks to detect it is core 2020-04-28 03:32:47 +08:00
Edwin Cheng
213d208e2d Add test 2020-04-28 02:10:17 +08:00
Edwin Cheng
6a5014329a Use core instead of std for builtin derive macros 2020-04-28 01:48:55 +08:00
bors[bot]
f654f49435
Merge #4125
4125: Avoid lossy OsString conversions r=matklad a=lnicola

This is a bit invasive, and perhaps for not much benefit since non-UTF-8 environment variables don't work anyway.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-25 10:35:14 +00:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
Laurențiu Nicola
58dde891f8 Avoid lossy OsString conversions 2020-04-25 12:19:23 +03:00
Edwin Cheng
4a303366c8 Improve remove dervie attrs 2020-04-22 01:44:21 +08:00
Jeremy Kolb
d7f3d858ad Some clippy fixes 2020-04-19 15:15:49 -04:00
Aleksey Kladov
146f6f5a45 Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the
presence of macros, so let's leave them out for now. We are not using
them heavily anyway.
2020-04-17 13:56:42 +02:00
Aleksey Kladov
a8196ffe84 Correctly highlight ranges of diagnostics from macros
closes #2799
2020-04-17 13:56:38 +02:00
Aleksey Kladov
302bf97bbf Don't expose impl details of SyntaxPtr 2020-04-17 12:25:41 +02:00
Aleksey Kladov
5e5eb6a108 Align grammar for record patterns and literals
The grammar now looks like this

   [name_ref :] pat
2020-04-12 00:00:15 +02:00
Aleksey Kladov
c1244c853c Forward compat 2020-04-11 00:27:00 +02:00
Edwin Cheng
19d952c603 Improve tt::Subtree debug print 2020-04-10 00:17:32 +08:00
Laurențiu Nicola
52fd2c8e48 Fix unnecessary braces warnings 2020-04-06 17:21:33 +03:00
Edwin Cheng
503cbd3f4b Implement ra_proc_macro client logic 2020-03-31 22:20:18 +08:00
bors[bot]
b1594f1080
Merge #3727
3727: Introduce ra_proc_macro r=matklad a=edwin0cheng

This PR implemented:

1.  Reading dylib path of proc-macro crate from cargo check , similar to how `OUTDIR` is obtained.
2.  Added a new crate `ra_proc_macro` and implement the foot-work for reading result from external proc-macro expander. 
3. Added a struct `ProcMacroClient` , which will be responsible to the client side communication to the External process.



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-03-26 17:09:32 +00:00
Edwin Cheng
db162df264 Remove deps on tt_mbe 2020-03-27 00:46:40 +08:00
Aleksey Kladov
db34abeb85 Get rid of ItemOrMacro 2020-03-26 16:10:01 +01:00
Edwin Cheng
d0b6ed4441 Add ProcMacroClient 2020-03-26 03:29:45 +08:00
Edwin Cheng
8afb445357 Rename to CustomDerive 2020-03-25 19:50:12 +08:00
Edwin Cheng
7667aa6033 Refactoring a bit 2020-03-25 19:50:12 +08:00
Edwin Cheng
519dc15cb1 Use dummy implementation 2020-03-25 19:50:12 +08:00
Edwin Cheng
34dc8d25c1 Add basic custom derive lowering 2020-03-25 19:50:12 +08:00
Aleksey Kladov
062f6e3bbe Generalise syntax rewriting infrastructure to allow removal of nodes 2020-03-24 17:14:33 +01:00
Edwin Cheng
6d6606895c Fix typo 2020-03-21 23:08:53 +08:00
Edwin Cheng
e1a9461806 Add identity expansion checking 2020-03-21 22:43:48 +08:00
Aleksey Kladov
f840fcb2f5 Simplify Arena to use a generic index 2020-03-19 18:46:30 +01:00
Florian Diebold
d655749aae Turn ExpandResult into struct 2020-03-16 18:38:19 +01:00
Florian Diebold
035db0fbb9 Add test, remove printlns 2020-03-16 18:38:19 +01:00
Florian Diebold
0f3a54dd4d wip 2020-03-16 18:38:19 +01:00
Florian Diebold
b973158aeb Make MBE expansion more resilient (WIP) 2020-03-16 18:38:19 +01:00
Aleksey Kladov
9faea2364d Use dyn Trait for working with databse
It improves compile time in `--release` mode quite a bit, it doesn't
really slow things down and, conceptually, it seems closer to what we
want the physical architecture to look like (we don't want to
monomorphise EVERYTHING in a single leaf crate).
2020-03-16 17:42:30 +01:00
Veetaha
7eb5d89a85
ra_hir_expand: change the ordering of imports as per the formatter 2020-03-15 18:51:09 +02:00
Veetaha
cbd9f46bc7
ra_hir_expand: migrate to impl_intern_key!() 2020-03-15 18:25:55 +02:00
Edwin Cheng
8f7703b006 Update comment
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-12 02:00:56 +08:00
Edwin Cheng
759bcea96d Implement dummy assert macro 2020-03-11 23:08:12 +08:00
Edwin Cheng
6ea7c31915 Add extern source 2020-03-11 11:04:02 +08:00
Edwin Cheng
5a292309c5 Add and fix tests 2020-03-11 01:06:01 +08:00
Edwin Cheng
22f064cca7 Add resolve_extern_path in DB 2020-03-11 01:06:01 +08:00
bors[bot]
beb4f49541
Merge #3513
3513: Completion in macros r=matklad a=flodiebold

I experimented a bit with completion in macros. It's kind of working, but there are a lot of rough edges.

 - I'm trying to expand the macro call with the inserted fake token. This requires some hacky additions on the HIR level to be able to do "hypothetical" expansions. There should probably be a nicer API for this, if we want to do it this way. I'm not sure whether it's worth it, because we still can't do a lot if the original macro call didn't expand in nearly the same way. E.g. if we have something like `println!("", x<|>)` the expansions will look the same and everything is fine; but in that case we could maybe have achieved the same result in a simpler way. If we have something like `m!(<|>)` where `m!()` doesn't even expand or expands to something very different, we don't really know what to do anyway.
 - Relatedly, there are a lot of cases where this doesn't work because either the original call or the hypothetical call doesn't expand. E.g. if we have `m!(x.<|>)` the original token tree doesn't parse as an expression; if we have `m!(match x { <|> })` the hypothetical token tree doesn't parse. It would be nice if we could have better error recovery in these cases.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-03-09 08:56:58 +00:00
Edwin Cheng
e7206467d5 Add parse_to_token_tree 2020-03-09 00:13:04 +08:00