-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
macros: Improve IDE support #6968
base: master
Are you sure you want to change the base?
Conversation
I will send a fix tomorrow. |
What’s really blocking the CI is that, Current changes preserved async body as-is: #[tokio::main]
async fn test_with_semicolon_without_return_type() {
#![deny(clippy::semicolon_if_nothing_returned)]
#[deny(clippy::semicolon_if_nothing_returned)]
0;
} So would convert into: fn test_with_semicolon_without_return_type() {
let body = async {
#![deny(clippy::semicolon_if_nothing_returned)] // ❌
#[deny(clippy::semicolon_if_nothing_returned)]
0;
};
...
} I didn’t realize this, The previous implementation moved global inner attributes outside: #[deny(clippy::semicolon_if_nothing_returned)]
fn test_with_semicolon_without_return_type() {
let body = async {
#[deny(clippy::semicolon_if_nothing_returned)]
0;
};
...
} There are many ways to address this issue. |
If you believe the output changes are acceptable, you can update the outputs to make the tests pass. See But keep in mind that just because something is not explained in the documentation, that doesn't mean we can just change it. We don't want to break existing users of the macro. |
Speaking as a person who works on rust-analyzer:
|
Oh! It turns out span is used for type suggestion in return or end statements, so I'll revert the previous change. Seems like it also fix some code suggestion: #3766 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Changes to parse_knobs and ItemFn looks generally good to me.
@@ -437,7 +531,7 @@ fn parse_knobs(mut input: ItemFn, is_test: bool, config: FinalConfig) -> TokenSt | |||
quote! {} | |||
}; | |||
|
|||
let body_ident = quote! { body }; | |||
let body_var = Ident::new("body", Span::call_site()); | |||
// This explicit `return` is intentional. See tokio-rs/tokio#4636 | |||
let last_block = quote_spanned! {last_stmt_end_span=> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests-build/tests/macros.rs
Outdated
@@ -13,10 +13,10 @@ fn compile_fail_full() { | |||
t.pass("tests/pass/macros_main_loop.rs"); | |||
|
|||
#[cfg(feature = "full")] | |||
t.compile_fail("tests/fail/macros_invalid_input.rs"); | |||
t.pass("tests/fail/macros_dead_code.rs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move macros_dead_code.rs
to tests/pass
and remove macros_dead_code.stderr
.
(Although it is odd that the dead_code will no longer be reported.)
This refectory improve performance and enhance better compatibility with IDEs.
Here is two examples,
Before: Note that there is no inlay hints for function arguments.
After: Fixed inlay hint hints problem.
channel(buffer: ..
,tokio::spawn(future: ..
Before: On syntax error.
Run Test | Debug
button dissipated. which is frustrating because the editor toggles back and forth while typing.After: It fix that.
It introduce two changes:
Removespaned
, Because as it's not meant to be used here.