-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Span is bytes(0..0) in many error cases #482
Comments
Thanks, this is being tracked in rust-lang/rust#43081. For now attribute macros only receive a usable span if the input is formatted precisely the way that rustc's ugly-printer would format it. In this case if you write a trailing comma in error: dummy_attr only applies to methods in an impl block
--> src/main.rs:11:5
|
11 | impl Simple {
| ^^^^ |
Thanks for pointing me to that issue. I suspected compiler limitations are at play. The statement case might be a different bug though! #![feature(proc_macro_expr)]
#![feature(stmt_expr_attributes)]
extern crate dummy_attr;
pub mod simple {
use dummy_attr::dummy_attr;
pub struct Simple {
num: i32,
}
impl Simple {
pub fn add_1(&mut self) { #[dummy_attr] self.num += 1; }
}
} |
All the "spans are null when they shouldn't be" issues are ultimately a consequence of rust-lang/rust#43081. Closing in favor of that issue. |
Assume we have this trivial proc-macro-attribute:
If we try it on a struct, we get a useful span:
Compile error:
But if we try it in other contexts like a module, an impl block, or a statement, the span is
bytes(0..0)
.For example:
The error does not have a useful span:
The text was updated successfully, but these errors were encountered: