Skip to content

Support phantom types inside a method body #1

Description

@dtolnay

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;`?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions