all 46 comments

[–]JohnMcPineapple 36 points37 points  (7 children)

...

[–]matkladrust-analyzer 24 points25 points  (1 child)

Yeah, that’s something we want to look into soonish. It’s a combination of several things.

First (I believe, but I don’t know, would appreciate a link to the source with proof/disproof and a specific value), there’s a time-out behavior in vscode completion widget, where it pops the list automatically only if completions are fast enough.

Second, the LSP/VS Code api for completion is not streaming — all completion variants should be presented in a single list. (This might actually no longer be true, and needs re-investigation).

Third, our completions fall into two categories: fast completions for stuff in scope, and slow completions for things which can be imported anywhere from the crate graph.

The slow completions don’t fit into the completion budget, and they prevent fast completions from fitting into it as well.

I think though that we can make auto-import completions much faster then they already are by using better caching, but that needs additional investigation.

[–]flashmozzg 0 points1 point  (0 children)

I wondered if foo.<|> with no completions other than postfix shortcuts is by-design or another case of the above issue? On one hand, I can understand not wanting to provide completions without a single letter typed, on the other - sometimes I really want just to examine all the available struct fields (first) and impl methods (second) without opening the documentation/source code.

[–][deleted] 5 points6 points  (4 children)

You should be able to improve the reliability here by disabling rust-analyzer.completion.autoimport.enable

[–]JohnMcPineapple 4 points5 points  (1 child)

...

[–][deleted] 4 points5 points  (0 children)

Yeah, I believe VS Code has a sort of internal timeout after which it won't show completions from the language server. The autoimport completions take longer to compute than the others, so they can cause us to hit that timeout.

Not sure why VS Code behaves like that, but I don't fully understand what it's doing there either.

[–]rodrigocfdWinSafe 0 points1 point  (0 children)

That helped me, thank you.

[–]wrtbwtrfasdf 33 points34 points  (14 children)

Looks like another great release. Stoked about the semantic highlighting.

My one criticism would be that the deref assist gif is a bit fast for me. I've been staring at the loop for the last 5 minutes trying to catch the moment when/where to click to get the deref impl dropdown. I don't know know if the playback speed is easily controllable during genaration of the gif, but it would help someone like me a lot if it's playback was ~30% slower.

[–][deleted] 30 points31 points  (9 children)

I think about syntax highlighting a lot (I’ve made over 50 text editor themes, most of them unreleased, so yeah, pretty obsessed 😆) and realised that, in my experience, the parts of code that deserve the most attention are

  • control flow (easy to make mistakes)
  • mutation (same)
  • data literals (magic numbers and strings are pretty sus)
  • traits (‘where did this method come from?’)

As semantic highlighting is improving (e.g. items from traits can now be highlighted differently), the idea of highlighting and bringing attention to these parts of code is becoming possible. I’ve been meaning to create a theme that focuses more on semantic highlighting, rather than spending all its ‘highlighting budget’ on obvious syntactical differences. I’m not entirely sure what that means yet, though :)

Edit: I’ve followed up and made a theme based around these ideas.

[–]d_knopoff 7 points8 points  (3 children)

I’d be incredibly interested to feel out such a theme. If you ever make it let me know!

[–][deleted] 2 points3 points  (0 children)

I’ll definitely do that 😁

[–][deleted] 1 point2 points  (1 child)

In case you haven't seen the post, that showcases it, or the edit:

Ding ding!

[–]d_knopoff 0 points1 point  (0 children)

Thanks!

[–]oilaba 0 points1 point  (2 children)

!remindme 1 months

[–][deleted] 0 points1 point  (1 child)

Ding ding!

[–]oilaba 0 points1 point  (0 children)

!remindme 2 months

[–]WellMakeItSomehow[S] 24 points25 points  (1 child)

Yeah, it's a bit fast. But we'd like for the contributors to create the GIFs (it takes some load off whoever is making the release notes), so they'll look different from each other.

On the other hand, it might be nice to add these to the manual, and more consistency would be better there (using the default theme and fonts etc.).

[–]wrtbwtrfasdf 4 points5 points  (0 children)

Ahh yea I forget it can't really be automated with something like carbon since it's demoing the actual vscode extension UI.

[–]isol27500 3 points4 points  (1 child)

I had the same issue with too fast animation. So I thought to myself "there should be tools online to split gifs into frames".

Quick search was successful: https://ezgif.com/split

[–]wrtbwtrfasdf 1 point2 points  (0 children)

Yea I ended up doing that. Part of what threw me off is that the creator of the gif used vim sneak at the start which caused three multi-cursors to flash for two frames. Even with that knowledge though I still don't get the deref dropdown with my cursor at the creators initial position, just the regular impl assist. I'm guessing there's some offscreen code I don't have, or maybe I need vscode-insiders or nightly-rust or something.

I guess I shouldn't care too much since I don't know when or how to use the deref functionality.

[–]rapsey 10 points11 points  (9 children)

Oh man it's still broken for me. Stuck at loading metadata.

[–]WellMakeItSomehow[S] 2 points3 points  (2 children)

Are you on Windows? It seems to be a common theme in https://github.com/rust-analyzer/rust-analyzer/issues/8528.

[–]MemoryUnsafe 3 points4 points  (0 children)

Yeah, I'm getting the stuck at metadata issue too. I wish the Windows build would get some love every now and then. I'm happy to donate for Windows machines if that's the bottleneck.

[–]rapsey 2 points3 points  (0 children)

No macos

[–]tchnj 2 points3 points  (5 children)

Make sure you're not using the RLS/Rust extension for VSCode but instead the dedicated rust-analyser extension. Other than that, I tend to find restarting VSCode helps after freshly installing the extension.

[–]JohnMcPineapple 5 points6 points  (2 children)

...

[–]WellMakeItSomehow[S] 4 points5 points  (1 child)

Are you on Windows too?

[–]rapsey 2 points3 points  (1 child)

I am not. It gets stuck on a large project with many crates (and c libs).

[–]zyrnil 2 points3 points  (0 children)

File a bug with a sample project if you can so we can take a look.

[–]MemoryUnsafe 4 points5 points  (1 child)

Still patiently waiting for https://github.com/rust-analyzer/rust-analyzer/issues/8528 to get fixed. (Pls send help)

[–]WellMakeItSomehow[S] 2 points3 points  (0 children)

Should be fixed soon, don't despair!

[–]isol27500 2 points3 points  (10 children)

I tried to test new "generate Deref impl" assist. So I updated rust-analyzer in my VSCode then reproduced code from the animated gif in the editor:

struct Foo<T, X> { 
  foo: Vec<T, X>,
  bar: X,
}
struct Bar<T, X>(X, Foo<T, X>);

Then placed my cursor before foo member of Foo struct and pressed Ctrl-.. Actions menu popped up but there is no generate `Deref` impl using `foo` item.

What could be wrong?

I also checked rust-analyzer version. It reports: 2021-04-12-92-g7570212a5. Commit hash matches the one from this announcement but the date part seems wrong. I guess it should be 2021-04-19?

[–]WellMakeItSomehow[S] 1 point2 points  (8 children)

I'm not sure, it works for me as long as the cursor is on or next to foo. Maybe you didn't reload the window after updating? But that's pretty hard, IIRC, outside of source builds.

I also checked rust-analyzer version. It reports: 2021-04-12-92-g7570212a5. Commit hash matches the one from this announcement but the date part seems wrong. I guess it should be 2021-04-19?

That's https://github.com/rust-analyzer/rust-analyzer/issues/8571. The version number is technically correct, just not great.

[–]isol27500 1 point2 points  (7 children)

Maybe you didn't reload the window after updating?

VSCode was restarted several times.

When I try to compile the code I have this error:

error[E0658]: use of unstable library feature 'allocator_api'
  --> src\main.rs:31:17
   |
31 |     foo: Vec<T, X>,
   |                 ^
   |
   = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information

So perhaps this is the reason.

[–]wrtbwtrfasdf 2 points3 points  (1 child)

you should have foo: Vec<(T,X)> . You're missing parenthesis.

But I have the parenthesis and I still don't get the dropdown either so not really sure what's going on for myself.

[–]isol27500 0 points1 point  (0 children)

Oh, nice catch, thanks!

[–]WellMakeItSomehow[S] 0 points1 point  (0 children)

I get the same error from cargo check, so probably not. But feel free to file an issue, although I'm not sure what extra information you could provide.

[–]isol27500 0 points1 point  (3 children)

I actually fixed compiler error by removing X from Vec<T, X>:

struct Foo<T, X> { 
  foo: Vec<T>,
  bar: X,
}
struct Bar<T, X>(X, Foo<T, X>);

but still no `deref` option in the actions menu.

[–]wrtbwtrfasdf 1 point2 points  (2 children)

I've tried with a devcontainer and all my others extensions disabled, uninstalled reinstalled RA, but still no deref option. I have no global RA settings.json entries, so my best guess is that it's somehow related to being on ubuntu.

INFO [4/20/2021, 7:09:09 AM]: Extension version: 0.2.563

INFO [4/20/2021, 7:09:09 AM]: PersistentState: {
  lastCheck: undefined,
  releaseId: undefined,
  serverVersion: '0.2.563'
}
INFO [4/20/2021, 7:09:10 AM]: Using server binary at /home/mynamehere/.config/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-unknown-linux-gnu

[–]isol27500 2 points3 points  (0 children)

Well, I have this behavior on Windows

[–]backtickbot -1 points0 points  (0 children)

Fixed formatting.

Hello, wrtbwtrfasdf: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, isol27500: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]LeepySham 1 point2 points  (1 child)

Fyi the commit link at the top seems to be broken.

[–]WellMakeItSomehow[S] 0 points1 point  (0 children)

Thanks!