Commit Graph

200 Commits

Author SHA1 Message Date
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
Florian Diebold
afdf08e964 Move hypothetical expansion to hir_expand 2020-03-08 11:10:48 +01:00
Florian Diebold
f617455d10 Remove TODOs 2020-03-07 19:58:18 +01:00
Florian Diebold
24e98121d8 Try to complete within macros 2020-03-07 15:48:06 +01:00
Edwin Cheng
18f88ad10b Prevent include! macro include itself 2020-03-07 19:08:42 +08:00
Edwin Cheng
2e178b5475 Fix test and add more comment 2020-03-07 13:02:54 +08:00
Edwin Cheng
36c7684687 Use a not so dummy implementation of env macro 2020-03-07 12:53:40 +08:00
Edwin Cheng
0a06c7e6e6 Implment include macro 2020-03-06 22:58:45 +08:00
Edwin Cheng
0c79e1d304 Add comment for parents logging 2020-03-05 03:02:51 +08:00
Edwin Cheng
c7b0c72dd7 Fix whitespace in tests 2020-03-05 00:12:39 +08:00
Edwin Cheng
028595548b Fix #3436 2020-03-04 23:41:14 +08:00
Edwin Cheng
e76dddd610 Add more log 2020-03-04 23:41:04 +08:00
Edwin Cheng
5ea83fee01 Fixed a typo in comment 2020-03-04 02:57:54 +08:00
Edwin Cheng
e04c0f4222 Fix panic on eager expansion 2020-03-04 02:41:33 +08:00
Edwin Cheng
4d5e80c6c8 Fix for rebasing 2020-03-04 01:24:33 +08:00
Edwin Cheng
1e9a3233f7 Move pub function first 2020-03-04 01:21:14 +08:00
Edwin Cheng
02b865019b Add doc about eager expansion name resolution 2020-03-04 01:21:14 +08:00
Edwin Cheng
1465cc0c4f Implement concat macro 2020-03-04 01:21:14 +08:00
Edwin Cheng
0d55454073 Add LazyMacroId 2020-03-04 01:21:14 +08:00
Edwin Cheng
3dc3d9d18f Fix a bug for single dollar sign macro 2020-03-04 01:03:44 +08:00
Kirill Bulatov
f6816c253b Update versions 2020-02-18 16:12:40 +02:00
Kirill Bulatov
eceaf94f19 More manual clippy fixes 2020-02-18 16:12:37 +02:00
Kirill Bulatov
b8ddcb0652 Run cargo +nightly fix --clippy -Z unstable-options 2020-02-18 16:03:08 +02:00
Aleksey Kladov
f2424f947c Add couple of utility methods 2020-02-12 18:19:55 +01:00
Kirill Bulatov
7de7c8a7ef Remove ImportResolver-related stubs 2020-02-09 12:34:41 +02:00
Kirill Bulatov
c669b2f489 Code review fixes 2020-02-02 14:27:52 +02:00
Kirill Bulatov
6dae5cbb11 Require ModPath for importing 2020-02-02 14:06:51 +02:00
Kirill Bulatov
7a2e449424 Prefer imports starting with std 2020-01-28 01:02:06 +02:00
Edwin Cheng
6ebb1edf21 Use dummy value for line! and column! macro 2020-01-15 01:47:01 +08:00
Edwin Cheng
d7be1a4372 Use attr location for builtin macro goto-imp 2020-01-12 18:08:53 +08:00
Florian Diebold
4496e2a06a Apply review suggestions 2020-01-11 23:33:04 +01:00
Florian Diebold
12905e5b58 Some more refactoring 2020-01-11 23:33:04 +01:00
Florian Diebold
b62292e8f9 basics working 2020-01-11 23:33:04 +01:00
bors[bot]
7c1af25b22
Merge #2795
2795: Use dummy value for macro file in bulitin macros r=matklad a=edwin0cheng

This PR skip the actual line and column computation for `MacroFile` and return a dummy value instead.

Related to #2794



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-11 20:13:48 +00:00
Edwin Cheng
9f65ae20c2 Use dummy value for macro file in bulitin macros 2020-01-11 16:37:42 +08:00
Florian Diebold
dd6ec81d65 Add test for macro expansion in various expressions 2020-01-10 22:08:02 +01:00
Edwin Cheng
dca9195f75 Add missing expr cases for expand macro 2020-01-11 03:11:23 +08:00
Edwin Cheng
ca62d98781 Expand PAREN_EXPR as expression 2020-01-11 00:29:00 +08:00
Aleksey Kladov
4d66f5d7d2 Fix panic in tuple fields 2020-01-07 14:49:42 +01:00
Florian Diebold
2058f704cb Add dummy implementations of env! and option_env! builtins
They don't do anything except return the correct type.

Also refactor the builtin macro tests a bit.
2019-12-21 13:34:43 +01:00
bors[bot]
1cbef27ff8
Merge #2625
2625: Clippy lints r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-12-21 06:12:36 +00:00
kjeremy
0d5d63a80e Clippy lints 2019-12-20 15:14:30 -05:00
Edwin Cheng
ad81d1dbc1 Add support macros in impl blocks 2019-12-21 03:37:03 +08:00
bors[bot]
af5e2abe15
Merge #2614
2614: Clippy cleanup r=matklad a=kjeremy

Just a few tweaks from the latest clippy.  There are a lot more but we should probably tweak our settings.

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-12-20 14:46:24 +00:00
kjeremy
133b4063a6 Remove useless clone 2019-12-20 09:43:01 -05:00
Edwin Cheng
dddee23f43 Add std::ops::Index support for infering 2019-12-19 12:45:07 +08:00
Edwin Cheng
2ea1cfd780 Rename range to by_kind 2019-12-18 11:36:10 +08:00
Edwin Cheng
320416d756 Add TokenTextRange 2019-12-18 11:20:22 +08:00
Edwin Cheng
59295854f8 Add token id to delims 2019-12-18 11:20:22 +08:00
Edwin Cheng
aceb9d7fb0 Add token ids for all tt::Leaf 2019-12-18 11:20:22 +08:00
bors[bot]
4a58522119
Merge #2562
2562: Fix NavigationTarget ranges r=matklad a=edwin0cheng

Fix the issue described in https://github.com/rust-analyzer/rust-analyzer/pull/2544#issuecomment-565572553

This PR change the order for finding `full_range` of `focus_range` in following orders:
1. map both ranges to macro_call
2. map focus range to a token inside macro call, and full range to the whole of macro call
3. map both ranges to the whole of macro call

And fix the corresponding tests and make these tests easily to follow.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2019-12-17 13:37:32 +00:00
Edwin Cheng
b53587c7bd Re-export Origin to replace ExpansionOrigin 2019-12-15 01:46:39 +08:00
Edwin Cheng
61360fdfec Fix original_source find order 2019-12-15 01:24:51 +08:00
Florian Diebold
6911bc89a7 Rename N! to name! 2019-12-13 22:33:38 +01:00
Florian Diebold
259c42f00e Add macros for known names and paths 2019-12-13 22:33:37 +01:00
bors[bot]
9c9f4635b4
Merge #2550
2550: Infer - and ! using std::ops::{Neg, Not} r=flodiebold a=kiljacken

Found some low hanging fruit while taking a cursory look at index inferring.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2019-12-13 19:49:01 +00:00
Edwin Cheng
98f98cbb54 Refactor tt::Delimiter 2019-12-13 21:53:34 +08:00
Emil Lauridsen
7705209051 Correctly infer - and ! using std::ops::{Neg,Not} 2019-12-13 12:45:38 +01:00
Aleksey Kladov
82e9b24558 Move traits to the new loc 2019-12-12 14:36:14 +01:00
Florian Diebold
5e096def15 Expand macros in blocks to expressions for now
Expanding to statements isn't handled properly yet and breaks things.
2019-12-08 13:03:13 +01:00
Florian Diebold
91f28e43a2 Fix expansion of format_args 2019-12-08 13:02:52 +01:00
Edwin Cheng
509fedd9d2 Remove MacroFileKind 2019-12-08 16:16:52 +08:00
Florian Diebold
b2c01f446e Implement ancestors_with_macros in a better way 2019-12-06 21:53:31 +01:00
Florian Diebold
4a99ef5c39 Builtin macros only use caller tokens 2019-12-06 21:25:22 +01:00
Florian Diebold
a565072dde Try to make go to definition work in format!
SourceAnalyzer didn't work properly within expression macro expansions because
it didn't find the enclosing function. Fix this by going up the expansion chain
to find ancestors. This makes the test work, but apparently in real usage it's
still not working.
2019-12-06 21:25:22 +01:00
Florian Diebold
eae425b10f Implement format_args more properly 2019-12-06 21:25:22 +01:00
Florian Diebold
3a5aa03e66 Remove unnecessary len parameter for Name::new_inline_ascii
I assume it was previously required because `len` was not const, but that
doesn't seem to be a problem anymore.
2019-12-06 21:25:22 +01:00
Florian Diebold
c5ffb0dc81 Add stub implementation of format_args{_nl} macros
Just enough to fix the huge amount of type mismatches they cause.
2019-12-06 21:25:22 +01:00
Florian Diebold
10697041c1 Implement all the other built-in derives
Since as long as we're not implementing the bodies, they all work the same way.
2019-12-05 19:52:52 +01:00
Florian Diebold
db8a00bd99 Implement derive(Copy, Clone) properly (well, kind of) 2019-12-05 19:29:57 +01:00
Florian Diebold
18f6a995d0 Add expansion infrastructure for derive macros 2019-12-05 17:23:09 +01:00
ice1000
009437f5d9 Replace ra_hir_expand::either with crate 2019-12-03 11:07:56 -05:00
oxalica
4992d2bf79
Infer range types 2019-11-29 03:10:16 +08: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
Edwin Cheng
447268ceac Hide MacroCallLoc 2019-11-27 01:33:08 +08:00
Aleksey Kladov
131c2da6bf ⬆️ salsa 2019-11-26 11:29:20 +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
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
Edwin Cheng
16854e28ef Use macro for all the things 2019-11-23 22:48:34 +08:00
Edwin Cheng
6940ae9eab Rename BuiltinExpander to BuiltinFnLikeExpander 2019-11-23 21:54:39 +08: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
kjeremy
786544f022 Expand file! to dummy "" 2019-11-22 10:05:04 -05:00
Piotr Szpetkowski
8ae5d6faf6
Add support for Stringify builtin macro 2019-11-22 07:56:50 +01:00