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

Weird error span for a mix of proc macro attributes #59013

Closed
nox opened this issue Mar 8, 2019 · 3 comments
Closed

Weird error span for a mix of proc macro attributes #59013

nox opened this issue Mar 8, 2019 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nox
Copy link
Contributor

nox commented Mar 8, 2019

In Servo, we have a proc_macro_attribute named dom_struct which emits a bunch of other attributes on the types it adorns, among which a derive attribute. Node, being itself a DOM struct, obviously uses it.

In the process of making use of inert, I added an #[inert::neutralize] attribute on Node but I put it after #[dom_struct], so rustc emitted an "macro attributes must be placed before #[derive]" error as it should, so far so good.

#[dom_struct]
#[inert::neutralize(as pub unsafe InertNode)] // ERROR: macro attributes must be placed before `#[derive]`
pub struct Node {
    ...
}

The problem is that the span itself of the error is completely wrong:

error: macro attributes must be placed before `#[derive]`
  --> components/script/lib.rs:1:1
   |
1  | / /* This Source Code Form is subject to the terms of the Mozilla Public
2  | |  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  | |  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4  | |
...  |
97 | | use crate::dom::bindings::proxyhandler;
98 | | use crate::serviceworker_manager::ServiceWorkerManager;
   | |_____________^

Most notably, use crate::serviceworker_manager::ServiceWorkerManager; is line 56 in that file.

Things that should be kept in mind while trying to debug that is that I don't use quote_spanned! for this specific kind of inert::neutralize attribute, but dom_struct itself does weird things because of #46489, but I really don't know if the wrong span is related to that bug.

@nox nox added the A-diagnostics Area: Messages for errors, warnings, and lints label Mar 8, 2019
@nox nox changed the title Weird span error for a mix of proc macro attributes Weird error span for a mix of proc macro attributes Mar 8, 2019
@jonas-schievink jonas-schievink added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Mar 8, 2019
@Aaron1011 Aaron1011 added the A-proc-macros Area: Procedural macros label May 24, 2020
@Aaron1011
Copy link
Member

@nox: Is there an easy way to reproduce this?

@nox
Copy link
Contributor Author

nox commented May 25, 2020

No.

@estebank estebank added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Mar 15, 2023
@apiraino
Copy link
Contributor

Closing as an MCVE could not be provided

@apiraino apiraino closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants