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

macros: fix diagnostics of last statement #5762

Merged
merged 1 commit into from
Jun 4, 2023
Merged

macros: fix diagnostics of last statement #5762

merged 1 commit into from
Jun 4, 2023

Conversation

icedrocket
Copy link
Contributor

@icedrocket icedrocket commented Jun 4, 2023

This change prevents rust-analyzer from incorrectly analyzing the last statement of the main function as a Builder::new_* method.

Fixes #5518

It was a combination of coincidences that led me to think the issue was resolved.

This commit prevents rust-analyzer from incorrectly analyzing the last
statement of the main function as a `Builder::new_*` method.
@Darksonn Darksonn added the A-tokio-macros Area: The tokio-macros crate label Jun 4, 2023
@Darksonn
Copy link
Contributor

Darksonn commented Jun 4, 2023

This PR is simpler than the abandoned #5619. What is the difference?

@icedrocket
Copy link
Contributor Author

icedrocket commented Jun 4, 2023

I think the problem was caused by the presence of unspanned tokens between spanned tokens. After removing the span hole, it was displayed correctly in the IDE.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, if this works for you in your IDE, then that's good enough for me.

@Darksonn Darksonn merged commit 076d77c into tokio-rs:master Jun 4, 2023
@Darksonn
Copy link
Contributor

Darksonn commented Jun 4, 2023

Thanks!

@icedrocket
Copy link
Contributor Author

icedrocket commented Jun 4, 2023

I apologize, it looks like the problem hasn't been fixed.

Something very strange happened to me. When I rebuilt after deleting the target directory and Cargo.lock, it seemed to be fixed, but when I set the dependency to a Git repository after the PR was merged, it didn't fix the problem. Setting the dependency to a local repository makes the problem go away, regardless of the patch.

I assumed this was caused by a bad local cache, so I cleared the extension and even reinstalled the entire rust compiler, but that didn't fix it.

Edit:
It seems that for some reason, rust-analyzer sometimes fails to load procedural macros properly from local repositories.

@Darksonn
Copy link
Contributor

Darksonn commented Jun 4, 2023

Okay, I reopened the issue. That said, I'm not sure we have to revert the change. It doesn't seem problematic.

@icedrocket
Copy link
Contributor Author

I didn't see your comment before creating the revert PR.

@icedrocket icedrocket deleted the macro-diagnostics branch June 11, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-macros Area: The tokio-macros crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[tokio::main] proc macro attaches questionable spans to user code
2 participants