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
Edwin Cheng
4ff400833f
Add MacroFileKind::Statements
2019-11-22 02:38:14 +08:00
Aleksey Kladov
51baaf298d
Rename with_ast -> with_value
2019-11-20 13:09:21 +03:00
Aleksey Kladov
36e3fc9d54
Rename Source::ast -> Source::value
2019-11-20 09:42:30 +03:00
Edwin Cheng
f24bba74d0
Fixed a bug for string lit in quote
2019-11-19 12:15:20 +08:00
Aleksey Kladov
2b6f1ab0e2
Collapse TokenMap and RevTokenMap
2019-11-18 16:08:41 +03:00
Aleksey Kladov
b79d678923
Token-based reverse-mapping
2019-11-18 15:08:39 +03:00
Aleksey Kladov
fd52d721e1
More correct expansion mapping
...
We can't really map arbitrary ranges, we only can map tokens
2019-11-17 20:15:55 +03:00
Aleksey Kladov
c8f858d043
Make shift an implementation detail of mbe
2019-11-17 19:11:43 +03:00
bors[bot]
64dac40a86
Merge #2287
...
2287: Disable doctests r=matklad a=matklad
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-11-17 15:45:30 +00:00
Aleksey Kladov
7e2f4b30db
Disable doctests
2019-11-17 18:35:05 +03:00
Aleksey Kladov
6a70bff451
Don't store shift redundantly
2019-11-17 18:22:34 +03:00
Aleksey Kladov
2eaa8c94a8
Goto definition works inside macros
2019-11-16 17:00:54 +03:00
Aleksey Kladov
0404e647e6
Prepare SourceAnalyzer for macros
2019-11-16 00:40:54 +03:00
Aleksey Kladov
bd8af6a413
Sourcify some more
2019-11-16 00:05:10 +03:00
Aleksey Kladov
4c90b7e2ec
Sourcify some things
...
If we want to support macros properly, we need to get rid of those
FileIds everywhere...
2019-11-15 23:24:56 +03:00
memoryruins
a5f57f98ca
Heed the advice of rustc's into_iter() warning
2019-11-15 07:18:10 -05:00
Aleksey Kladov
da2ca01eba
Handle macro-generated expressions slightly less wrong
2019-11-14 10:30:30 +03:00
Edwin Cheng
4f7df2aac1
Add MacroDefKind
2019-11-11 18:48:16 +08:00
Edwin Cheng
c4aa8b63bc
Add line macro and tests
2019-11-11 14:15:09 +08:00
Edwin Cheng
1637a8a590
Add quote macro
2019-11-11 14:14:39 +08:00
Edwin Cheng
c46768d13d
Add basic bultin macro infrastructure
2019-11-11 14:13:31 +08:00
Aleksey Kladov
70f2a21b55
Remove typed macro parsing API
...
We do type-erasure on every path anyway, so it doesn't make much sense
to duplicate this function for every type
2019-11-09 13:14:10 +03:00
Aleksey Kladov
f6c40c09e0
Minor cleanup
2019-11-09 12:49:35 +03:00
Edwin Cheng
0a5ec69404
Remove map_ranges in RevTokenMap
2019-11-09 12:00:46 +08:00
Edwin Cheng
d01e0abdb5
Refactor and simpfily
2019-11-09 04:26:28 +08:00
Edwin Cheng
62ed93db13
Refactor and add more comments
2019-11-08 10:19:41 +08:00
Edwin Cheng
2a76bb5a0b
Refactor a bit
2019-11-05 03:20:54 +08:00
Edwin Cheng
604bdc6ffe
Use macro_rules shift to map text ranges
2019-11-05 02:09:16 +08:00
Edwin Cheng
7e28924012
Use ? and destructing to simplifed long code
2019-11-05 01:38:20 +08:00
Edwin Cheng
e6709f64af
Rename and fix typos
2019-11-05 01:38:20 +08:00
Edwin Cheng
67226ebc82
Remove dbg!
2019-11-05 01:38:20 +08:00
Edwin Cheng
ae609d7953
Add parent_expansion to HirFileId
2019-11-05 01:38:20 +08:00
Edwin Cheng
159da285e9
Add macro_expansion_info in hir_expand
2019-11-05 01:38:20 +08:00
Aleksey Kladov
13735d91a7
Move diagnostics to hir_expand
2019-11-02 23:42:38 +03:00
Aleksey Kladov
b8533413cf
Move Source to hir_expand
2019-11-02 23:11:27 +03:00
Aleksey Kladov
ab559f170e
move hygiene to hir_expand
2019-10-30 19:10:53 +03:00
Aleksey Kladov
872ac566bf
push name down to hir_expand
2019-10-30 18:56:20 +03:00
Aleksey Kladov
b05d6e53fb
push either to hir_expand
2019-10-30 18:50:10 +03:00
Aleksey Kladov
16e620c052
move raw_items to hir_def
2019-10-30 17:43:11 +03:00
Aleksey Kladov
bca708ba4c
cleanup
2019-10-29 16:19:08 +03:00
Aleksey Kladov
99b6ecfab0
switch expand to dyn Trait
2019-10-29 16:12:54 +03:00
Aleksey Kladov
3260639608
reduce visibility
2019-10-29 16:08:06 +03:00
Aleksey Kladov
1ec418c3b8
add doc comment
2019-10-29 16:03:29 +03:00
Aleksey Kladov
7de6eaa58a
remove not that useful indirection
2019-10-29 16:01:14 +03:00
Aleksey Kladov
2a5254c106
reduce visibility
2019-10-29 15:25:46 +03:00
Aleksey Kladov
d095d9273e
remove unused query
2019-10-29 15:22:20 +03:00
Aleksey Kladov
858dd48af2
less generics
2019-10-29 15:20:08 +03:00
Aleksey Kladov
6bf7faf315
flatten hir_expand
2019-10-29 15:11:42 +03:00
Aleksey Kladov
dba767802d
make file id repr private again
2019-10-29 15:01:55 +03:00
Aleksey Kladov
5b803055b7
rename hir_def -> hir_expand
2019-10-29 14:59:55 +03:00