bors[bot]
b6a7276c54
Merge #8586
...
8586: Replace SyntaxRewriter usage with ted in eager::eager_macro_recur r=Veykril a=Veykril
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-04-19 18:03:56 +00:00
Lukas Wirth
617cd7231c
Remove SyntaxRewriter usage in eager::eager_macro_recur
2021-04-19 19:28:41 +02:00
bors[bot]
e4f7f1e1bd
Merge #8462
...
8462: Expand macros at type position r=jonas-schievink a=cynecx
Co-authored-by: cynecx <me@cynecx.net>
2021-04-19 13:01:30 +00:00
Jonas Schievink
ae84a71e4a
Expand global_asm!
to nothing
2021-04-18 18:43:45 +02:00
cynecx
cf3b4f1e20
hir_ty: Expand macros at type position
2021-04-17 16:24:56 +02:00
Jonas Schievink
e2c1da36f5
Support macros in pattern position
2021-04-11 01:25:50 +02:00
Jonas Schievink
44b04ebe43
Revert "Rewrite #[derive]
removal to be based on AST"
...
This reverts commit 7e78aebc8f
.
2021-04-10 20:30:28 +02:00
Jonas Schievink
050dc93e00
Revert "Use pub(crate)
"
...
This reverts commit c51213c2e7
.
2021-04-10 20:30:24 +02:00
Jonas Schievink
526dc4b5f5
Revert "Use name![derive]
"
...
This reverts commit d6187de4cd
.
2021-04-10 20:30:19 +02:00
Jonas Schievink
d6187de4cd
Use name![derive]
2021-04-09 14:50:42 +02:00
Jonas Schievink
c51213c2e7
Use pub(crate)
2021-04-09 14:24:31 +02:00
Jonas Schievink
7e78aebc8f
Rewrite #[derive]
removal to be based on AST
2021-04-09 14:10:54 +02:00
Jonas Schievink
c0dd36fd42
Store #[derive]
attribute ID along macro invoc
2021-04-09 13:38:01 +02:00
Jonas Schievink
3fcdd1bcdf
Add AttrId
to track attribute sources
2021-04-09 13:32:03 +02:00
Jonas Schievink
86b7861612
Use named fields in MacroCallKind
2021-04-08 20:43:07 +02:00
Jonas Schievink
053dac88ca
Update OUT_DIR
diagnostic to match setting
2021-04-07 20:19:28 +02:00
Jonas Schievink
3abcdc03ba
Make ast_to_token_tree
infallible
...
It could never return `None`, so reflect that in the return type
2021-04-04 01:46:45 +02:00
Jonas Schievink
6198eb74b2
Implement edition-dependent builtin panic!
macro
2021-04-03 03:12:55 +02:00
Aleksey Kladov
5c0c09c9c3
internal: document semantics for missing names
2021-03-31 13:24:08 +03:00
Edwin Cheng
a193666361
Basic Support Macro 2.0
2021-03-27 13:44:54 +08:00
bors[bot]
c8066ebd17
Merge #8201
...
8201: Fix recursive macro statements expansion r=edwin0cheng a=edwin0cheng
This PR attempts to properly handle macro statement expansion by implementing the following:
1. Merge macro expanded statements to parent scope statements.
2. Add a new hir `Expr::MacroStmts` for handle tail expression infer.
PS : The scope of macro expanded statements are so strange that it took more time than I thought to understand and implement it :(
Fixes #8171
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-27 02:57:02 +00:00
cynecx
5ff3299dd6
syntax: return owned string instead of leaking string
2021-03-26 18:30:59 +01:00
Edwin Cheng
8ce15b02de
Fix recursive macro statement expansion
2021-03-26 04:21:15 +08:00
bors[bot]
31ed164161
Merge #8134
...
8134: Correct the paths of submodules from the include! macro r=edwin0cheng a=sticnarf
This PR should fix #7846 . It mostly follows the instructions from @edwin0cheng in that issue.
Co-authored-by: Yilin Chen <sticnarf@gmail.com>
2021-03-21 17:57:45 +00:00
Yilin Chen
3bb9efb6b7
use the included file as the source of expanded include macro
...
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
2021-03-21 23:02:01 +08:00
Matthias Krüger
8a67116857
use strip_prefix() instead of starts_with and slicing (clippy::manual_strip)
2021-03-21 12:38:21 +01:00
Matthias Krüger
3d9b3a8575
remove more redundant clones (clippy::redundant_clone())
2021-03-21 12:10:39 +01:00
Jonas Schievink
93aeb16eb2
Return Either
from MacroDefId::ast_id
2021-03-19 19:56:13 +01:00
Jonas Schievink
54c78c96db
Rename derive-specific APIs
2021-03-19 14:23:13 +01:00
Jonas Schievink
c05a1a6e37
Store an AstId
for procedural macros
2021-03-18 16:11:18 +01:00
Jonas Schievink
b84efbaacf
Make MacroDefId's AstId
mandatory when possible
2021-03-18 15:37:14 +01:00
Jonas Schievink
4cf36545e6
Create AstId for builtin_derive macro in tests
2021-03-18 15:14:52 +01:00
Jonas Schievink
5f80364ede
Improve diagnostic when including nonexistent file
2021-03-17 21:56:09 +01:00
bors[bot]
f7fbea509f
Merge #8063
...
8063: couple clippy::complexity fixes r=matklad a=matthiaskrgr
avoid redundant `.into()` calls to convert T into identical T (`let x: String = String::from("hello").into();`)
use `if let Some(x)` instead of `.is_some()` + `.unwrap()`
don't clone Copy types
remove redundant wrapped ?s: `Some(Some(3)?)` can just be `Some(3)`
use `.map(|x| y)` instead of `and_then(|x| Some(y)` on `Option`s
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
2021-03-17 08:12:34 +00:00
bors[bot]
6fcb5d772f
Merge #8048
...
8048: Fix missing unresolved macro diagnostic in function body r=edwin0cheng a=brandondong
This was an issue I found while working on https://github.com/rust-analyzer/rust-analyzer/pull/7970 .
**Reproduction:**
1. Call a non-existent macro in a function body.
```
fn main() {
foo!();
}
```
2. No diagnostics are raised. An unresolved-macro-call diagnostic is expected.
3. If the macro call is instead outside of the function body, this works as expected.
I believe this worked previously and regressed in https://github.com/rust-analyzer/rust-analyzer/pull/7805 .
**Behavior prior to https://github.com/rust-analyzer/rust-analyzer/pull/7805 :**
- The unresolved-macro-call diagnostic did not exist. Instead, a macro-error diagnostic would be raised with the text "could not resolve macro [path]".
- This was implemented by adding an error to the error sink (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8L657 ).
- The error was propagated through 1a82af3527/crates/hir_def/src/body.rs (L123)
eventually reaching 1a82af3527/crates/hir_def/src/body/lower.rs (L569)
.
**Behavior after:**
- Instead of writing to the error sink, an UnresolvedMacro error is now returned (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R631 ).
- The parent caller throws away the error as its function signature is `Option<MacroCallId>` (https://github.com/rust-analyzer/rust-analyzer/pull/7805/files#diff-50a326c5ae465bd9b31ee4310186380aa06e4fa1f6b41dbc0aed5bcc656a3cb8R604 ).
- We instead now reach the warn condition (1a82af3527/crates/hir_def/src/body.rs (L124)
) and no diagnostics are created in 1a82af3527/crates/hir_def/src/body/lower.rs (L575)
.
**Fix:**
- Make sure to propagate the UnresolvedMacro error. Report the error using the new unresolved-macro-call diagnostic.
Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-03-17 07:20:28 +00:00
Brandon
a79b5673e8
Follow established ErrorEmitted pattern
2021-03-16 23:31:14 -07:00
Matthias Krüger
64b91393b8
remove uselessly wrapped ?s. (clippy::meedless_question_mark
...
let x = Some(3);
let y = Some(x?);
can just be:
let y = x
2021-03-17 02:19:40 +01:00
Matthias Krüger
048dad8c2e
don't clone types that are copy (clippy::clone_on_copy)
2021-03-17 01:56:31 +01:00
Aleksey Kladov
f5a81ec468
Upgrade rowan
...
Notably, new rowan comes with support for mutable syntax trees.
2021-03-16 16:10:49 +03:00
Edwin Cheng
8e07b23b84
Fix macro expansion for statements w/o semicolon
2021-03-16 13:44:50 +08:00
Chetan Khilosiya
0c2d4a8a77
7709: Updated the implementation.
...
The get function from impl method is updated.
and now same method used to get len and is_empty function.
2021-03-15 22:48:50 +05:30
Matthias Krüger
cad617bba0
some clippy::performance fixes
...
use vec![] instead of Vec::new() + push()
avoid redundant clones
use chars instead of &str for single char patterns in ends_with() and starts_with()
allocate some Vecs with capacity to avoid unneccessary resizing
2021-03-15 10:19:59 +01:00
bors[bot]
fe4a94fff3
Merge #7994
...
7994: Speed up mbe matching in heavy recursive cases r=edwin0cheng a=edwin0cheng
In some cases (e.g. #4186 ), mbe matching is very slow due to a lot of copy and allocation for bindings, this PR try to solve this problem by introduce a semi "link-list" approach for bindings building.
I used this [test case](https://github.com/weiznich/minimal_example_for_rust_81262 ) (for `features(32-column-tables)`) to run following command to benchmark:
```
time rust-analyzer analysis-stats --load-output-dirs ./
```
Before this PR : 2 mins
After this PR: 3 seconds.
However, for 64-column-tables cases, we still need 4 mins to complete.
I will try to investigate in the following weeks.
bors r+
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-13 13:04:45 +00:00
Edwin Cheng
f1350dd93c
add expand log
2021-03-13 20:14:21 +08:00
Jonas Schievink
bc4ecb199b
Use expect-test for builtin macro/derive tests
2021-03-10 21:05:02 +01:00
Jonas Schievink
2b8674b37e
Implement builtin cfg!
macro
2021-03-10 19:43:03 +01:00
Aleksey Kladov
842d8ad9c8
Compilation speed
2021-03-09 22:30:58 +03:00
Edwin Cheng
30402beeb2
Fix assert split exprs on comma
2021-02-28 20:46:24 +08:00
Edwin Cheng
f5bf1a9650
Fix builtin macros split exprs on comma
2021-02-28 13:06:17 +08:00
Matt Hall
a28e862825
Address further review comments
...
* Use known names for iter/iter_mut method (simplifies checking if the
method exists
* Extract code to check assist with fixtures to function
2021-02-24 19:23:12 +00:00