Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select! macro and auto-complete #1019

Open
hasezoey opened this issue Aug 21, 2023 · 1 comment
Open

select! macro and auto-complete #1019

hasezoey opened this issue Aug 21, 2023 · 1 comment

Comments

@hasezoey
Copy link

hasezoey commented Aug 21, 2023

Currently with crossbeam 0.8.2 using select! with rust-analyzer (and rustfmt) is quite annoying because rustfmt cannot format the inner contents and rust-analyzer cannot give much or any auto-completion (especially on incomplete input like msg.).

Full Repository

rust-lang/rust-analyzer#12759

Workarounds would be to use functions instead of a macro, but in my opinion using Select directly currently is somewhat unsafe / a maintenance problem, because indexes out-of-bounds could be used or the order of events might be change and with that the returned index but the match block might be forgotten to be changed and so lead to a panic (assert on pointers).
Something to fix this would be something akin to sel.recv(&rx1, SomeEnum::rx1)(where either the enum is a u* or Hash?) and later matching against that enum (in case it is already defined a panic should be used) or directly (if possible) store the receiver and return it with the SelectedOperation

@taiki-e
Copy link
Member

taiki-e commented Aug 22, 2023

Hmm, unlike the RA issue you linked, our select macro is not proc macro. So, aside from the formatter, it is odd that auto comp doesn't work at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants