Skip to content

Get def_site() to resolve paths #290

Closed
@dtolnay

Description

@dtolnay

I got stuck trying to get Span::def_site() to resolve things correctly with --features proc-macro2/unstable. @mystor could you take a look?

quote_spanned! {
    Span::def_site(),
    impl #impl_generics HeapSize for #name #ty_generics #where_clause {
        fn heap_size_of_children(&self) -> usize {
            0
        }
    }
}

Run cargo build in this directory to see the error.

error[E0405]: cannot find trait `HeapSize` in this scope
 --> src/main.rs:7:10
  |
7 | #[derive(HeapSize)]
  |          ^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
  |
5 | use heapsize::HeapSize;
  |

With Span::call_site() it correctly resolves the HeapSize imported by main.rs, but I want def_site() so that it resolves the one in scope within the heapsize_derive crate. Is this not implemented yet or am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions