-
Notifications
You must be signed in to change notification settings - Fork 1.8k
proc macro server crashed #8925
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
Comments
Works for me in The proc macro ABI strikes again. |
For the confused (like me), this is not caused by building rust-analyzer with nightly, but rather your own project. The last working version is |
Thanks @ivan. |
The solution is not to use |
Or to disable proc macro support. |
Turning proc macros off works. I've seen this on quite a few projects now. This seems a pretty widespread regression. Maybe proc macro should default to off for the moment as it could give a bad impression to new users - seeing a sea of red and them thinking they've done something wrong? |
I would assume that most new users aren't running nightly. |
For one reason or another, an awful lot of people are on nightly and their take away will be that something's up with RA because they're building fine with cargo. I think you're all doing a great job, I'm just concerned that this bug (rightly or wrongly) is making RA look flaky to a fair section of your userbase. |
Disabling proc macros completely would have a far greater impact. |
Hi guys, i'm getting this |
ok, I figured it out |
don't think this is a safe assumption.
|
Right now we can't support multiple ABI versions, so we can't merge the open PR unit these nightlies hit
I'd guess there are about 3-4 breaking ABI changes per year.
You won't get completions and other IDE features for code generated by proc macros. |
This comment has been minimized.
This comment has been minimized.
Disabling proc macros will break a lot of functionality for stable users; it's not an option. We might want to think about supporting multiple ABI versions, or detecting nightlies with broken ABI and disabling proc macros for those; on the other hand, once we're following the Rust release train, we can just follow the nightly ABI. @adsick that doesn't sound like a problem with our proc macro integration, since most errors are provided by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hmm, I could think of a hack that might work: you have two release streams at the moment, a nightly rust analyser and a weekly one. If the nightly rust analyser was targeting the nightly abi that might be a resonable compromise? |
That would mean supporting both ABIs anyway, so it would probably be almost as much work as just supporting both in the same build. |
Could you elaborate, @gilescope ? I tried the following steps, and no lucky -
|
@lnicola actually I tried to build rust-analyzer on that patch, and it doesn't work for me. Anything goes wrong? Edited: oh, maybe it's indeed not enough. |
It might be #9047 (comment), depending on your nightly version. |
@flisky clone the master & |
Here's my fork with another commit that allows building for current nightly: https://github.com/yotamofek/rust-analyzer/tree/literal-from-str |
Having to wait for almost 3 months to get proc-macro working again, is really a sore point for me as most of the functions of one of my libraries are generated by proc-macros, and the library depends on nightly Rust. And if this happens 3-4 times a year (although I didn't notice such a thing last year) it would be broken most of the year. So, should If multiple ABIs is an option and needs help, I am happy to help out with some mentoring. |
(Quoted from #6755 (comment))
Would it be reasonable to include this information in the |
Just hit this myself. Agreed with the logic above that if multiple such breakages happen a year with a multi-month delay before the ABI changes can be merged to RA then it seems like RA with nightly will be unusable most of the year. I don't use nightly except when I have to, but it's not uncommon to run into an existing project/library that requires nightly for one reason or another. For example, I encountered this with https://github.com/serenity-rs/serenity which relies on unstable rustfmt features. |
@sbrocket you can use nightly |
FWIW, even if you disable proc macro support you can still get incorrect errors from this. Currently I have proc macro support disabled, and RA is giving me an error saying there is no method with a particular name on a type generated using proc macros, but the code compiles successfully. |
That's normal: since the macro didn't run, rust-analyzer can't know about the code it works have generated. You can disable these diagnostics, but only globally -- there's no way to tell "this method would have been generated by a proc macro" without actually executing the said macro. |
Actually I don't believe that is normally the case, is it? Usually errors relating to proc macro generated code are suppressed, otherwise any usage of proc macro code without the server would give an error. In any case, I suspect the error I was talking about was due to a separate issue, so probably best to disregard my comment for now. |
FWIW, i believe this is currently hitting |
^ it is and will hit stable on 29-07-2021, then it'll be fixed to work with the new stable. Beta and nightly will work as well unless they get proc-macro changes again. |
And it does. |
Is there a way we could handle this sort of ABI change in the future by having two channels for rust-analyzer, one that only reflects the |
9550: Proc macro multi abi proof of concept r=matklad a=alexjg #8925 was irritating me so I thought I would have a bash at fixing it. What I've done here is copy the `crates/proc_macro_srv/src/proc_macro` code (which is copied from `<RUST>/library/proc_macro`) to `crates/proc_macro_srv/src/proc_macro_nightly` and the modified the nightly version to include the changes from #9047 and https://github.com/yotamofek/rust-analyzer/commit/aeb7b183a2302af968f1110fb3cbd00c76a34974 This gives us the code to support both stable and nightly ABIs. Then we use the `proc_macro_api::version::read_dylib_info` to determine which version of the ABI to load when creating a `ProcMacroLibraryLibLoading` (which is now an enum). This seems to work for me. The code could be cleaned up but I wanted to see if the approach makes sense before I spend more time on it. I've split the change into two commits, the first is just copying and modifying the `proc_macro` crate, the second contains most of the interesting work around figuring out which ABI to use. Co-authored-by: Alex Good <[email protected]> Co-authored-by: alexjg <[email protected]>
Fixed in #9550. |
rust-analyzer version: b824588 2021-05-17 stable
After
rustup update
and maybe a new version of ra I get this error: 'proc macro returned error: proc-macro panicked: range end index 8 out of range for slice of length 0'.stack backtrace:
Here's a minimal example: https://github.com/NickNick/ra-proc-macro-panic-derivemore-from
For me it looks like this:

... but runs fine:
The text was updated successfully, but these errors were encountered: