Skip to content

Fix Result::chain, Result::chain_err to not require Copy bounds. - #3954

Merged
brson merged 1 commit into
rust-lang:incomingfrom
burg:result-chain
Nov 13, 2012
Merged

Fix Result::chain, Result::chain_err to not require Copy bounds.#3954
brson merged 1 commit into
rust-lang:incomingfrom
burg:result-chain

Conversation

@burg

@burgburg commented Nov 13, 2012

Copy link
Copy Markdown

gogogo

brson added a commit that referenced this pull request Nov 13, 2012
Fix Result::chain, Result::chain_err to not require Copy bounds.
@brson
brson merged commit 1ead8aa into rust-lang:incomingNov 13, 2012
@brson

Copy link
Copy Markdown
Contributor

Thanks!

RalfJung added a commit to RalfJung/rust that referenced this pull request Nov 10, 2024
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
4008: tests: add more info about what failed in tidy tests r=matklad a=bnjjj
Separate PR from rust-lang#3954
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
3954: Improve autocompletion by looking on the type and name r=matklad a=bnjjj
This tweet (https://twitter.com/tjholowaychuk/status/1248918374731714560) gaves me the idea to implement that in rust-analyzer.
Basically for this first example I made some examples when we are in a function call definition. I look on the parameter list to prioritize autocompletions for the same types and if it's the same type + the same name then it's displayed first in the completion list.
So here is a draft, first step to open a discussion and know what you think about the implementation. It works (cf tests) but maybe I can make a better implementation at some places. Be careful the code needs some refactoring to be better and concise.
PS: It was lot of fun writing this haha
Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
U007D pushed a commit to U007D/rust-mos that referenced this pull request Aug 21, 2026
7904: Improved completion sorting r=JoshMcguigan a=JoshMcguigan
I was working on extending rust-lang#3954 to apply completion scores in more places (I'll have another PR open for that soon) when I discovered that actually completion sorting was not working for me at all in `coc.nvim`. This led me down a bit of a rabbit hole of how coc and vs code each sort completion items.
Before this PR, rust-analyzer was setting the `sortText` field on completion items to `None` if we hadn't applied any completion score for that item, or to the label of the item with a leading whitespace character if we had applied any completion score. Completion score is defined in rust-analyzer as an enum with two variants, `TypeMatch` and `TypeAndNameMatch`. In vs code the above strategy works, because if `sortText` isn't set [they default it to the label](microsoft/vscode@b4ead4e). However, coc [does not do this](https://github.com/neoclide/coc.nvim/blob/e211e361475a38b146a903b9b02343551c6cd372/src/completion/complete.ts#L245).
I was going to file a bug report against coc, but I read the [LSP spec for the `sortText` field](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion) and I feel like it is ambiguous and coc could claim what they do is a valid interpretation of the spec.
Further, the existing rust-analyzer behavior of prepending a leading whitespace character for completion items with any completion score does not handle sorting `TypeAndNameMatch` completions above `TypeMatch` completions. They were both being treated the same.
The first change this PR makes is to set the `sortText` field to either "1" for `TypeAndNameMatch` completions, "2" for `TypeMatch` completions, or "3" for completions which are neither of those. This change works around the potential ambiguity in the LSP spec and fixes completion sorting for users of coc. It also allows `TypeAndNameMatch` items to be sorted above just `TypeMatch` items (of course both of these will be sorted above completion items without a score). The second change this PR makes is to use the actual completion scores for ref matches. The existing code ignored the actual score and always assumed these would be a high priority completion item.
#### Before
Here coc just sorts based on how close the items are in the file.
![image](https://user-images.githubusercontent.com/22216761/110249880-46063580-7f2d-11eb-9233-91a2bbd48238.png)
#### After
Here we correctly get `zzz` first, since that is both a type and name match. Then we get `ccc` which is just a type match.
![image](https://user-images.githubusercontent.com/22216761/110249883-4e5e7080-7f2d-11eb-9269-a3bc133fdee7.png)
Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@burg@brson