aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast
Commit message (Collapse)AuthorAgeFilesLines
* feat: add expr_for_loop to make in syntaxLuiz Carlos Mourão Paes de Carvalho2021-03-101-0/+3
|
* Better strip turbofishesKirill Bulatov2021-03-081-0/+4
|
* Merge #7777bors[bot]2021-03-022-5/+9
|\ | | | | | | | | | | | | | | 7777: Implement line<->block comment assist r=Veykril a=djrenren Fixes: https://github.com/rust-analyzer/rust-analyzer/issues/6515 Co-authored-by: John Renner <[email protected]>
| * Implement line<->block comment assistJohn Renner2021-02-252-5/+9
| |
* | Add tests for apply_demorganLukas Wirth2021-02-241-2/+5
|/
* Fix incorrect missing field diagnostic with box patternsLaurențiu Nicola2021-02-201-4/+13
|
* Revert "Replace usage of ast::NameOrNameRef with ast::NameLike"Lukas Wirth2021-02-171-16/+21
| | | | This reverts commit e1dbf43cf85f84c3a7e40f9731fc1f7ac96f8979.
* Replace usage of ast::NameOrNameRef with ast::NameLikeLukas Wirth2021-02-171-21/+16
|
* Implement ast::AstNode for NameLike and move it to node_extLukas Wirth2021-02-161-0/+46
|
* Merge #7620bors[bot]2021-02-161-9/+50
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 7620: Support control flow in `extract_function` assist r=matklad a=cpud36 Support `return`ing from outer function, `break`ing and `continue`ing outer loops when extracting function. # Example Transforms ```rust fn foo() -> i32 { let items = [1,2,3]; let mut sum = 0; for &item in items { <|>if item == 42 { break; }<|> sum += item; } sum } ``` Into ```rust fn foo() -> i32 { let items = [1,2,3]; let mut sum = 0; for &item in items { if fun_name(item) { break; } sum += item; } sum } fn fun_name(item: i32) -> bool { if item == 42 { return true; } false } ``` ![add_explicit_type_infer_type](https://user-images.githubusercontent.com/4218373/107544222-0fadf280-6bdb-11eb-9625-ed6194ba92c0.gif) # Features Supported variants - break and function does not return => uses `bool` and plain if - break and function does return => uses `Option<T>` and matches on it - break with value and function does not return => uses `Option<T>` and if let - break with value and function does return => uses `Result<T, U>` and matches on t - same for `return` and `continue`(but we can't continue with value) Assist does handle nested loops and nested items(like functions, modules, impls) Try `expr?` operator is allowed together with `return Err(_)` and `return None`. `return expr` is not allowed. # Not supported ## Mixing `return` with `break` or `continue` If we have e.g. a `return` and a `break` in the selected code, it is unclear what the produced code should look like. We can try `Result<T, Option<U>>` or something like that, but it isn't idiomatic, nor it is established. Otherwise, implementation is relatively simple. ## `break` with label Not sure how to handle different labels for multiple `break`s. [edit] implemented try `expr?` Co-authored-by: Vladyslav Katasonov <[email protected]>
| * allow try expr? when extacting functionVladyslav Katasonov2021-02-131-0/+3
| |
| * handle return, break and continue when extracting functionVladyslav Katasonov2021-02-131-9/+47
| |
* | Don't rename field record patterns directlyLukas Wirth2021-02-131-3/+2
|/
* Refactor reference searching to work with the astLukas Wirth2021-02-121-4/+26
|
* AdtDef -> AdtAleksey Kladov2021-02-071-19/+19
|
* allow modifications of vars from outer scope inside extracted functionVladyslav Katasonov2021-02-031-1/+1
| | | | | It currently allows only directly setting variable. No `&mut` references or methods.
* Fix ast::String::value not properly escaping in some casesLukas Wirth2021-01-301-2/+19
|
* .Aleksey Kladov2021-01-193-14/+14
|
* :arrow_up: rowanAleksey Kladov2021-01-191-1/+1
|
* Add `MacroType` syntaxJonas Schievink2021-01-181-2/+31
|
* Merge #7291bors[bot]2021-01-182-15/+25
|\ | | | | | | | | | | | | | | 7291: Wrap remaining self/super/crate in Name{Ref} r=matklad a=Veykril That should be the remaining special casing for `self` 🎉 Co-authored-by: Lukas Wirth <[email protected]>
| * Wrap remaining self/super/crate in Name{Ref}Lukas Wirth2021-01-152-15/+25
| |
* | Add Unmerge Use assistunexge2021-01-151-2/+6
|/
* Handle self/super/crate in PathSegment as NameRefLukas Wirth2021-01-152-7/+21
|
* Add support for yiled keywordDaiki Ihara2021-01-151-1/+33
|
* Merge #7218bors[bot]2021-01-101-1/+1
|\ | | | | | | | | | | | | | | 7218: Fix typos r=Veykril a=regexident Apart from the very last commit on this PR (which fixes a public type's name) all changes are non-breaking. Co-authored-by: Vincent Esche <[email protected]>
| * Fixed typos in code commentsVincent Esche2021-01-091-1/+1
| |
* | Replace SyntaxKind usage with T! macro where applicableLukas Wirth2021-01-101-1/+1
|/
* Rename expr -> tail_exprAleksey Kladov2021-01-051-1/+1
|
* Fix warnings on rust-nightlycynecx2021-01-021-2/+2
|
* indentationAdnoC2020-12-301-3/+3
|
* Smarter bracketed use diagnosticAdnoC2020-12-301-0/+8
|
* Implement const block inferenceLukas Wirth2020-12-231-0/+4
|
* Merge #7010bors[bot]2020-12-231-1/+32
|\ | | | | | | | | | | | | | | | | | | | | | | 7010: Update ungrammar for const block patterns r=matklad a=Veykril Fixes #6848 Adds const blocks and const block patterns to the AST and parses them. Blocked on https://github.com/rust-analyzer/ungrammar/pull/17/, will merge that PR there once this one gets the OK so I can remove the local ungrammar dependency path and fix the Cargo.lock. Co-authored-by: Lukas Wirth <[email protected]>
| * Update ungrammar for const block patternsLukas Wirth2020-12-231-1/+32
| |
* | Document `make` module designAleksey Kladov2020-12-231-1/+7
|/
* Minor, cleanup APIAleksey Kladov2020-12-181-0/+3
|
* Merge #6896bors[bot]2020-12-162-30/+44
|\ | | | | | | | | | | | | | | | | | | | | | | 6896: Node-ify lifetimes r=jonas-schievink a=Veykril Let's see if this passes the tests 🤞 Depends on https://github.com/rust-analyzer/ungrammar/pull/15 Co-authored-by: Jonas Schievink <[email protected]> Co-authored-by: Jonas Schievink <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
| * Node-ify lifetimesLukas Wirth2020-12-162-30/+44
| |
* | Merge #6897bors[bot]2020-12-162-1/+89
|\| | | | | | | | | | | | | | | | | | | | | | | | | 6897: Basic support for macros 2.0 r=jonas-schievink a=jonas-schievink This adds support for (built-in-only) macros 2.0, and removes some hacks used for builtin derives, which are declared via macros 2.0 in libcore. First steps for https://github.com/rust-analyzer/rust-analyzer/issues/2248. Blocked on https://github.com/rust-analyzer/ungrammar/pull/16. Co-authored-by: Jonas Schievink <[email protected]> Co-authored-by: Jonas Schievink <[email protected]>
| * Basic support for decl macros 2.0Jonas Schievink2020-12-152-1/+89
| |
* | Merge #6894bors[bot]2020-12-161-0/+3
|\ \ | |/ |/| | | | | | | | | | | 6894: Parenthesize composite if condition before inverting in invert-if assist r=matklad a=Jesse-Bakker Fixes #6867 Co-authored-by: Jesse Bakker <[email protected]>
| * Parenthesize composite if condition before inverting in invert-if assistJesse Bakker2020-12-151-0/+3
| |
* | Move to upstream `macro_rules!` modelJonas Schievink2020-12-152-21/+39
|/
* Remove some redundant allocationsJeremy Kolb2020-12-122-2/+2
|
* Properly fetch inner and outer docs on hir-levelLukas Wirth2020-12-091-0/+8
|
* Simplify ast::Comment api surfaceLukas Wirth2020-12-081-10/+15
|
* Keep doc attribute orderLukas Wirth2020-12-072-41/+35
|
* Merge #6719bors[bot]2020-12-071-0/+1
|\ | | | | | | | | | | | | | | 6719: Use items can also have doc comments r=matklad a=Veykril Prior to this change modules show more docs than they have cause they inherit the docs from documented use items inside of them. Co-authored-by: Lukas Wirth <[email protected]>
| * Use items can also have doc commentsLukas Wirth2020-12-041-0/+1
| |