-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rocket should handle attribute macro errors more gracefully. #1967
Comments
I would like to add that in my opinion, this is kind of a necessity for a second RC or a full release of 0.5. Releasing with a broken IDE experience would certainly not be good (though I have to agree with the point async-trait made that this should probably not be the responsibility of the proc macro crates, but that's where we are right now). |
To be clear:
I agree with @dtolnay that this is an issue that should be handled by |
Hello, @SergioBenitez! Great to hear from you, and many thanks for maintaining Rocket. :) As for (1), I pretty much exclusively use I think most of the community has tended to agree with @dtolnay here, which is why |
Is this the "don't expand proc-macros" setting? |
Note that you need to ask rust-analyzer to use nightly, too. I say that this shouldn't be an issue on nightly because we don't emit a |
Yep! Or rather, you can specify a list of macros for "rust-analyzer.procMacro.ignored": {
"rocket_okapi_codegen": [
"openapi"
],
"async-trait": [
"async_trait"
],
"rocket_codegen": [
"get",
"post",
"put",
"delete",
"patch",
"head",
"options",
],
},
Got it, this might be why I didn't ever see failures, but I saw just a "lack" of any local code completion capabilities. Since there was no Personally, I am happy with the |
Sounds good! |
Description
The Rocket attribute macros may not handle errors gracefully, which results in
rust-analyzer
failing to work inside of, e.g., http handler methods marked with attributes (e.g.,get
orpost
). See rust-lang/rust-analyzer#10652 for screenshots ofrust-analyzer
code completion suggestions in http handlers.FWIW, other crates have similar issues. See rust-lang/rust-analyzer#10498.
To Reproduce
With
rust-analyzer
enabled, attempt a code completion in a Rocket http handler (e.g.,get
). For example, the following code would fail to provide suggestions (pipe used as cursor).Generally,
key.
would provideString
method completion suggestions. When inside of this method, there are no suggestions due to the macro expansion. It seems like this happens because the macro re-emits the method, and doesn't handle the syntax errors well.Expected Behavior
The macro expansion would handle errors gracefully and not break
rust-analyzer
code completion.Environment:
The text was updated successfully, but these errors were encountered: