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

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

Open
jonas-schievink opened this issue Mar 1, 2023 · 3 comments · Fixed by #5762
Open

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

jonas-schievink opened this issue Mar 1, 2023 · 3 comments · Fixed by #5762
Labels
A-tokio-macros Area: The tokio-macros crate C-request Category: A non-feature request, e.g.: metadata updates, optimization suggestion, etc. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@jonas-schievink
Copy link

Version
tokio-macros 1.8.2

Platform
n/a

Description

In the following code, the variable; statement has incorrect spans attached to itself:

#[tokio::main]
async fn main() {
    let variable = "";
    variable;
}

The spans of variable; point to tokio::runtime::Builder::new_multi_thread() in the output of the macro. This causes rust-analyzer to (correctly) highlight variable as a function call and to show the new_multi_thread function on hover.

Please consider not doing this, as it degrades IDE functionality.

@jonas-schievink jonas-schievink added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Mar 1, 2023
@Darksonn Darksonn added A-tokio-macros Area: The tokio-macros crate E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate and removed A-tokio Area: The main tokio crate labels Mar 1, 2023
@Darksonn
Copy link
Contributor

Darksonn commented Mar 2, 2023

Thanks for reporting this bug. You are correct that it seems to be using the wrong span. Perhaps the #[tokio::main] macro's span would be better?

@jonas-schievink
Copy link
Author

Yeah, Span::call_site() should be a good default

@taiki-e
Copy link
Member

taiki-e commented Apr 15, 2023

These were intended to improve diagnostics (#3766), but I would accept a patch to improve compatibility with rust-analyzer as long as there are no diagnostics regressions.

@taiki-e taiki-e added C-request Category: A non-feature request, e.g.: metadata updates, optimization suggestion, etc. and removed C-bug Category: This is a bug. labels Apr 15, 2023
@Darksonn Darksonn removed E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Jun 4, 2023
@Darksonn Darksonn reopened this Jun 4, 2023
@Darksonn Darksonn added E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Oct 1, 2023
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 C-request Category: A non-feature request, e.g.: metadata updates, optimization suggestion, etc. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
3 participants