Skip to content

Error spans in macros 1.1 #36218

Closed
Closed
@dtolnay

Description

@dtolnay

I understand that we can't know the spans correctly after passing through rustc_macro_derive but instead of pointing to the "Serialize" in these examples I think it would usually be less misleading to point to the "struct A" or maybe to the entire struct body. I don't want to field these support tickets in Serde's issue tracker:

trait T {
    fn f();
}

#[derive(Serialize, Deserialize)]
struct A {
    exciting: &T,
}

#[derive(Serialize, Deserialize)]
struct B<'a> {
    exciting: &'a T,
}
error[E0106]: missing lifetime specifier
  --> src/main.rs:10:10
   |
10 | #[derive(Serialize, Deserialize)]
   |          ^ expected lifetime parameter

error[E0038]: the trait `T` cannot be made into an object
  --> src/main.rs:15:15
   |
15 | #[derive(Serialize, Deserialize)]
   |          ^^^^^^^^^^ the trait `T` cannot be made into an object

Side note: those errors are inconsistent with each other, one points to just the letter "S", the other to "Serialize,".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions