dtolnay / dtolnay/ghost

Support phantom types inside a method body

Open
#1 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
167
Forks
31
PR merge metrics
No merged PRs in 30d

Description

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:

```rust
use ghost::phantom;

fn main() {
#[phantom]
struct MyPhantom;
}
```

```console
error[E0432]: unresolved import `super::MyPhantom`
--> src/main.rs:5:12
|
5 | struct MyPhantom;
| ^^^^^^^^^ 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;`?
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Rust example in the issue and examine how the method body interacts with relative paths in `use` statements. The issue does not name implementation files or tests; done would mean supporting the shown `#[phantom]` declaration inside `main` without the unresolved-import errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.