-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rustc doesn't report line numbers for type errors within proc macro async fn within macro_rules macro #68430
Comments
I can also add that incorrect line information is reported for panics, it's says src/main.rs:1:1 instead of the actual file and line.
|
I'm seeing the same thing, at the trait/impl level. I have a macro that wraps pub fn async_sync_trait(args: TokenStream, input: TokenStream) -> TokenStream {
let args = parse_macro_input!(args as Args);
let mut item = parse_macro_input!(input as Item);
// Adds some methods
expand(&mut item, args.local);
if args.local {
TokenStream::from(quote! {
#[async_trait::async_trait(?Send)]
#item
})
} else {
TokenStream::from(quote! {
#[async_trait::async_trait]
#item
})
}
} If I don't emit the |
[triagebot] Can't say anything without investigating, won't investigate due to low priority. |
I'm having this problem too. I made a repo with a minimal reproduction FWIW. I'm not sure if this completely explains the problem, but in this repo I defined two trivial proc macro attributes, one which spits out the code unchanged (#[noop]), another which quotes the code and then spits that out unchanged ([#quoter]). I tried various combinations of these two macros, and all of them preserve line numbers for type errors except when applying noop and then quoter. Here is the line that demonstrates the combination that causes line numbers to be erased: https://github.com/maackle/nested-proc-macro-mcve/blob/master/app/src/main.rs#L21 |
@petrochenkov It's P-high now, I posted a small repro in another issue: #51635 (comment) That doesn't need anything async to show this behavior, so it might just be more general. |
Taking a look at this. |
triage: visited as part of general query of unassigned P-high non-ICE issues. But it looks like @nellshamrell is taking a look at this, so I'm marking as assigned to nell for now. |
Hello all - looking at my list of things to do, I realized I'm not going to be able to get to this in the immediate future. Taking my name off the issue for now so someone else can pick it up if they have time before I do. |
This looks like another instance of #43081 |
Fixes rust-lang#68430 This is a re-attempt of PR rust-lang#72388, which was previously reverted due to a large number of breakages. All of the known breakages should now be patched upstream.
When using a macro to generate an async fn with a proc macro inside it, if the generated function includes a type error, rustc will not report any line number information. This makes finding and debugging type errors in large async applications extremely difficult.
I tried this code:
I expected to see this happen:
Error including line number information (you will get this output if you just comment out the
$before
line in the test fn)Instead, this happened:
Error including no line number information
Meta
rustc --version --verbose
: Tested on Playground with stable 1.40.0 and nightly 1.42.0 (2020-01-20)The text was updated successfully, but these errors were encountered: