const-eval: support (symbolic) distance between two pointers
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
LLVM and linkers apparently can represents the distance between two symbols symbolically, but currently there is no way to get rustc to emit those instructions. The proper way to implement this would be for const-eval to have symbolic values that represent the distance between two pointers. That's possible but it's a non-trivial extension of the core const-eval machinery.
This comes up in our Windows SEH code that really would like compile-time pointer distance, and works around it with lazy initialization at runtime that is technically UB.
I don't know if that is a strong enough usecase to warrant supporting this, but it is at least worth tracking.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Windows SEH use case in library/panic_unwind/src/seh.rs, especially lines 318-337, and then trace the const-eval machinery responsible for pointer values and linker-emitted instructions. Determine the design needed for symbolic distances between pointers and identify the relevant compiler tests before defining completion criteria.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100