lance-format / lance-format/lance

Make `location: location!()` less painful to use

Open
#1,298 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
7.1k
Forks
852
Avg merge
3d 18h
Merged PRs (30d)
272

Description

snafu::Location is a struct we can include in our error types. The Location struct records the line at which the error is created. This is very helpful for debugging. However, there are a few drawbacks:

  1. We need to call location: location!() at every error init site. This is tedious and annoying.
  2. While the SomethingSnafu types generated can automatically record locations, there are complications with it as well.
  3. It's unclear to new comers to the repo what the heck is a Snafu
  4. the location captured in async code is not correct without special tricks: https://docs.rs/snafu/latest/snafu/struct.Location.html#asynchronous-code

Idea: Maybe we could write a proc macro that scans for all Error init sites and inject location: location!() calls everywhere.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the issue's proposal to design a proc macro that scans error initialization sites and injects location calls. First investigate how Snafu error types and async locations currently work; done would require a concrete, agreed-upon approach that addresses both repetitive call sites and async correctness.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.