aboutsummaryrefslogtreecommitdiff
path: root/crates
Commit message (Collapse)AuthorAgeFilesLines
*-. Merge #8524 #8527bors[bot]2021-04-194-38/+298
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8524: Fix extract function with partial block selection r=matklad a=brandondong **Reproduction:** ```rust fn foo() { let n = 1; let mut v = $0n * n;$0 v += 1; } ``` 1. Select the snippet ($0) and use the "Extract into function" assist. 2. Extracted function is incorrect and does not compile: ```rust fn foo() { let n = 1; let mut v = fun_name(n); v += 1; } fn fun_name(n: i32) {} ``` 3. Omitting the ending semicolon from the selection fixes the extracted function: ```rust fn fun_name(n: i32) -> i32 { n * n } ``` **Cause:** - When `extraction_target` uses a block extraction (semicolon case) instead of an expression extraction (no semicolon case), the user selection is directly used as the TextRange. - However, the existing function extraction logic for blocks requires that the TextRange spans from start to end of complete statements to work correctly. - For example: ```rust fn foo() { let m = 2; let n = 1; let mut v = m $0* n; let mut w = 3;$0 v += 1; w += 1; } ``` produces ```rust fn foo() { let m = 2; let n = 1; let mut v = m let mut w = fun_name(n); v += 1; w += 1; } fn fun_name(n: i32) -> i32 { let mut w = 3; w } ``` - The user selected TextRange is directly replaced by the function call which is now in the middle of another statement. The extracted function body only contains statements that were fully covered by the TextRange and so the `* n` code is deleted. The logic for calculating variable usage and outlived variables for the function parameters and return type respectively search within the TextRange and so do not include `m` or `v`. **Fix:** - Only extract full statements when using block extraction. If a user selected part of a statement, extract that full statement. 8527: Switch introduce_named_lifetime assist to use mutable syntax tree r=matklad a=iDawer This extends `GenericParamsOwnerEdit` trait with `get_or_create_generic_param_list` method Co-authored-by: Brandon <[email protected]> Co-authored-by: Dawer <[email protected]>
| | * Finish GenericParamsOwnerEdit implsDawer2021-04-151-5/+94
| | |
| | * Switch introduce_named_lifetime assist to use mutable syntax treeDawer2021-04-143-36/+147
| | |
| * | Fix extract function with partial block selectionBrandon2021-04-151-2/+62
| | |
* | | Merge #8462bors[bot]2021-04-1916-76/+391
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8462: Expand macros at type position r=jonas-schievink a=cynecx Co-authored-by: cynecx <[email protected]>
| * | | hir_ty: cleanups and extend infinitely_recursive_macro_type testcynecx2021-04-182-8/+14
| | | |
| * | | hir_ty: keep body::Expander in TyLoweringContextcynecx2021-04-184-59/+94
| | | |
| * | | hir_def: various cleanupscynecx2021-04-183-11/+9
| | | |
| * | | hir_def: refactor expand_macro_type and cleanupscynecx2021-04-173-123/+33
| | | |
| * | | hir_def: ignore ast::Type in file_item_tree querycynecx2021-04-172-10/+11
| | | |
| * | | hir_ty: deal with TypeRef::Macro in HirFormattercynecx2021-04-172-5/+17
| | | |
| * | | hir_ty: Expand macros at type positioncynecx2021-04-1717-81/+434
| | | |
* | | | Merge #8574bors[bot]2021-04-195-41/+40
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8574: Check for rust doc code attributes like rustdoc does r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
| * | | | Check for rust doc code attributes like rustdoc doesLukas Wirth2021-04-195-45/+40
| | | | |
| * | | | Don't require all doc fences to be valid for identifying rust codeLukas Wirth2021-04-192-2/+6
| | | | |
* | | | | Merge #8565bors[bot]2021-04-191-28/+100
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8565: Fill match arms assist: add remaining arms for tuple of enums r=iDawer a=iDawer Fix for #8493 However, the assist is still flaky and does not use `hir_ty::diagnostics::match_check` Co-authored-by: Dawer <[email protected]>
| * | | | Unindent test according to the style guide.Dawer2021-04-191-23/+23
| | | | |
| * | | | Return to the status quo in #8129Dawer2021-04-181-0/+2
| | | | |
| * | | | Prevent adding useless match armsDawer2021-04-181-11/+27
| | | | |
| * | | | Test fill-match-arms assist: partial with wildcardsDawer2021-04-171-0/+34
| | | | |
| * | | | Fill partial match arms for a tuple of enumsDawer2021-04-161-17/+37
| | | | |
* | | | | Merge #8540bors[bot]2021-04-1910-29/+101
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8540: Prevent being able to rename items that are not part of the workspace r=Veykril a=Veykril This change causes renames that happen on items coming from crates outside the workspace to fail. I believe this should be the right approach, but usage of cargo's workspace might not be entirely correct for preventing these kinds of refactoring from touching things they shouldn't. I'm not entirely sure? cc #6623, this is one of the bigger footguns when it comes to refactoring, especially in combination with import aliases people tend to rename items coming from a crates dependency which this prevents. Co-authored-by: Lukas Wirth <[email protected]>
| * | | | | Better visualise control flow for change_annotation_support"Lukas Wirth2021-04-181-51/+46
| | | | | |
| * | | | | Prevent being able to rename items that are not part of the workspaceLukas Wirth2021-04-1810-15/+92
| | | | | |
* | | | | | Merge #8467bors[bot]2021-04-196-0/+269
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8467: Adds impl Deref assist r=jhgg a=jhgg This PR adds a new `generate_deref` assist that automatically generates a deref impl for a given struct field. Check out this gif: ![2021-04-11_00-33-33](https://user-images.githubusercontent.com/5489149/114296006-b38e1000-9a5d-11eb-9112-807c01b8fd0a.gif) -- I have a few Q's: - [x] Should I write more tests, if so, what precisely should I test for? - [x] I have an inline question on line 65, can someone provide guidance? :) - [x] I can implement this for `ast::TupleField` too. But should it be a separate assist fn, or should I try and jam both into the `generate_deref`? - [x] I want to follow this up with an assist on `impl $0Deref for T {` which would automatically generate a `DerefMut` impl that mirrors the Deref as well, however, I could probably use some pointers on how to do that, since I'll have to reach into the ast of `fn deref` to grab the field that it's referencing for the `DerefMut` impl. Co-authored-by: jake <[email protected]>
| * | | | | | implement field stuff toojake2021-04-191-22/+106
| | | | | | |
| * | | | | | Adds impl Deref assistjake2021-04-116-0/+185
| | | | | | |
* | | | | | | Collect inherent impls in unnamed constsJonas Schievink2021-04-192-17/+62
| | | | | | |
* | | | | | | Fix visibility of items in block modulesJonas Schievink2021-04-192-1/+21
| | | | | | |
* | | | | | | Merge #8564bors[bot]2021-04-182-0/+11
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8564: Expand `global_asm!` to nothing r=jonas-schievink a=jonas-schievink fixes https://github.com/rust-analyzer/rust-analyzer/issues/8563 bors r+ Co-authored-by: Jonas Schievink <[email protected]>
| * | | | | | | Expand `global_asm!` to nothingJonas Schievink2021-04-182-0/+11
| | | | | | | |
* | | | | | | | Merge #8561bors[bot]2021-04-182-5/+23
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8561: Accept `E<error_number>` notation in doctests r=Veykril a=ChayimFriedman2 ```` ```compile_fail,E0000 ``` ```` The code was stolen from rustdoc at https://github.com/rust-lang/rust/blob/392ba2ba1a7d6c542d2459fb8133bebf62a4a423/src/librustdoc/html/markdown.rs#L866-L867 Co-authored-by: Chayim Refael Friedman <[email protected]>
| * | | | | | | | Accept `E<error_number>` notation in doctestsChayim Refael Friedman2021-04-182-5/+23
| |/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```compile_fail,E0000 ``` The code was stolen from rustdoc at https://github.com/rust-lang/rust/blob/392ba2ba1a7d6c542d2459fb8133bebf62a4a423/src/librustdoc/html/markdown.rs#L866-L867
* | | | | | | | Merge #8560bors[bot]2021-04-182-3/+23
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8560: Escape characters in doc comments in macros correctly r=jonas-schievink a=ChayimFriedman2 Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`. This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks. This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained. We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least. Example (the keyword and primitive docs are `include!()`d at https://doc.rust-lang.org/src/std/lib.rs.html#570-578, and thus originate from macro): Before: ![image](https://user-images.githubusercontent.com/24700207/115130096-40544300-9ff5-11eb-847b-969e7034e8a4.png) After: ![image](https://user-images.githubusercontent.com/24700207/115130143-9cb76280-9ff5-11eb-9281-323746089440.png) Co-authored-by: Chayim Refael Friedman <[email protected]>
| * | | | | | | Escape characters in doc comments in macros correctlyChayim Refael Friedman2021-04-182-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously they were escaped twice, both by `.escape_default()` and the debug view of strings (`{:?}`). This leads to things like newlines or tabs in documentation comments being `\\n`, but we unescape literals only once, ending up with `\n`. This was hard to spot because CMark unescaped them (at least for `'` and `"`), but it did not do so in code blocks. This also was the root cause of #7781. This issue was solved by using `.escape_debug()` instead of `.escape_default()`, but the real issue remained. We can bring the `.escape_default()` back by now, however I didn't do it because it is probably slower than `.escape_debug()` (more work to do), and also in order to change the code the least.
* | | | | | | | Add some more error messages to fixture failure casesLukas Wirth2021-04-172-4/+6
| | | | | | | |
* | | | | | | | Add an error message to fixture errorsYoshua Wuyts2021-04-171-1/+3
| |_|_|_|/ / / |/| | | | | |
* | | | | | | nail rowan version downBernhard Schuster2021-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | The different pre versions include breaking changes, which cause build failures for the users.
* | | | | | | Handle extended key value attr in mbeEdwin Cheng2021-04-173-48/+35
| | | | | | |
* | | | | | | Fix `TestDB::module_at_position` with submodulesJonas Schievink2021-04-172-2/+72
| | | | | | |
* | | | | | | Merge #8546bors[bot]2021-04-162-2/+35
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8546: Return CallInfo for unclosed call expressions r=Veykril a=Veykril Closes #8522 bors r+ Co-authored-by: Lukas Wirth <[email protected]>
| * | | | | | | Return CallInfo for unclosed call expressionsLukas Wirth2021-04-162-2/+35
| | |_|/ / / / | |/| | | | |
* | | | | | | Merge #8542bors[bot]2021-04-168-20/+40
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8542: Include path in `unresolved-macro-call` diagnostic r=matklad a=jonas-schievink Co-authored-by: Jonas Schievink <[email protected]>
| * | | | | | | Include path in `unresolved-macro-call` diagnosticJonas Schievink2021-04-168-20/+40
| |/ / / / / /
* | | | | | | Merge #8539bors[bot]2021-04-165-7/+53
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8539: fix: Do not propose inherent traits in flyimports and import assists r=flodiebold a=SomeoneToIgnore Closes https://github.com/rust-analyzer/rust-analyzer/issues/8520 I've went with a separate method approach, since the [highlighted code](https://github.com/rust-analyzer/rust-analyzer/issues/8520#issuecomment-819856337) has not`Type` and uses `Ty` to get his data, but the code I had to change has no access to `Ty` and has `Type` only. Co-authored-by: Kirill Bulatov <[email protected]>
| * | | | | | | Exclude inherent traits from flyimportsKirill Bulatov2021-04-165-7/+53
| |/ / / / / /
* | | | / / / Fix primitive shadowing with inner itemsJonas Schievink2021-04-162-1/+25
| |_|_|/ / / |/| | | | |
* | | | | | Merge #8543bors[bot]2021-04-162-16/+24
|\ \ \ \ \ \ | |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8543: Assist fix: Fill match arms for a tuple of a single enum. r=Veykril a=iDawer This is rather a small fix addressing an issue mentioned in https://github.com/rust-analyzer/rust-analyzer/issues/8493#issuecomment-818770670 Co-authored-by: Dawer <[email protected]>
| * | | | | Fill match arms for a tuple of a single enum.Dawer2021-04-162-16/+24
| | | | | |
* | | | | | change grammarMilo2021-04-151-4/+4
| | | | | |