dtolnay / ghost

Define your own PhantomData

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support phantom types inside a method body

dtolnay opened this issue · comments

The poor interaction between method bodies and handling of relative paths in use statements in Rust makes this extremely challenging or (I currently believe) impossible to support. Doesn't hurt to have an issue though:

use ghost::phantom;

fn main() {
    #[phantom]
    struct MyPhantom<T>;
}
error[E0432]: unresolved import `super::MyPhantom`
 --> src/main.rs:5:12
  |
5 |     struct MyPhantom<T>;
  |            ^^^^^^^^^ maybe a missing `extern crate MyPhantom;`?

error[E0432]: unresolved import `self`
 --> src/main.rs:4:5
  |
4 |     #[phantom]
  |     ^^^^^^^^^^ maybe a missing `extern crate __value_MyPhantom;`?