aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand
Commit message (Collapse)AuthorAgeFilesLines
...
* Use named fields in `MacroCallKind`Jonas Schievink2021-04-084-16/+18
|
* Update `OUT_DIR` diagnostic to match settingJonas Schievink2021-04-071-1/+1
|
* Make `ast_to_token_tree` infallibleJonas Schievink2021-04-043-13/+7
| | | | It could never return `None`, so reflect that in the return type
* Implement edition-dependent builtin `panic!` macroJonas Schievink2021-04-033-2/+26
|
* internal: document semantics for missing namesAleksey Kladov2021-03-311-0/+9
|
* Basic Support Macro 2.0Edwin Cheng2021-03-273-23/+41
|
* Merge #8201bors[bot]2021-03-271-17/+42
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * Fix recursive macro statement expansionEdwin Cheng2021-03-251-17/+42
| |
* | syntax: return owned string instead of leaking stringcynecx2021-03-261-2/+2
|/
* Merge #8134bors[bot]2021-03-213-26/+76
|\ | | | | | | | | | | | | | | 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 <[email protected]>
| * use the included file as the source of expanded include macroYilin Chen2021-03-213-26/+76
| | | | | | | | Signed-off-by: Yilin Chen <[email protected]>
* | use strip_prefix() instead of starts_with and slicing (clippy::manual_strip)Matthias Krüger2021-03-211-3/+2
| |
* | remove more redundant clones (clippy::redundant_clone())Matthias Krüger2021-03-211-1/+1
|/
* Return `Either` from `MacroDefId::ast_id`Jonas Schievink2021-03-192-5/+6
|
* Rename derive-specific APIsJonas Schievink2021-03-192-5/+5
|
* Store an `AstId` for procedural macrosJonas Schievink2021-03-184-6/+6
|
* Make MacroDefId's `AstId` mandatory when possibleJonas Schievink2021-03-186-34/+39
|
* Create AstId for builtin_derive macro in testsJonas Schievink2021-03-181-13/+28
|
* Improve diagnostic when including nonexistent fileJonas Schievink2021-03-171-10/+11
|
* Merge #8063bors[bot]2021-03-172-7/+4
|\ | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * remove uselessly wrapped ?s. (clippy::meedless_question_markMatthias Krüger2021-03-171-2/+2
| | | | | | | | | | | | | | | | let x = Some(3); let y = Some(x?); can just be: let y = x
| * don't clone types that are copy (clippy::clone_on_copy)Matthias Krüger2021-03-171-5/+2
| |
* | Merge #8048bors[bot]2021-03-171-1/+1
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body.rs#L123 eventually reaching https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/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 (https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/crates/hir_def/src/body.rs#L124) and no diagnostics are created in https://github.com/rust-analyzer/rust-analyzer/blob/1a82af3527e476d52410ff4dfd2fb4c57466abcb/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 <[email protected]>
| * Follow established ErrorEmitted patternBrandon2021-03-171-1/+1
| |
* | Upgrade rowanAleksey Kladov2021-03-161-1/+4
| | | | | | | | Notably, new rowan comes with support for mutable syntax trees.
* | Fix macro expansion for statements w/o semicolonEdwin Cheng2021-03-161-1/+2
|/
* 7709: Updated the implementation.Chetan Khilosiya2021-03-151-0/+2
| | | | | The get function from impl method is updated. and now same method used to get len and is_empty function.
* some clippy::performance fixesMatthias Krüger2021-03-151-1/+1
| | | | | | | 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
* Merge #7994bors[bot]2021-03-131-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * add expand logEdwin Cheng2021-03-131-0/+2
| |
* | Use expect-test for builtin macro/derive testsJonas Schievink2021-03-103-80/+65
| |
* | Implement builtin `cfg!` macroJonas Schievink2021-03-104-2/+19
| |
* | Compilation speedAleksey Kladov2021-03-091-1/+3
|/
* Fix assert split exprs on commaEdwin Cheng2021-02-281-17/+2
|
* Fix builtin macros split exprs on commaEdwin Cheng2021-02-281-20/+25
|
* Address further review commentsMatt Hall2021-02-241-0/+1
| | | | | | * Use known names for iter/iter_mut method (simplifies checking if the method exists * Extract code to check assist with fixtures to function
* Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"Lukas Wirth2021-02-171-10/+3
| | | | This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.
* Replace usage of ast::NameOrNameRef with ast::NameLikeLukas Wirth2021-02-171-3/+10
|
* add more countsAleksey Kladov2021-01-271-1/+3
|
* Disallow non-boolean literals in concat!Laurențiu Nicola2021-01-251-2/+4
|
* Unquote strings and handle boolean literals in concat!Laurențiu Nicola2021-01-251-16/+8
|
* Identify methods using functions ids rather than string namesPhil Ellison2021-01-231-0/+3
|
* Merge #7359bors[bot]2021-01-201-6/+14
|\ | | | | | | | | | | | | | | | | | | 7359: ItemTree: store a mapping from blocks to inner items r=jonas-schievink a=jonas-schievink To do name resolution within block expressions, we need to know which inner items are located inside each block expression. This adds such a mapping to `ItemTree`, replacing the previous one, which was seemingly unused other than to access all the inner items. This also assigns `AstId`s to block expressions, which is needed to store the mapping in salsa. Co-authored-by: Jonas Schievink <[email protected]>
| * Record `FileAstId`s for block expressiosnJonas Schievink2021-01-191-6/+14
| | | | | | | | | | Every block expression may contain inner items, so we need to be able to refer to any block expression and use it as a salsa key.
* | .Aleksey Kladov2021-01-192-5/+5
| |
* | :arrow_up: rowanAleksey Kladov2021-01-191-1/+1
|/
* shrink_to_fit `TokenMap`'s backing storageJonas Schievink2021-01-181-0/+2
|
* Merge #7292bors[bot]2021-01-181-2/+2
|\ | | | | | | | | | | | | | | | | | | 7292: Swap assert_eq_text\!(expected, actual) r=matklad a=u5surf Fixes #7283 Swap assert_eq_text parameters in the order (expected, actual) Co-authored-by: yugo-horie <[email protected]>
| * Swap assert_eq_text\!(expected, actual)yugo-horie2021-01-161-2/+2
| |
* | :arrow_up: arenaAleksey Kladov2021-01-171-1/+1
| |