about summary refs log tree commit diff
path: root/crates
AgeCommit message (Collapse)AuthorLines
2022-01-06Expand attribute macros on impl and trait itemsJonas Schievink-73/+200
2022-01-06Always put a space after impl in macro pretty-printingJonas Platte-5/+5
… regardless of whether the next symbol is punctuation or not.
2022-01-06fix: remove brackets if no generic typesCôme ALLART-49/+60
2022-01-05Merge #11204bors[bot]-1/+34
11204: fix: `replace_qualified_name_with_use` does not use full item path for replacements r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05fix: `replace_qualified_name_with_use` does not use full item path for ↵Lukas Wirth-1/+34
replacements
2022-01-05Merge #11195 #11202bors[bot]-5/+366
11195: Correctly pass through reference modifiers when extracting a variable r=Veykril a=Vannevelj Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10034 This will parse the field expression and look at whether it is marked `&` or `&mut` and include a modifier if appropriate. The original issue only mentions `&mut params` but I've found that this issue also occurs for `&mut locals` as well as `&params` and `&locals` so I've also added tests for them. I'd definitely be interested in hearing where I can make my code more idiomatic for Rust. 11202: fix: Fix `apply_demorgan` assist hanging for certain binary expressions r=Veykril a=Veykril Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10963 bors r+ Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com> Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05fix: Fix `apply_demorgan` assist hanging for certain binary expressionsLukas Wirth-3/+14
2022-01-05removed double matchingJeroen Vannevel-17/+4
2022-01-05no PathExpr armJeroen Vannevel-2/+1
2022-01-05.clone() over .to_owned()Jeroen Vannevel-1/+1
2022-01-05less wordy ref_kind assignmentJeroen Vannevel-10/+4
2022-01-05Merge #11201bors[bot]-27/+40
11201: fix: Fix completions not considering ancestor items for attribute search r=Veykril a=Veykril Turns out we never filled the `CompletionContext` with the attribute expansion of attributed impls and traits when typing in the assoc items, as we were only considering the assoc item to have an attribute to expand. bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05fix: Fix completions not considering ancestor items for attribute searchLukas Wirth-27/+40
2022-01-05Merge #11200bors[bot]-1/+42
11200: Always put a space after dyn in macro pretty-printing r=Veykril a=jplatte Fixes #11100. Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
2022-01-05Always put a space after `dyn` in macro pretty-printingJonas Platte-1/+1
… regardless of whether the next symbol is punctuation or not. Fixes issue 11100.
2022-01-05Add failing test case for issue 11100Jonas Platte-0/+41
2022-01-05simplifyJonas Schievink-48/+43
2022-01-05Remove unused lifetimeAaron Hill-1/+1
2022-01-05removed trailing whitespaceJeroen Vannevel-4/+4
2022-01-05commentJeroen Vannevel-0/+1
2022-01-05additional test for a reference local (on top of mutable reference local)Jeroen Vannevel-2/+68
2022-01-05failing test for a reference localJeroen Vannevel-0/+66
2022-01-05Don't include a ref if none was declaredJeroen Vannevel-3/+49
2022-01-05support ref params as wellJeroen Vannevel-4/+109
2022-01-05correctly handle mutable referencesJeroen Vannevel-2/+88
2022-01-05fix(gen-doc-assist): remove lifetimes in description of `new`Côme ALLART-1/+124
2022-01-04Merge #11190bors[bot]-24/+91
11190: fix(completions): improve fn_param r=dbofmmbt a=dbofmmbt - insert commas around when necessary - only suggest `self` completions when param list is empty - stop suggesting completions for identifiers which are already on the param list Closes #11085 Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2022-01-04refactor: apply review suggestionsEduardo Canellas-14/+21
2022-01-04Merge #11112bors[bot]-27/+94
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi cc #8655 Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-05Evaluate constants in array repeat expressionhkalbasi-27/+94
2022-01-04remove forgotten dbg macroEduardo Canellas-1/+0
2022-01-04improve logic for trailing comma additionEduardo Canellas-2/+12
2022-01-04fix(completions): improve fn_paramEduardo Canellas-24/+75
- insert commas around when necessary - only suggest `self` completions when param list is empty - stop suggesting completions for identifiers which are already on the param list
2022-01-04Remove lossy `Definition::from_token`/`Definition::from_node` methodsLukas Wirth-92/+91
2022-01-04Merge #11157bors[bot]-57/+131
11157: internal: Remove `SemanticScope::speculative_resolve_as_mac` r=Veykril a=Veykril Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11132 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04add better default behavior on fill struct fields diagnosticBenjamin Coenen-12/+122
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-04Rename and use the 1.55 ABI for 1.54Laurențiu Nicola-9/+9
2022-01-04Merge #11184bors[bot]-1/+63
11184: Correctly pass through mutable parameter references when extracting a function r=Veykril a=Vannevelj Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10277 I have based this investigation based on my understanding of [the Borrowing chapter](https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html) but I wasn't able to debug the test runs or see it in action in an IDE. I'll try to figure out how to do that for future PRs but for now, the tests seem to confirm my understanding. I'll lay out my hypothesis below. Here we define the parameters for the to-be-generated function: https://github.com/rust-analyzer/rust-analyzer/blob/7409880a07803c34590ad162d7854061145c6eae/crates/ide_assists/src/handlers/extract_function.rs#L882 Three values in particular are important here: `requires_mut`, `is_copy` and `move_local`. These will in turn be used here to determine the kind of parameter: https://github.com/rust-analyzer/rust-analyzer/blob/7409880a07803c34590ad162d7854061145c6eae/crates/ide_assists/src/handlers/extract_function.rs#L374-L381 and then here to determine what transformation is needed for the calling argument: https://github.com/rust-analyzer/rust-analyzer/blob/7409880a07803c34590ad162d7854061145c6eae/crates/ide_assists/src/handlers/extract_function.rs#L383-L390 which then gets transformed here: https://github.com/rust-analyzer/rust-analyzer/blob/7409880a07803c34590ad162d7854061145c6eae/crates/syntax/src/ast/make.rs#L381-L383 What I believe is happening is that * `requires_mut` is `false` (it already is marked as mutable), * `is_copy` is `false` (`Foo` does not implement `Copy`), and * `move_local` is `false` (it has further usages) According to the pattern matching in `fn kind()`, that would lead to `ParamKind::SharedRef` which in turn applies a transformation that prepends `&`. However if I look at the chapter on borrowing then we only need to mark an argument as a reference if we actually own it. In this case the value is passed through as a reference parameter into the current function which means we never had ownership in the first place. By including the additional check for a reference parameter, `move_local` now becomes `true` and the resulting parameter is now `ParamKind::Value` which will avoid applying any transformations. This was further obscured by the fact that you need further usages of the variable or `move_local` would be considered `true` after all. I didn't follow it in depth but it appears this idea applies for both the generated argument and the generated parameter. There are existing tests that account for `&mut` values but they refer to local variables for which we do have ownership and as such they didn't expose this issue. Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-01-04reduced the tests to their bare essenceJeroen Vannevel-12/+6
2022-01-04Merge #11186bors[bot]-15/+15
11186: minor: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04minor: SimplifyLukas Wirth-15/+15
2022-01-04additional test without further usagesJeroen Vannevel-1/+32
2022-01-04Correctly pass through mutable references when extracting a functionJeroen Vannevel-1/+38
2022-01-03Merge #11061bors[bot]-54/+317
11061: Support "move if to guard" for if else chains r=weirane a=weirane The idea is to first parse the if else chain into a vector of `(Condition, BlockExpr)`s until we reach an iflet branch, an else branch, or the end (the tail). Then add the match arms with guard for the vector, and add the tail with no if guard. Because the whole original match arm is replaced and the generated code doesn't have redundent commas, I removed redundent commas in some test cases. Closes #11033. Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-03Update generated testsWang Ruochen-1/+0
2022-01-03Don't add pattern if there is a catch all afterwardsWang Ruochen-9/+69
2022-01-03Merge #11115bors[bot]-59/+84
11115: internal: refactor: avoid separate traversal in replace filter map next with find map r=Veykril a=rainy-me fix: #7428 Co-authored-by: rainy-me <github@yue.coffee>
2022-01-03give `resolve_derive_ident` a more robust apiLukas Wirth-22/+39
2022-01-03fix: don't panic on seeing an unexpected offsetDavid Hotham-30/+38
2022-01-03Merge #11180bors[bot]-0/+14
11180: minor: add missing test r=matklad a=matklad This test kills the following mutant: diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs index 9d2b1da9a..055d9a733 100644 --- a/crates/mbe/src/tt_iter.rs +++ b/crates/mbe/src/tt_iter.rs `@@` -134,7 +134,7 `@@` impl<'a> TtIter<'a> { self.inner = self.inner.as_slice()[res.len()..].iter(); let res = match res.len() { 1 => Some(res[0].cloned()), - 0 => None, + // 0 => None, _ => Some(tt::TokenTree::Subtree(tt::Subtree { delimiter: None, token_trees: res.into_iter().map(|it| it.cloned()).collect(), bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>