Use more useful panic message for with_session_globals when TLS variable not set
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Currently this panics with "cannot access a scoped thread local variable without calling set first", which doesn't explain why that is the case. In my experience this is generally caused by either someone forgetting to add extern crate rustc_driver; to their codegen backend (or back when we still supported them, their rustc plugin) or compiling against a different rustc_driver than the rustc it gets loaded into. It would be nice to indicate this in the panic message. Ideally we would also prevent loading the codegen backend entirely when either scenario is detected.
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 by locating the with_session_globals entry point and tracing where its thread-local state is initialized. Then inspect the codegen backend loading path to determine whether the panic message can identify a missing rustc_driver dependency or version mismatch, and whether loading should be prevented in those cases. Done means the failure explains the likely cause and the loading behavior is addressed if that scope is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100